diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-23 23:33:36 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-24 10:39:52 +0100 |
commit | 35667b31ddf1ce47a56ccbf4db9896dbc165ad0a (patch) | |
tree | 758fa5203849f284bd8379d8928b22dfbbbc699e /market.py | |
parent | 88e486a61fd563b3d30d34e1962269eae5a931bf (diff) | |
download | Trader-35667b31ddf1ce47a56ccbf4db9896dbc165ad0a.tar.gz Trader-35667b31ddf1ce47a56ccbf4db9896dbc165ad0a.tar.zst Trader-35667b31ddf1ce47a56ccbf4db9896dbc165ad0a.zip |
Cleanup market from_config
Diffstat (limited to 'market.py')
-rw-r--r-- | market.py | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -14,9 +14,7 @@ class Market: | |||
14 | trades = None | 14 | trades = None |
15 | balances = None | 15 | balances = None |
16 | 16 | ||
17 | def __init__(self, ccxt_instance, args, | 17 | def __init__(self, ccxt_instance, args, **kwargs): |
18 | user_id=None, market_id=None, | ||
19 | report_path=None, pg_config=None): | ||
20 | self.args = args | 18 | self.args = args |
21 | self.debug = args.debug | 19 | self.debug = args.debug |
22 | self.ccxt = ccxt_instance | 20 | self.ccxt = ccxt_instance |
@@ -26,14 +24,11 @@ class Market: | |||
26 | self.balances = BalanceStore(self) | 24 | self.balances = BalanceStore(self) |
27 | self.processor = Processor(self) | 25 | self.processor = Processor(self) |
28 | 26 | ||
29 | self.user_id = user_id | 27 | for key in ["user_id", "market_id", "report_path", "pg_config"]: |
30 | self.market_id = market_id | 28 | setattr(self, key, kwargs.get(key, None)) |
31 | self.report_path = report_path | ||
32 | self.pg_config = pg_config | ||
33 | 29 | ||
34 | @classmethod | 30 | @classmethod |
35 | def from_config(cls, config, args, | 31 | def from_config(cls, config, args, **kwargs): |
36 | user_id=None, market_id=None, report_path=None, pg_config=None): | ||
37 | config["apiKey"] = config.pop("key", None) | 32 | config["apiKey"] = config.pop("key", None) |
38 | 33 | ||
39 | ccxt_instance = ccxt.poloniexE(config) | 34 | ccxt_instance = ccxt.poloniexE(config) |
@@ -50,9 +45,7 @@ class Market: | |||
50 | ccxt_instance.session.request = request_wrap.__get__(ccxt_instance.session, | 45 | ccxt_instance.session.request = request_wrap.__get__(ccxt_instance.session, |
51 | ccxt_instance.session.__class__) | 46 | ccxt_instance.session.__class__) |
52 | 47 | ||
53 | return cls(ccxt_instance, args, | 48 | return cls(ccxt_instance, args, **kwargs) |
54 | user_id=user_id, market_id=market_id, | ||
55 | pg_config=pg_config, report_path=report_path) | ||
56 | 49 | ||
57 | def store_report(self): | 50 | def store_report(self): |
58 | self.report.merge(Portfolio.report) | 51 | self.report.merge(Portfolio.report) |