X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helper.py;h=21e95c76ab18738875c9e283e2266fd4a5ad631c;hb=23f4616a85bef7e9acc57740f889a2a0346788af;hp=d948dacd6caadec59c643bcb242c6b3cfd4b7642;hpb=2033e7fef780298be2ec15455a0ec1d26515de55;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/helper.py b/helper.py index d948dac..21e95c7 100644 --- a/helper.py +++ b/helper.py @@ -83,8 +83,8 @@ def main_parse_args(argv): parser.add_argument("--user", default=None, required=False, help="Only run for that user") parser.add_argument("--action", - default=None, required=False, - help="Do a different action than trading") + action='append', + help="Do a different action than trading (add several times to chain)") args = parser.parse_args(argv) @@ -124,19 +124,19 @@ def main_fetch_markets(pg_config, user): for row in cursor: yield row -def main_process_market(user_market, action, before=False, after=False): - if action is None: +def main_process_market(user_market, actions, before=False, after=False): + if len(actions or []) == 0: if before: process_sell_all__1_all_sell(user_market) if after: portfolio.Portfolio.wait_for_recent(user_market) process_sell_all__2_all_buy(user_market) - elif action == "print_balances": - print_balances(user_market) - elif action == "print_orders": - print_orders(user_market) else: - raise NotImplementedError("Unknown action {}".format(action)) + for action in actions: + if action in globals(): + (globals()[action])(user_market) + else: + raise NotImplementedError("Unknown action {}".format(action)) def main_store_report(report_path, user_id, user_market): try: