cannot find right symbol for Interactive Brokers
-
Hello,
I have been trying my code on the symbol
EUR.USD-CASH-IDEALPRO
successfully so far. The problem raises when I want to use another symbol with IBStore.Following is my code:
cerebro = bt.Cerebro(stdstats=False) ibstore = bt.stores.IBStore(host='127.0.0.1', port=7496, clientId=35) # data = ibstore.getdata(dataname='EUR.USD-CASH-IDEALPRO', fromdate=datetime.datetime( data = ibstore.getdata(dataname='ES.USD-FUT-GLOBEX-201806', fromdate=datetime.datetime( 2018, 4, 1), todate=datetime.datetime(2018, 5, 1), timeframe=bt.TimeFrame.Days, reverse=False) cerebro.broker.setcash(10000.0) cerebro.broker.setcommission(commission=0.0) cerebro.adddata(data) cerebro.addstrategy(TestStrategy) print('Starting portfolio: %f' % cerebro.broker.getvalue()) strats = cerebro.run() ss = strats[0] for each in ss.analyzers: each.print() cerebro.plot(volume=False, style='candle') print('Final portfolio: %f' % cerebro.broker.getvalue())
And I get the error:
Starting portfolio: 10000.000000 Server Version: 76 TWS Time at connection:20180514 15:17:36 Eastern European Time --------------------------------------------------------------------------- IndexError Traceback (most recent call last) ~/Documents/Devel/trade/bt_basic.py in <module>() 156 157 print('Starting portfolio: %f' % cerebro.broker.getvalue()) --> 158 strats = cerebro.run() 159 160 ss = strats[0] ~/.virtualenvs/trade-7uGUPCDQ/lib/python3.6/site-packages/backtrader/cerebro.py in run(self, **kwargs) 1125 # let's skip process "spawning" 1126 for iterstrat in iterstrats: -> 1127 runstrat = self.runstrategies(iterstrat) 1128 self.runstrats.append(runstrat) 1129 if self._dooptimize: ~/.virtualenvs/trade-7uGUPCDQ/lib/python3.6/site-packages/backtrader/cerebro.py in runstrategies(self, iterstrat, predata) 1299 1300 for strat in runstrats: -> 1301 strat._stop() 1302 1303 self._broker.stop() ~/.virtualenvs/trade-7uGUPCDQ/lib/python3.6/site-packages/backtrader/strategy.py in _stop(self) 459 460 def _stop(self): --> 461 self.stop() 462 463 for analyzer in itertools.chain(self.analyzers, self._slave_analyzers): ~/Documents/Devel/trade/bt_basic.py in stop(self) 84 85 def stop(self): ---> 86 self.log('(MA Period %2d) Ending Value %.2f' % (self.params.maperiod, self.broker.getvalue()), doprint=True) 87 88 def notify_order(self, order): ~/Documents/Devel/trade/bt_basic.py in log(self, txt, dt, doprint) 21 def log(self, txt, dt=None, doprint=False): 22 if self.params.printlog or doprint: ---> 23 dt = dt or self.datas[0].datetime.date(0) 24 print('%s, %s' % (dt.isoformat(), txt)) 25 ~/.virtualenvs/trade-7uGUPCDQ/lib/python3.6/site-packages/backtrader/linebuffer.py in date(self, ago, tz, naive) 389 390 def date(self, ago=0, tz=None, naive=True): --> 391 return num2date(self.array[self.idx + ago], 392 tz=tz or self._tz, naive=naive).date() 393 IndexError: array index out of range
How can I resolve this issue?
-
@eduedix said in cannot find right symbol for Interactive Brokers:
EUR.USD-CASH-IDEALPRO
This is for FOREX where the pair is
EUR.USD
@eduedix said in cannot find right symbol for Interactive Brokers:
ES.USD-FUT-GLOBEX-201806
A future is not a forex pair and the currency is specified later, right after the exchange and before the expiration date.. See the reference here: Docs - Interactive Brokers
-
Thank you very much for the quick response!
I fixed the symbol name now and the dataname looks like this:
ES-FUT-GLOBEX-USD-201806
. I do not receive any error anymore. However, the system stays in theDELAYED
status forever. Do you have any idea what might be the problem here? -
That's usually due to lack of permissions to download real-time data.
-
I am doing paper trading only. The delay occurs for EURUSD for only 1-2 seconds though. I also have this problem when I want to work on historical data only (limited with
fromdate
andtodate
as parameters togetdata
. Do you think this is a permission related issue?