diff options
Diffstat (limited to 'python/position_file_bowdst.py')
| -rw-r--r-- | python/position_file_bowdst.py | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py index 8fd7ac07..95145e08 100644 --- a/python/position_file_bowdst.py +++ b/python/position_file_bowdst.py @@ -27,7 +27,7 @@ def gen_positions_and_fnames(cob, fund): yield buf, dest -def main(cob, fund, upload): +def build_file(cob, fund, upload): client = Client.from_creds("hm_globeop", folder="incoming") attachments = [] for buf, dest in gen_positions_and_fnames(cob, fund): @@ -47,26 +47,42 @@ def main(cob, fund, upload): ) -parser = argparse.ArgumentParser( - description="Generate position files for Bowdoin Street" -) -parser.add_argument( - "date", - nargs="?", - type=datetime.date.fromisoformat, - default=prev_business_day((datetime.date.today().replace(day=1))), -) -parser.add_argument( - "--no-upload", - "-n", - action="store_true", - default=False, - help="uploads to globeop", -) -args = parser.parse_args() -if ( - not prev_business_day(datetime.date.today()) == args.date and not args.no_upload -): # We only want to upload if the previous business day was monthend - pass -else: - main(args.date, "BOWDST", not args.no_upload) +def parse_args(): + parser = argparse.ArgumentParser( + description="Generate position files for Bowdoin Street" + ) + parser.add_argument( + "date", + nargs="?", + type=datetime.date.fromisoformat, + default=prev_business_day((datetime.date.today().replace(day=1))), + ) + parser.add_argument( + "--no-upload", + "-n", + action="store_true", + default=False, + help="uploads to globeop", + ) + parser.add_argument( + "--manual", + "-m", + action="store_true", + default=False, + help="indicates that the script is being run manually", + ) + return parser.parse_args() + + +def main(): + args = parse_args() + if ( + not prev_business_day(datetime.date.today()) == args.date and not args.no_upload + ) and not args.manual: # We only want to upload if the previous business day was monthend + pass + else: + build_file(args.date, "BOWDST", not args.no_upload) + + +if __name__ == "__main__": + main() |
