QuantConnect / Lean.Brokerages.InteractiveBrokers

InteractiveBrokers Brokerage Plugin
Apache License 2.0
27 stars 17 forks source link

History Request of Expired Contracts #88

Closed AlexCatarino closed 8 months ago

AlexCatarino commented 8 months ago

Expected Behavior

If IB no longer supports a contract because it has expired, LEAN doesn't throw an error, and returns an empty list of historical data.

Actual Behavior

The algorithm exists with No security definition has been found for the request error.

Potential Solution

When the error 200 occurs for history requests, we check out if the symbol has expired, and return an empty list.

Reproducing the Problem

Warm-up VX futures' algorithm.

var symbol = QuantConnect.Symbol.CreateFuture("VX", Market.CFE, new(2023, 10, 18), "VX18V23");
symbol = AddFutureContract(symbol).Symbol;   // <- optional 
var history = History(symbol, TimeSpan.FromDays(5), Resolution.Minute);

Checklist