Skip to content

Warn once for coarse option underlying resolution - #9759

Open
pengpengyi92 wants to merge 2 commits into
QuantConnect:masterfrom
pengpengyi92:bug-9732-option-underlying-resolution
Open

Warn once for coarse option underlying resolution#9759
pengpengyi92 wants to merge 2 commits into
QuantConnect:masterfrom
pengpengyi92:bug-9732-option-underlying-resolution

Conversation

@pengpengyi92

Copy link
Copy Markdown

Description

Replaces the fatal validation from #9751 with a one-time warning, as requested in the maintainer review.

When an option contract uses a finer resolution than the finest existing underlying subscription, AddOptionContract now:

  • emits a Debug warning once per algorithm;
  • continues adding the option contract;
  • recommends adding the underlying at the option resolution or finer so implied volatility and Greeks use a current price.

The validation still uses the finest available underlying subscription and UniverseSettings.Resolution when the option resolution is omitted.

Related Issue

Closes #9732.
Supersedes #9751 after GitHub rejected reopening the closed pull request.

Motivation and Context

LEAN computes option implied volatility and Greeks from the underlying's latest price. A finer option subscription can therefore use a stale underlying price. A warning surfaces that risk without blocking users for whom a coarser underlying resolution is the best available data.

Requires Documentation Change

No. The warning explains the resolution relationship and recommended action.

How Has This Been Tested?

  • Built Tests/QuantConnect.Tests.csproj in Release mode with .NET 10: 0 errors.
  • Ran all tests matching AlgorithmAddDataTests.AddOptionContract: 9 passed, 0 failed.
  • Ran the complete AlgorithmAddDataTests fixture: 54 passed; the only two failures were existing Python/Pandas tests because the minimal container does not include pandas, and neither test exercises this change.
  • Ran git diff --check successfully.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature
  • Breaking change
  • Non-functional change

Checklist

  • My code follows the code style of this project.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • All new and existing tests passed. (All relevant and non-Pandas fixture tests pass; two unrelated Python/Pandas tests require the upstream environment.)
  • My branch follows the project naming convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when an option is subscribed at a finer resolution than its underlying

1 participant