aboutsummaryrefslogtreecommitdiff
path: root/market.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-12 02:54:13 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-12 02:54:13 +0100
commit718e3e919acb9b57269d3155543f9e8ad1b91324 (patch)
tree25a045b1f77fc36e3bb794ed72dbf02406377a00 /market.py
parent83c698c925db9dcb2d347c2a625de88d85cfeb21 (diff)
downloadTrader-718e3e919acb9b57269d3155543f9e8ad1b91324.tar.gz
Trader-718e3e919acb9b57269d3155543f9e8ad1b91324.tar.zst
Trader-718e3e919acb9b57269d3155543f9e8ad1b91324.zip
Store printed logs
Diffstat (limited to 'market.py')
-rw-r--r--market.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/market.py b/market.py
index 8672c59..2ddebfa 100644
--- a/market.py
+++ b/market.py
@@ -49,9 +49,11 @@ class Market:
49 self.report.merge(Portfolio.report) 49 self.report.merge(Portfolio.report)
50 try: 50 try:
51 if self.report_path is not None: 51 if self.report_path is not None:
52 report_file = "{}/{}_{}.json".format(self.report_path, datetime.now().isoformat(), self.user_id) 52 report_file = "{}/{}_{}".format(self.report_path, datetime.now().isoformat(), self.user_id)
53 with open(report_file, "w") as f: 53 with open(report_file + ".json", "w") as f:
54 f.write(self.report.to_json()) 54 f.write(self.report.to_json())
55 with open(report_file + ".log", "w") as f:
56 f.write("\n".join(map(lambda x: x[1], self.report.print_logs)))
55 except Exception as e: 57 except Exception as e:
56 print("impossible to store report file: {}; {}".format(e.__class__.__name__, e)) 58 print("impossible to store report file: {}; {}".format(e.__class__.__name__, e))
57 59