Skip to content

Add Python version of IndicatorVolatilityModelAlgorithm#9580

Merged
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
jonathanwu906:feature-6375-indicator-volatility-model-python-example
Jul 2, 2026
Merged

Add Python version of IndicatorVolatilityModelAlgorithm#9580
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
jonathanwu906:feature-6375-indicator-volatility-model-python-example

Conversation

@jonathanwu906

Copy link
Copy Markdown
Contributor

Description

Adds Algorithm.Python/IndicatorVolatilityModelAlgorithm.py, a Python port of the existing C# regression algorithm demonstrating IndicatorVolatilityModel usage — including how to reset and warm the indicator back up on splits and dividends so volatility doesn't jump on price discontinuities. Also updates the C# definition's Languages to { CSharp, Python } so the regression suite runs both variants against the same expected statistics.

Related Issue

Closes #6375

Motivation and Context

#6375 asks for an example of IndicatorVolatilityModel. The C# example algorithm and unit tests were added in #7058; this completes the issue with the Python counterpart, matching the convention that example/regression algorithms ship in both languages.

Requires Documentation Change

No — this adds the example the documentation can reference.

How Has This Been Tested?

Ran the regression tests inside the quantconnect/lean:foundation container (same image as the Regression Tests CI workflow):

dotnet test Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName~IndicatorVolatilityModelAlgorithm"

Result: 2/2 passed (CSharp/IndicatorVolatilityModelAlgorithm, Python/IndicatorVolatilityModelAlgorithm); the Python variant produces statistics identical to the C# ExpectedStatistics.

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 (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

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.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

🤖 Generated with Claude Code

https://claude.ai/code/session_01R7LGdW3eC9za8WMrtssHGr

Port the C# regression algorithm demonstrating IndicatorVolatilityModel
usage, including how to reset and warm up the indicator on splits and
dividends to avoid volatility jumps from price discontinuities, and
enable the Python variant in the regression test suite.

Closes QuantConnect#6375

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R7LGdW3eC9za8WMrtssHGr
@jonathanwu906 jonathanwu906 force-pushed the feature-6375-indicator-volatility-model-python-example branch from c6120c9 to b90fb92 Compare July 2, 2026 17:03
@jonathanwu906

Copy link
Copy Markdown
Contributor Author

@Martin-Molinero Hi, thanks for approving the CI runner earlier.

I've fixed the mypy call-overload error in IndicatorVolatilityModelAlgorithm.py that was causing the Syntax Tests failure — the algorithm now keeps a reference to the IndicatorVolatilityModel instance instead of reading it back from Security.volatility_model, mirroring the cast in the C# version. Runtime behavior is unchanged.

When you have a moment, could you please approve the workflows again so CI can re-run? Thank you!

@Martin-Molinero Martin-Molinero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonathanwu906!

@Martin-Molinero Martin-Molinero merged commit 77caa03 into QuantConnect:master Jul 2, 2026
7 of 8 checks passed
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.

Add Example Algorithm with IndicatorVolatilityModel

2 participants