Error initiating IB realtime ticks using Zipline example

Hi there,

I’ve been trying to get live trading working for a zipline algo that has been successfully run in the backtest environment. I receive an error when trying to initiate tick collection from Interactive Brokers, using the code suggested in the Usage guide. I recreated the problem in a Jupyter notebook, using the zipline kernel and run_pipeline to generate the assets. My code:

output = run_pipeline(pipe, start_date="2020-07-01", end_date="2020-07-07", bundle='usstock-minute')
assets = output.index.get_level_values(1)

sids = [assets[i].real_sid for i in range(0, 6)]



['FIBBG000C2V3D6', 'FIBBG00B3T3HD3', 'FIBBG00LPXX872', 'FIBBG000V2S3P6', 'FIBBG000BDYRW6', 'FIBBG005P7Q881']

And the error I get:

2020-07-28 00:16:20 quantrocket.realtime: INFO Collecting market data for 6 securities in all-stk-etf-tick
2020-07-28 00:16:22 quantrocket.realtime: WARNING ibg1 client 10395 got IBKR error code 320: Error reading request:Message id 0.  Unable to parse data. java.lang.NumberFormatException: For input string: "1715006.0"
2020-07-28 00:16:22 quantrocket.realtime: ERROR Traceback (most recent call last):
2020-07-28 00:16:22 quantrocket.realtime: ERROR   File "sym://qrocket_realtime_collect_ibkr_workers_py", line 16, in wrapped
2020-07-28 00:16:22 quantrocket.realtime: ERROR   File "sym://qrocket_realtime_collect_ibkr_market_data_py", line 79, in run
2020-07-28 00:16:22 quantrocket.realtime: ERROR   File "sym://qrocket_realtime_collect_ibkr_market_data_py", line 119, in subscribe
2020-07-28 00:16:22 quantrocket.realtime: ERROR   File "sym://qrocket_realtime_collect_ibkr_models_py", line 130, in get_request
2020-07-28 00:16:22 quantrocket.realtime: ERROR   File "sym://qrocket_realtime_collect_ibkr_models_py", line 68, in _get_contract
2020-07-28 00:16:22 quantrocket.realtime: ERROR AttributeError: 'float' object has no attribute 'split'
2020-07-28 00:16:22 quantrocket.realtime: ERROR 
2020-07-28 00:16:22 quantrocket.realtime: INFO Exiting IBKR market data collection due to errors

And here is the how the tick db was created:

                        fields=['LastPrice', 'Volume', 
                                'BidPrice', 'AskPrice', 'BidSize', 'AskSize'])

I’ve successfully initiated tick collection from jupyter notebooks, so it doesn’t seem to be a problem with the connection. Any ideas?

The reason for the error is that you need to collect the securities listings from Interactive Brokers before you can collect real-time data from IBKR. For all US stocks, you probably want something like this:

quantrocket master collect-ibkr --exchanges 'NASDAQ' 'NYSE' 'AMEX' 'BATS' 'ARCA' --sec-types 'STK' 'ETF'

That was not documented as clearly as it should be; we’ve added a clarifying note to the real-time docs. And we will replace the unhandled exception with a more helpful error message in the next release.

This solution worked, thanks! I had previously collected the securities listings for NASDAQ, NYSE, and AMEX but not BATS and ARCA. I recollected all five exchanges, and it started working. It might be helpful in the guide to specify which collection of exchanges provide comprehensive coverage of the assets in the usstock database.

Version 2.2.0 is now available and includes better error handling for this situation. There is also a new Zipline example strategy that shows the IBKR exchanges to collect for live trading.