QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.56k stars 3.23k forks source link

Live IBKR OptionChainProvider & AddFutureOption not including daily expirations #7338

Open vguruv opened 1 year ago

vguruv commented 1 year ago

Expected Behavior

In live trading with IBKR data that includes daily expiring Futures options. OptionChainProvider & AddFutureOption should return all expirations, including daily expiries. I understand that backtest data does not include daily expirations, but live IBKR live data does include daily expirations and is 24 hours for futures.

Actual Behavior

OptionChainProvider & AddFutureOption return only options matching Future expiry date and not daily expiries.

Potential Solution

Lean code may be filtering options based on Future expiry, with no way to override this filter.

Reproducing the Problem

Run this as back test and also with IBKR live data: https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_3b5cfe799d9bab4f680cf2268b134831.html

Checklist

jhonabreul commented 1 year ago

Lean currently does not support weekly and daily future options contracts.

In order to have this feature in a live IB deployment, the LiveOptionChainProvider would need to take into account all categories returned by CME (future options are source from CME even in an IB live deploment), which include the weekly/daily contracts.

Also, FuturesOptionsExpiryFunctions.GetFutureOptionExpiryFromFutureExpiry would have to be modifed to calculate the proper option expiration date (for instance, for a weekly monday expiration option, given the year, month and week number).

Backtesting would need to have this feature implemented as well.

vguruv commented 1 year ago

Since Equities already support weekly and daily options contracts, I assume implementing the same in Futures was just missed. Can this be implemented using this issue report, instead of going into the Features backlog?

jaredbroad commented 1 year ago

Sorry, @vguruv we don't have this data. Procuring it is possible but at the moment it's a relatively niche asset class. If more commercial clients come on board seeking this asset we can expand support.

vguruv commented 1 year ago

Sorry, @vguruv we don't have this data. Procuring it is possible but at the moment it's a relatively niche asset class. If more commercial clients come on board seeking this asset we can expand support.

Thanks for the attention @jaredbroad. This is only about live trading where IBKR does provide the data, but Lean is ignoring or unable to use it, due to discrepancy in Options vs FuturesOptions implementations. This is not about back testing (sorry if the issue description was not clear about that).

vguruv commented 1 year ago

@jhonabreul @jaredbroad @Martin-Molinero Following up to ensure that it is clear that this is a live-only trading problem due to mismatch between options and futures options implementation and not a backtest data issue. @jhonabreul has already identified the location and nature of the change needed to resolve this live-only trading issue.