From 43bdb04868d3b77d3f651eb5f67859b07e66612f Mon Sep 17 00:00:00 2001 From: atreyuxtrading <107624011+atreyuxtrading@users.noreply.github.com> Date: Tue, 1 Nov 2022 16:36:12 +0000 Subject: [PATCH] Update ibbroker.py Date from IBKR was broken --- atreyu_backtrader_api/ibbroker.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/atreyu_backtrader_api/ibbroker.py b/atreyu_backtrader_api/ibbroker.py index c20c671..d7b8918 100644 --- a/atreyu_backtrader_api/ibbroker.py +++ b/atreyu_backtrader_api/ibbroker.py @@ -518,7 +518,14 @@ def push_commissionreport(self, cr): # Use the actual time provided by the execution object # The report from TWS is in actual local time, not the data's tz - dt = date2num(datetime.strptime(ex.time, '%Y%m%d %H:%M:%S')) + #dt = date2num(datetime.strptime(ex.time, '%Y%m%d %H:%M:%S')) + dt_array = [] if ex.time == None else ex.time.split(" ") + if dt_array and len(dt_array) > 1: + dt_array.pop() + ex_time = " ".join(dt_array) + dt = date2num(datetime.strptime(ex_time, '%Y%m%d %H:%M:%S')) + else: + dt = date2num(datetime.strptime(ex.time, '%Y%m%d %H:%M:%S %A')) # Need to simulate a margin, but it plays no role, because it is # controlled by a real broker. Let's set the price of the item