diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-05 09:56:51 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-05 09:56:51 +0200 |
commit | a42d6cc8a49e82d851cde587fbc938b3b6364f63 (patch) | |
tree | e01688e2a4d72ffa0aaf6f278906cac9d716d0d1 /market.py | |
parent | 3b60291066e5442ce2980a6c40ea10542f24a910 (diff) | |
download | Trader-a42d6cc8a49e82d851cde587fbc938b3b6364f63.tar.gz Trader-a42d6cc8a49e82d851cde587fbc938b3b6364f63.tar.zst Trader-a42d6cc8a49e82d851cde587fbc938b3b6364f63.zip |
Refactor config parsing
Diffstat (limited to 'market.py')
-rw-r--r-- | market.py | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -25,11 +25,10 @@ class Market: | |||
25 | self.balances = BalanceStore(self) | 25 | self.balances = BalanceStore(self) |
26 | self.processor = Processor(self) | 26 | self.processor = Processor(self) |
27 | 27 | ||
28 | for key in ["user_id", "market_id", "report_path", "pg_config"]: | 28 | for key in ["user_id", "market_id", "pg_config"]: |
29 | setattr(self, key, kwargs.get(key, None)) | 29 | setattr(self, key, kwargs.get(key, None)) |
30 | 30 | ||
31 | self.report.log_market(self.args, self.user_id, self.market_id, | 31 | self.report.log_market(self.args, self.user_id, self.market_id) |
32 | self.report_path, self.debug) | ||
33 | 32 | ||
34 | @classmethod | 33 | @classmethod |
35 | def from_config(cls, config, args, **kwargs): | 34 | def from_config(cls, config, args, **kwargs): |
@@ -42,14 +41,14 @@ class Market: | |||
42 | def store_report(self): | 41 | def store_report(self): |
43 | self.report.merge(Portfolio.report) | 42 | self.report.merge(Portfolio.report) |
44 | date = datetime.now() | 43 | date = datetime.now() |
45 | if self.report_path is not None: | 44 | if self.args.report_path is not None: |
46 | self.store_file_report(date) | 45 | self.store_file_report(date) |
47 | if self.pg_config is not None: | 46 | if self.pg_config is not None and self.args.report_db: |
48 | self.store_database_report(date) | 47 | self.store_database_report(date) |
49 | 48 | ||
50 | def store_file_report(self, date): | 49 | def store_file_report(self, date): |
51 | try: | 50 | try: |
52 | report_file = "{}/{}_{}".format(self.report_path, date.isoformat(), self.user_id) | 51 | report_file = "{}/{}_{}".format(self.args.report_path, date.isoformat(), self.user_id) |
53 | with open(report_file + ".json", "w") as f: | 52 | with open(report_file + ".json", "w") as f: |
54 | f.write(self.report.to_json()) | 53 | f.write(self.report.to_json()) |
55 | with open(report_file + ".log", "w") as f: | 54 | with open(report_file + ".log", "w") as f: |