Conversation
Author
|
The CI workflows are currently waiting for first-time-contributor approval ( |
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
Stop applying Binance/Bybit/dYdX crypto-future funding from a cached
MarginInterestRateonce the security is no longer receiving current market data.MarginInterestRateis auxiliary data and can intentionally be reused across multiple funding applications at coarser resolutions (for example, the existing daily regression). The fix therefore checks the security's last market data viaSecurity.GetLastData()instead of comparing each cached funding point against every 00:00/08:00/16:00 window. When the market data is stale, the model skips the current funding application and realigns_nextFundingRateApplicationso a later data point is not retrospectively charged for missed intervals.Related Issue
Fixes #9801
Motivation and Context
For a delisted or settled Binance contract, the data feed stops but
Security.Cachekeeps returning the lastMarginInterestRate. The model previously reused that final rate indefinitely. In the reported A2ZUSDT backtest this turned a small Binance-implied funding cost into a large, repeated charge after the contract's data ended.The guard is deliberately based on market-data freshness rather than a per-interval timestamp comparison on the auxiliary rate. A per-interval comparison was tested first and failed the existing daily funding regression because it reduced the expected three applications to two. Existing hourly and daily funding behavior remains unchanged.
Requires Documentation Change
No.
How Has This Been Tested?
Tests/Common/Securities/CryptoFuture/:dotnet test Tests/QuantConnect.Tests.csproj --filter "FullyQualifiedName~BinanceFutureMarginInterestRateModelTests": 3/3 passed.dotnet test Tests/QuantConnect.Tests.csproj --filter "FullyQualifiedName~QuantConnect.Tests.Common.Securities.CryptoFuture": 24/24 passed.CryptoFutureDailyMarginInterestRegressionAlgorithmandCryptoFutureHourlyMarginInterestRegressionAlgorithmboth completed with their expected statistics (daily end equity1000206.40; hourly end equity1000207.90).Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>