@ravi-vidap Hi, this error should not occur with recent sources (issue #41 is now closed)
Latest posts made by EMR
RE: Exception has occurred: ValueError day is out of range for month File "F:\IBBackTradeLiveDataEx.py", line 165, in <module> cerebro.run()
RE: Can get live data from IB but can't trade or get position
@adrianyuen Seems there is a margin issue : "Status: Margin"
Do you have enough cash on the paper account ?
Do you use the store model (https://www.backtrader.com/docu/live/ib/ib/)
RE: feeding sizer with stop loss value
@peixoto Not 100% sure of what you want to achieve (maybe the relevant part of your code would help to understand better) but have you considered to specify size=xxx in your orders, or tried to use setsizer (see https://www.backtrader.com/docu/sizers/sizers/) before each position ?
RE: How to know whether 2 lines are crossing?
@crypto_trader Crossing mean one line was above the other on previous period, and is under on current period.
This logic could be written like that :
if (self.l.indicator1>self.l.indicator2) and (self.l.indicator1<self.l.indicator2):
You may want to read below links, for a more efficient implementation :
and have a look at crossover.py indicator.
RE: Hi I'm new just wondering if backtrader supports TD??
RE: live trading : ibbroker.py error when order from another clientid occur
So, in case it is of some interest for people who like me were ignorant about this and are willing to know more : BT cannot filter by ClientID when receiving commissionReport, as IB do not send a ClientID in the commissionReport message.
Feel free to correct me if I am wrong :
- IB do send the ClientID and the OrderId with the openorder callback but not the ExecId (Which is normal as the order may not have been executed)
- IB send the ExecId, the ClientID and the OrderId with the execDetails messages.
- IB do not send the ClientID or OrderId with the commissionReport messages, the only thing that can be linked to an order that is then sent is the ExecId
So a running strategy will receive commissionReport messages for all order executed on TWS : its own orders, orders placed manually and from another clientId, but not the openorder and execDetails messages.
There are 2 exception for this :
- ClientID 0 will receive openorders, execDetails and commissionReports for itself and for orders placed manually
- If a ClientID is set as "Master API client ID" (in Global configuration / API / Settings) it will receive openorder, execDetails and commissionReport for all clients.
RE: Why won't order.Accept? Is it because I need volume?
Do you have the same issue if you add a dummy volume column (let's say 100 each line) to your own data source ?
live trading : ibbroker.py error when order from another clientid occur
I tested on an IB paper account the following :
- running a strategy with clientid, let's say 8888.
- Execute manually an order.
The result was an error :
08-Oct-20 17:47:24 ERROR Exception in message dispatch. Handler 'commissionReport' for 'commissionReport' Traceback (most recent call last): File "x/backtrader-J2SaRgr0/lib/python3.7/site-packages/ib/opt/dispatcher.py", line 44, in __call__ results.append(listener(message)) File "x/backtrader/backtrader/backtrader/stores/ibstore.py", line 1323, in commissionReport self.broker.push_commissionreport(msg.commissionReport) File x/labs/backtrader/backtrader/backtrader/brokers/ibbroker.py", line 482, in push_commissionreport ex = self.executions.pop(cr.m_execId) KeyError: '0000e215.5f7e7752.01.01
Tested also the following :
- running a strategy with clientid : 8888.
- running another strategy with a different client id : 9999
I encounter the same error.
As far as I investigated, my understanding is that IB notify the order, that BT receive the notification and do not find it its own list of orders, hence the error. There is no filtering by clientid.
Is it correct or did I missed something ? Any help would be much appreciated.