Problem with backtrader live Gold (XAUUSD) data from IB (Interactive Brokers)
Backtrader works fine with live data of IB (Interactive Brokers) through TWS, but when I want to trade on gold commodity (XAUUSD), it cannot receive the data. the python code is:
data = store.getdata(dataname='XAUUSD', sectype='CMDTY', exchange='SMART', timeframe=bt.TimeFrame.Minutes)
I inserted the details as:
run-out last edited by
First thing to check is if you have a paid subscription to the data. Go into TWS and try to get quotes.
Thanks, but I have a paid subscription,
Do you have any other solution?
@seton It may help to know which error message you have.
Normally (and for other data),first I have "Data Status => DELAYED" and then "Data Status => LIVE" in the terminal output.
But for XAUUSD, I just see the "Data Status => DELAYED" and nothing else.
I noticed that if I change , in ibstore.py, def reqMktData
line 855 from :
if contract.m_secType in ['CASH', 'CFD']:
if contract.m_secType in ['CASH', 'CFD', 'CMDTY']:
I receive XAUUSD CMDTY. Of course, this change would also need to be done in other parts of the code for a real fix.
@run-out do you know if CMDTY used to be available with live trading with IB, in backtrader ?
@rodket I noticed that the issue also appear for historical data, so I guess it have to be done in other parts of ibstore.
But before this fix could be used, it have to be though & tested as there always can be side effects to code modification.