Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix options indicators data synchronization #8564

Merged

Conversation

jhonabreul
Copy link
Collaborator

@jhonabreul jhonabreul commented Jan 29, 2025

Description

Introduce MultiSymbolIndicator class for indicators that work on multiple symbols.

This class allows to detect when the indicator is ready to calculate, that is, when data for all symbols at the same time is available. For instance, if an indicator works with daily data for an option and it's underlying, and they have different market closes, daily data would come at different times of the day for the same date. When this happens, the indicator is able to detect that both symbols have data for the same date and is ready to calculate.

Options indicators, including implied volatility and greeks now are based on this class to handle cases like this.

Note: AutomaticIndicatorWarmupOptionIndicatorsMirrorContractsRegressionAlgorithm history count decreased because options indicators period is now 1 instead of 2.

protected OptionIndicatorBase(string name, Symbol option, IRiskFreeInterestRateModel riskFreeRateModel, IDividendYieldModel dividendYieldModel,
Symbol mirrorOption = null, OptionPricingModelType? optionModel = null, int period = 1)

Related Issue

Motivation and Context

An example is RUT index, where market closes at 4pm for indices and at 4:15pm for its options.

Requires Documentation Change

How Has This Been Tested?

Unit tests.
Manual runs.

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>

…bols

Use the new class as base for DualSymbolIndicator and OptionIndicatorBase.
The OptionIndicatorBase can now detect when ready even if underlying and options market close is different when resolution is daily.
AutomaticIndicatorWarmupOptionIndicatorsMirrorContractsRegressionAlgorithm history count decreased because options indicators period is now 1 instead of 2
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

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

Thank you, nice work 👍, minor improvement request shared

@jhonabreul jhonabreul merged commit de9f9bf into QuantConnect:master Jan 31, 2025
7 checks passed
@jhonabreul jhonabreul deleted the bug-options-indicators-timestamp branch January 31, 2025 18:22
@NoSealsInSealBeach
Copy link

Any good reason as to why the ComputeIndicator method in OptionGreekIndicatorBase got sealed with the above change ? The ComputeIndicator method seems to have replaced the logic of the Calculate method which I was overriding in my custom classes to have my own time to expiration calculation. Now there is no straightforward way to override the time to expiration calculation in the custom greek classes derived from the Greek Indicators anymore...unless one implements their own OptionGreekIndicatorBase class but that's messy as then you will have to implement the full indicator classes for each greek as they will be deriving from that custom class...and at that point you might as well skip using QuantConnect Indicators and write your own indicators. Is it possible for you to unseal this method ? This has broken all my custom Greeks and IV classes. Thanks!!

@NoSealsInSealBeach
Copy link

NoSealsInSealBeach commented Feb 1, 2025

Also, I noticed that the ComputeIndicator in the ImpliedVolatility is unsealed so I can derive a custom class from ImpliedVolatility and use my own time to expiration calcs in the ImpliedVolatility indicator. But I am not allowed to do it for greeks ? That seems inconsistent...

@jhonabreul
Copy link
Collaborator Author

Hi @NoSealsInSealBeach
You are right, fixing this in #8570
Thank you

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.

3 participants