Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Should Live Option Chain Provider Return Expired Contracts?

Open AlexCatarino opened this issue 3 years ago • 0 comments

Expected Behavior

LiveOptionChainProvider should not return expired contracts.

Actual Behavior

LiveOptionChainProvider may return expired contracts leading to the following runtime error when we try to subscribe it to IB:

Runtime Error: No security definition has been found for the request. Origin: [Id=23] Subscribe: SOFI 220225C00020000 (OPT SOFI USD Smart 20220225 20 C) Stack Trace: No security definition has been found for the request. Origin: [Id=23] Subscribe: SOFI 220225C00020000 (OPT SOFI USD Smart 20220225 20 C)

Potential Solution

a - Does LOCP need to return expired contracts? Does someone need/use it? If no reason can try filter internally directly b - Add an optional argument to filter out expired contract c - Or maybe add helper method to filter expired options

Reproducing the Problem

Call

contracts = self.OptionChainProvider.GetOptionContractList(Underlying, self.Time)

in a method right after the market opens. Do not add any logic to filter out expired contracts (assume they are not there), so you can call AddOptionContract for an expired contract.

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

AlexCatarino avatar Mar 01 '22 15:03 AlexCatarino