QuantConnect / QuantConnect/Lean
CryptoFuture.IsCryptoCoinFuture() incorrectly classifies USD-quoted linear futures as coin-margined, breaking EU MiCA-compliant exchanges
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 21.7k
- Forks
- 5.3k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 34
Description
CryptoFuture.IsCryptoCoinFuture() hardcodes a whitelist of quote currencies (USDT, BUSD, USDC) to distinguish linear from coin-margined futures. This breaks any exchange that quotes linear perpetual futures in USD instead of USDT — which is exactly the case for EU MiCA-regulated exchanges.
Background / Regulatory Context
Under EU MiCA, compliant exchanges are restricted from offering stablecoins such as USDT or USDC as settlement currencies for derivatives — only fiat currencies are permitted. As a result, exchanges such as Kraken Futures and OKX EU quote their linear perpetual futures in USD (fiat) rather than USDT or USDC. Binance and Bybit have already withdrawn from EU futures markets due to MiCA compliance requirements, so going forward, any EU-compliant futures exchange will always quote in fiat USD — making this a structural blocker for EU exchange integration.
I have been implementing community brokerage connectors for Kraken Futures and OKX EU. This bug in LEAN core is a hard blocker that prevents me from proceeding with either connector.
Root Cause
In Common/Securities/CryptoFuture/CryptoFuture.cs:
private static bool IsCryptoCoinFuture(string quoteCurrency)
{
return quoteCurrency != "USDT" && quoteCurrency != "BUSD" && quoteCurrency != "USDC";
}
This method assumes only USDT/BUSD/USDC-quoted futures are linear. Any fiat USD-quoted future is incorrectly classified as coin-margined/inverse, regardless of its actual contract type. This affects:
CryptoFutureHolding.GetQuantityValue()→HoldingsValueandUnrealizedProfituse the inverse formula (quantity / pricein base currency instead ofprice * quantityin quote currency), producing a value equal toQuantityinstead of the correct notional USD value.CryptoFutureMarginModel.GetCollateralCash()→ collateral is incorrectly attributed to base currency (e.g. XBT) instead of quote currency (USD), breaking margin calculations.SecurityPortfolioManager.TotalPortfolioValue→ completely wrong, causing incorrect position sizing in live trading.
Impact
TotalPortfolioValueshows a BTC position as worth2.8USD instead of~163,000USD.- Position sizing is off by a factor equal to the current BTC price.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Common/Securities/CryptoFuture/CryptoFuture.cs at IsCryptoCoinFuture(string quoteCurrency), then trace how CryptoFutureHolding.GetQuantityValue() and CryptoFutureMarginModel.GetCollateralCash() use the classification. Reproduce the USD-quoted linear-future behavior and verify that HoldingsValue, UnrealizedProfit, collateral, and TotalPortfolioValue use the correct notional and currency treatment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- fintech-quant
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100