IBKR Cloud Paper Trading Error

Hi Brian,

I got to the point in trying to paper trade a strategy on the cloud but I'm still getting an annoying error that seems to be in regards to a delisted stock.

  • 2021-11-17 19:02:37 quantrocket.zipline: ERROR raise HTTPError(http_error_msg, response=self) 2021-11-17 19:02:37 quantrocket.zipline: ERROR requests.exceptions.HTTPError: ('400 Client Error: BAD REQUEST for url: http://houston/blotter/orders', {'status': 'error', 'msg': 'No IBKR ConId found for Sid FIBBG00YMWPKZ0, is the Sid valid and did you collect the security listing from IBKR?'}) 2021-11-17 19:02:37 quantrocket.zipline: ERROR

Any idea what this is and how to fix it?

Thank you,
Bruno

The answer is right there in the error message. :slight_smile: Collect the listing from IBKR.

I thought I had. This is what I'd done:

from quantrocket.master import collect_ibkr_listings
collect_ibkr_listings(exchanges=['NYSE', 'CBOE', 'AMEX', 'ARCA', 'NASDAQ'], sec_types=['STK', 'IND', 'ETF'])

When you dig deeper you can see that this stock in the thread has two Sids, the one from the error is still NAN even after IBKR listing collection and the secondary for some reason has .0 at the end after IBKR ID integer code

Thoughts?

Thank you

This was a SPAC that combined with the target company. The IBKR record got a new sid but the usstock record did not, which can happen for reasons explained in the docs. For live trading, I would suggest adding a Pipeline filter that uses the SecuritiesMaster dataset to make sure the ibkr_ConId field is not null.

Hi @Brian,

I added this to the pipeline:

error_prevention = master.SecuritiesMaster.ibkr_ConId.latest.notnull() & master.SecuritiesMaster.ibkr_PrimaryExchange.latest.notnull() & master.SecuritiesMaster.Exchange.latest.notnull()

but I'm still getting an error:

quantrocket_flightlog_1|2021-11-22 18:14:15 quantrocket.zipline: ERROR requests.exceptions.HTTPError: ('400 Client Error: BAD REQUEST for url: http://houston/blotter/orders', {'status': 'error', 'msg': 'missing required fields Exchange for order: {"TotalQuantity": 58, "Sid": "FIBBG00R0TMXH1", "OrderRef": "strategy", "Account": "acct#", "Tif": "DAY", "Action": "SELL", "OrderType": "MKT"}'})

This question is outside of the scope of the forum because it can be solved by reading the error message and reading the Zipline live trading docs. Keep in mind that there are always going to be many issues and error messages to work through in order to deploy a live trading strategy. The vast majority of these error messages don't mean there is a bug in the software but simply mean that algorithmic trading is complex. The forum is mainly about addressing the occasional bug.

Hi Brian,

I've read the error messages and the docs multiple times and I can't figure out what the problem is.

Is there a way to just exclude a SID or Symbol from the Sharadar Fundamental Data Zipline Bundle?

It would be great to get help with an actual solution from you.

I appreciate your help.

As the error message indicates, you have to specify an Exchange when sending orders to IBKR. The docs show how.

These are my buy and sell orders, I thought I had the exchange specified.

    # Buy with market order
    algo.order_target_percent(
        asset,
        target = ORDER_WEIGHT ,
        style=MarketOrder(exchange="SMART", order_params={"AlgoStrategy": "Adaptive"})#style=MarketOrder() # for IBKR, specify exchange (e.g. exchange="SMART")
    )
    
 
for asset in context.assets_to_short:
    # Sell with market order
    algo.order_target_percent(
        asset,
        target = -ORDER_WEIGHT ,
        style=MarketOrder(exchange="SMART", order_params={"AlgoStrategy": "Adaptive"})# for IBKR, specify exchange (e.g. exchange="SMART")
    )