diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-01 15:23:27 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-01 15:23:27 +0100 |
commit | 23f4616a85bef7e9acc57740f889a2a0346788af (patch) | |
tree | d701f03a699c107e16a562a106bf67a1071a7e2f /helper.py | |
parent | 7192b2e1315c3dfd1204d609d716dd07e90f3bf4 (diff) | |
download | Trader-23f4616a85bef7e9acc57740f889a2a0346788af.tar.gz Trader-23f4616a85bef7e9acc57740f889a2a0346788af.tar.zst Trader-23f4616a85bef7e9acc57740f889a2a0346788af.zip |
Dynamically use process methods
Diffstat (limited to 'helper.py')
-rw-r--r-- | helper.py | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -83,8 +83,8 @@ def main_parse_args(argv): | |||
83 | parser.add_argument("--user", | 83 | parser.add_argument("--user", |
84 | default=None, required=False, help="Only run for that user") | 84 | default=None, required=False, help="Only run for that user") |
85 | parser.add_argument("--action", | 85 | parser.add_argument("--action", |
86 | default=None, required=False, | 86 | action='append', |
87 | help="Do a different action than trading") | 87 | help="Do a different action than trading (add several times to chain)") |
88 | 88 | ||
89 | args = parser.parse_args(argv) | 89 | args = parser.parse_args(argv) |
90 | 90 | ||
@@ -124,19 +124,19 @@ def main_fetch_markets(pg_config, user): | |||
124 | for row in cursor: | 124 | for row in cursor: |
125 | yield row | 125 | yield row |
126 | 126 | ||
127 | def main_process_market(user_market, action, before=False, after=False): | 127 | def main_process_market(user_market, actions, before=False, after=False): |
128 | if action is None: | 128 | if len(actions or []) == 0: |
129 | if before: | 129 | if before: |
130 | process_sell_all__1_all_sell(user_market) | 130 | process_sell_all__1_all_sell(user_market) |
131 | if after: | 131 | if after: |
132 | portfolio.Portfolio.wait_for_recent(user_market) | 132 | portfolio.Portfolio.wait_for_recent(user_market) |
133 | process_sell_all__2_all_buy(user_market) | 133 | process_sell_all__2_all_buy(user_market) |
134 | elif action == "print_balances": | ||
135 | print_balances(user_market) | ||
136 | elif action == "print_orders": | ||
137 | print_orders(user_market) | ||
138 | else: | 134 | else: |
139 | raise NotImplementedError("Unknown action {}".format(action)) | 135 | for action in actions: |
136 | if action in globals(): | ||
137 | (globals()[action])(user_market) | ||
138 | else: | ||
139 | raise NotImplementedError("Unknown action {}".format(action)) | ||
140 | 140 | ||
141 | def main_store_report(report_path, user_id, user_market): | 141 | def main_store_report(report_path, user_id, user_market): |
142 | try: | 142 | try: |