fix: support BNFCR alternative collateral in CryptoFutureMarginModel for Binance#9373
Merged
Romazes merged 12 commits intoQuantConnect:masterfrom Apr 13, 2026
Conversation
11 tasks
Replace IsStableCoinWithoutPair foreach loop with a single TryGetValue check for BNFCR. BNFCR is EU/EEA-only (MiCA Credits Trading Mode) so the lookup is a no-op for all other users. Amount reflects availableBalance from the Binance API — the total cross-margin pool already aggregated by Binance — making the > 0 guard correct and avoiding CashBook iteration.
…e USDⓈ-M futures Asserts end-to-end that EU/MiCA accounts with zero USDT and BNFCR as the only collateral can open ADAUSDT positions. Verifies buying power, holdings AbsoluteHoldingsCost, TotalSaleVolume, TotalMarginUsed, maintenance margin consistency and TotalUnrealizedProfit accuracy.
…ry collateral Replace IsStableCoinWithoutPair and hardcoded asset list with CashBook iteration gated by BNFCR presence. Binance controls which assets are in the account — all with non-zero walletBalance are valid collateral. Add tests for BNFCR zero balance and BTC collateral conversion.
…BNFCR mode - Extract virtual SharesCollateral in CryptoFutureMarginModel - Override in BinanceCryptoFutureMarginModel: BNFCR present → all USDⓈ-M share pool - Add BNFCRCurrency const - Add SharedCollateralDeductsMaintenanceMarginAcrossQuoteCurrencies unit test - Refactor regression algorithm to assert shared collateral across ADAUSDT/ETHUSDC
…reMarginModel - Remove IsCryptoCoinFuture() check (coin futures use BinanceCoinFuturesBrokerageModel, not this model) - Call base.GetTotalCollateralAmount() instead of duplicating primaryCollateral.Amount - Remove CoinFutureDoesNotIncludeBnfcrAsCollateral test (tested wrong margin model)
- No longer accessed by subclasses after removing direct collateral checks from BinanceCryptoFutureMarginModel
Martin-Molinero
approved these changes
Apr 13, 2026
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
Add
BinanceCryptoFutureMarginModelthat aggregates all supplementary collateral assets for USDⓈ-M futures when BNFCR is present (EU/EEA MiCA Credits Trading Mode). BNFCR presence in CashBook gates the collateral loop - non-EU accounts skip entirely. All non-zerowalletBalanceassets are summed as collateral (Binance specifiesmarginAvailable: truefor each eligible asset in the API response).Related PR(s)
Related Issue
Fixes #9339
Motivation and Context
EU/EEA Binance Futures users under MiCA Credits Trading Mode use BNFCR as the cross-margin
accounting currency.
GetMarginRemaining()only checked the quote currency (e.g. USDT),returning zero buying power for EU users. Binance aggregates all collateral into BNFCR
(from the MiCA FAQ:
1,000 USDC + 0.3 BTC×$60k + 12 BNB×$600 = 26,200 BNFCR).All 12 asset types in the EU account API response have
marginAvailable: true-including stablecoins (USDC, FDUSD, USD1), crypto (BTC, ETH, BNB, U), and internal
products (BNFCR, LDUSDT, BFUSD, RWUSD). Binance adds new collateral types regularly,
so a hardcoded list would be outdated quickly. Instead we iterate CashBook and sum all
non-zero, non-primary collateral when BNFCR is present.
Requires Documentation Change
No
How Has This Been Tested?
Unit tests (
CryptoFutureMarginModelTests):MarginRemainingWithBnfcrOnlyCollateral- BNFCR as sole collateralMarginRemainingWithMixedCollateral- USDT + BNFCRMarginRemainingWithUsdtOnlyCollateral- non-EU backward compatibilityCoinFutureDoesNotIncludeBnfcrAsCollateral- coin futures skip BNFCRBnfcrZeroBalanceIncludesSupplementaryCollateral- BNFCR=0, USDC=100BtcCollateralConvertedToQuoteCurrency- BTC collateral converted via market priceDefaultMarginModelDoesNotIncludeSupplementaryCollateral- non-Binance brokerageRegression algorithm:
BinanceCryptoFutureBnfcrCollateralRegressionAlgorithmLive tested with Binance EU account (Credits Trading Mode,
multiAssetsMargin: true).Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>