Fall back from open interest mapping for KRX futures and warn on unavailable mapping modes - #9831
Open
jhonabreul wants to merge 7 commits into
Open
jhonabreul wants to merge 7 commits into
jhonabreul wants to merge 7 commits into
Conversation
…ailable mapping modes
…re-add instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Continuous futures on KRX (e.g.
KM) get no history and no data with default settings. PassingOpenInterestexplicitly on EUREX, HKFE, ICE or KRX, or adding the same future twice with different settings, also fails with no feedback.Cause: these markets have no open interest mapping data, and the
LastTradingDayfallback only covered EUREX, HKFE and ICE when no mode was passed. The KRX market was added in #9585 but never added to that fallback.The fix:
Extensions.GetUniverseMappingModeOrDefaultnow also falls back fromOpenInterest/OpenInterestAnnualtoLastTradingDayfor KRX.DataMappingMode.IsAvailableForFutureMarket(market)extension.AddFutureandHistory()fall back to the market default for an unsupported mapping mode, whether it is the default or passed explicitly.AddFutureandHistory().AddFuturewith a different mapping mode, normalization mode or contract depth offset keeps the first settings and warns once.Symbol, so both calls resolve to the same/ES.FESXwithOpenInterestdoes not warn.Initialize, the warning says to add the future once. AfterInitialize, it says to remove it withRemoveSecurity()and add it again.Examples:
KRX future with default settings now falls back:
Explicit unsupported mapping mode in
AddFuturenow falls back:Explicit unsupported mapping mode in
History()now falls back:Re-adding a future with different settings in
Initialize:Re-adding a future with different settings after
Initialize(e.g. inOnData):Related Issue
Closes #9764
Motivation and Context
The KOSPI 200 futures added in #9585 get no data with default settings. The other cases return empty data with no hint why.
Requires Documentation Change
No.
How Has This Been Tested?
ExtensionsTests.GetUniverseMappingModeOrDefault:OpenInterestfalls back on KRX/EUREX/HKFE/ICE and not on CME.AlgorithmAddSecurityTests.AddFutureFallsBackFromUnavailableDataMappingMode: default and explicitOpenInterestfall back on KRX/EUREX with the exact warning; supported modes are kept.AlgorithmAddSecurityTests.AddFutureDataMappingModeFallbackWarnsOncePerMarket: one fallback warning per market.AlgorithmAddSecurityTests.AddFutureFallsBackToUniverseSettingsDataMappingMode: fallback uses a supportedUniverseSettings.DataMappingMode.AlgorithmHistoryTests.HistoryWithExplicitUnavailableDataMappingModeFallsBackToMarketDefault: explicitOpenInterestrequests useLastTradingDay, even if the future was added with another mode, and warn once.AlgorithmHistoryTests.HistoryWithoutDataMappingModeFallsBackForFutureNotAdded: default history of a future not added falls back and warns once.AlgorithmHistoryTests.HistoryWithExplicitAvailableDataMappingModeKeepsIt: a supported explicit mode is kept with no warning.AlgorithmHistoryTests.HistoryWithExplicitUnavailableDataMappingModeDoesNotFallBackForContractsOrChains: contract and chain requests keepOpenInterestand don't warn.AlgorithmAddSecurityTests.AddFutureAgain*: conflicting re-adds keep the first settings and warn once with the right text; matching re-adds don't warn.AlgorithmAddSecurityTests.AddFutureAfterRemovingItAppliesNewSettings: removing and re-adding applies the new mapping mode.FutureDataMappingModeFallbackRegressionAlgorithm(C#/Python, FESX data): explicitOpenInterestmaps to the June contract via the fallback, explicitOpenInteresthistory matches default history, and the after-Initializere-add warning is sent. Fails on master.OpenInterestand 1300 rows withLastTradingDay.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>