Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Runtime Error when adding option contract without explicitly adding equity to portfolio

Open ashutoshrana171 opened this issue 1 year ago • 0 comments

Expected Behavior

We should not get the error and the prices should convert to Raw mode automatically since the equity is not in the portfolio.

Actual Behavior

When we use AddOptionContract() method without explicitly adding equity to the portfolio it throws a runtime error.

"The underlying Equity asset (PARA) is set to Adjusted, please change this to DataNormalizationMode.Raw with the SetDataNormalization() method at QuantConnect.Algorithm.QCAlgorithm.AddOptionContract(Symbol symbol, Nullable`1 resolution, Boolean fillForward, Decimal leverage, Boolean extendedMarketHours) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Algorithm/QCAlgorithm.cs:line 2354"

Potential Solution

Reproducing the Problem

Used these steps to reproduce the error:

  1. Symbol.Create to avoid getting underlying data
  2. got option symbols from OptionChainProvider and also created option symbols using Symbol.CreateOption
  3. Added option contracts using AddOptionContract

Attached backtest for reference: https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_d454480026bc4855024d87c2b5364479.html

System Information

Tested on QC cloud.

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

ashutoshrana171 avatar Feb 10 '24 00:02 ashutoshrana171