aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/main.py b/main.py
index 3e98289..4462192 100644
--- a/main.py
+++ b/main.py
@@ -62,9 +62,11 @@ def make_order(market, value, currency, action="acquire",
62 62
63def get_user_market(config_path, user_id, debug=False): 63def get_user_market(config_path, user_id, debug=False):
64 pg_config, report_path = parse_config(config_path) 64 pg_config, report_path = parse_config(config_path)
65 market_config = list(fetch_markets(pg_config, str(user_id)))[0][1] 65 market_id, market_config, user_id = list(fetch_markets(pg_config, str(user_id)))[0]
66 args = type('Args', (object,), { "debug": debug, "quiet": False })() 66 args = type('Args', (object,), { "debug": debug, "quiet": False })()
67 return market.Market.from_config(market_config, args, user_id=user_id, report_path=report_path) 67 return market.Market.from_config(market_config, args,
68 pg_config=pg_config, market_id=market_id,
69 user_id=user_id, report_path=report_path)
68 70
69def fetch_markets(pg_config, user): 71def fetch_markets(pg_config, user):
70 connection = psycopg2.connect(**pg_config) 72 connection = psycopg2.connect(**pg_config)
@@ -132,7 +134,7 @@ def parse_args(argv):
132 134
133 return args 135 return args
134 136
135def process(market_id, market_config, user_id, report_path, args, pg_config): 137def process(market_config, market_id, user_id, args, report_path, pg_config):
136 try: 138 try:
137 market.Market\ 139 market.Market\
138 .from_config(market_config, args, 140 .from_config(market_config, args,
@@ -151,13 +153,13 @@ def main(argv):
151 import threading 153 import threading
152 market.Portfolio.start_worker() 154 market.Portfolio.start_worker()
153 155
154 for row in fetch_markets(pg_config, args.user): 156 def process_(*args):
155 threading.Thread(target=process, args=[ 157 threading.Thread(target=process, args=args).start()
156 *row, report_path, args, pg_config
157 ]).start()
158 else: 158 else:
159 for row in fetch_markets(pg_config, args.user): 159 process_ = process
160 process(*row, report_path, args, pg_config) 160
161 for market_id, market_config, user_id in fetch_markets(pg_config, args.user):
162 process_(market_config, market_id, user_id, args, report_path, pg_config)
161 163
162if __name__ == '__main__': # pragma: no cover 164if __name__ == '__main__': # pragma: no cover
163 main(sys.argv[1:]) 165 main(sys.argv[1:])