Open VitalyErmilov opened 6 years ago
So, the аsset's field 'symbol' contаins now quаndl's database code which uses delimiter '_' for compounded tickers, while we should hаve а blаnk space instead. Here is the link to ib knowledge bаse section concerning the issue : https://ibkr.info/node/462
Thanks for reporting this issue.
Generic way of solving this issue would be to replace underscore to space (in case of IB), here:
https://github.com/zipline-live/zipline/blob/master/zipline/gens/brokers/ib_broker.py#L640
Care should be taken to handle all the cases where contract.m_symbol
is used, otherwise order & position status would be negative affected.
A less generic way would be to build up a zp-symbol to ib-symbol mapping table. This approach would only be preferred, if the generic underscore-to-space approach would not work out. Example of zp-symbol to ib-symbol mapping could be taken from symbol_to_exchange mapping: https://github.com/zipline-live/zipline/blob/master/zipline/gens/brokers/ib_broker.py#L58-L64
@VitalyErmilov : Is this enough guidance to start working on the fix?
@tibkiss I've made a workaround by replacing underscores to spaces on the stage of data ingestion by modifying quandl.py. This tells that replacement method does work .
The first thing I tried was to make it in ib_broker.py because it's a broker specific code. But It seems to me that I didn't handle all the cases, so I couldn't get the preferable approach working.
I will make another try to do this. Thank you for the guidance.
Dear Zipline Maintainers, I've found that the function data.current() doesn't work now for so called fuzzy symbols (symbols that consist of two parts), such as BRK B (Berkshire Hathaway B).
I think the problem is that the way fuzzy symbols are presented now in securities database is incompatible with interactive brokers' smart search. So when we try to get market data for a fuzzy symbol, smart search can't find the security for the symbol which results in the following error:
'No security definition is found for this request, error code 200'
I tried to find BRK B stock in Tws manually and the result was that Tws couldn't find the security when querying 'BRK.B' or 'BRK_B''. But It managed to find it when I typed in the search box 'BRK B' (with a space)
We need to reflect this in how zipline-live handles compounded tickers to query interactive brokers in a way it can understand them.
To reproduce the issue try to retrieve some data_current() information for the stock BRK_B
Sincerely, Vitaly Ermilov