trades = None
balances = None
- def __init__(self, ccxt_instance, debug=False, user_id=None, report_path=None):
- self.debug = debug
+ def __init__(self, ccxt_instance, args, user_id=None, report_path=None):
+ self.args = args
+ self.debug = args.debug
self.ccxt = ccxt_instance
self.ccxt._market = self
- self.report = ReportStore(self)
+ self.report = ReportStore(self, verbose_print=(not args.quiet))
self.trades = TradeStore(self)
self.balances = BalanceStore(self)
self.processor = Processor(self)
self.report_path = report_path
@classmethod
- def from_config(cls, config, debug=False, user_id=None, report_path=None):
+ def from_config(cls, config, args, user_id=None, report_path=None):
config["apiKey"] = config.pop("key", None)
ccxt_instance = ccxt.poloniexE(config)
ccxt_instance.session.request = request_wrap.__get__(ccxt_instance.session,
ccxt_instance.session.__class__)
- return cls(ccxt_instance, debug=debug, user_id=user_id, report_path=report_path)
+ return cls(ccxt_instance, args, user_id=user_id, report_path=report_path)
def store_report(self):
self.report.merge(Portfolio.report)
try:
if self.report_path is not None:
- report_file = "{}/{}_{}.json".format(self.report_path, datetime.now().isoformat(), self.user_id)
- with open(report_file, "w") as f:
+ report_file = "{}/{}_{}".format(self.report_path, datetime.now().isoformat(), self.user_id)
+ with open(report_file + ".json", "w") as f:
f.write(self.report.to_json())
+ with open(report_file + ".log", "w") as f:
+ f.write("\n".join(map(lambda x: x[1], self.report.print_logs)))
except Exception as e:
print("impossible to store report file: {}; {}".format(e.__class__.__name__, e))