QuantConnect/Lean · error · RegressionTestException
Order rejected — BNFCR collateral should cover margin
Error message
Order rejected — BNFCR collateral should cover margin
What it means
Thrown when Buy(_adaUsdt.Symbol, 1000) returns an OrderTicket with Status == OrderStatus.Invalid. This means the order was rejected by the Lean order processor or brokerage model. The assertion verifies that the BNFCR collateral pool provides sufficient margin to accept the ADAUSDT futures order.
Source
Thrown at Algorithm.CSharp/BinanceCryptoFutureBnfcrCollateralRegressionAlgorithm.cs:73
{
if (_adaUsdt.Price == 0 || _orderPlaced)
{
return;
}
// 1. BNFCR collateral must produce positive buying power (USDT is zero)
var buyingPower = _adaUsdt.BuyingPowerModel.GetBuyingPower(new BuyingPowerParameters(Portfolio, _adaUsdt, OrderDirection.Buy));
if (buyingPower.Value <= 0)
{
throw new RegressionTestException($"Expected positive buying power from BNFCR, got {buyingPower.Value}");
}
// 2. Order must not be rejected
var ticket = Buy(_adaUsdt.Symbol, 1000);
_orderPlaced = true;
if (ticket.Status == OrderStatus.Invalid)
{
throw new RegressionTestException("Order rejected — BNFCR collateral should cover margin");
}
// 3. Margin must be tracked
if (Portfolio.TotalMarginUsed <= 0)
{
throw new RegressionTestException($"Expected positive TotalMarginUsed, got {Portfolio.TotalMarginUsed}");
}
// 4. Shared collateral: ETHUSDC (different quote currency) must deduct ADAUSDT margin
_ethUsdc.SetMarketPrice(new TradeBar { Time = Time, Symbol = _ethUsdc.Symbol, Close = 1600 });
var ethBuyingPower = _ethUsdc.BuyingPowerModel.GetBuyingPower(new BuyingPowerParameters(Portfolio, _ethUsdc, OrderDirection.Buy));
var adaBuyingPower = _adaUsdt.BuyingPowerModel.GetBuyingPower(new BuyingPowerParameters(Portfolio, _adaUsdt, OrderDirection.Buy));
// ETHUSDC must see less buying power than ADAUSDT - ADAUSDT maintenance margin
// is deducted from ETHUSDC's shared pool, but ADAUSDT skips itself.
if (ethBuyingPower.Value >= adaBuyingPower.Value)
{View on GitHub (pinned to d2c3659f87)
Solutions
- Log the ticket's full details: ticket.Status, ticket.CancelMessage, and ticket.SubmitRequest.Response.
- Verify the ADAUSDT crypto future symbol exists in SymbolPropertiesDatabase with correct lot size.
- Check that the BNFCR collateral value (200 × conversion rate) covers the maintenance margin for 1000 ADAUSDT.
- Inspect the BinanceFuturesBrokerageModel.CanSubmitOrder for rejection conditions.
- Reduce the order quantity to test if the rejection is margin-related vs. a hard validation failure.
Example fix
// before
var ticket = Buy(_adaUsdt.Symbol, 1000);
_orderPlaced = true;
if (ticket.Status == OrderStatus.Invalid)
{
throw new RegressionTestException("Order rejected — BNFCR collateral should cover margin");
}
// after — capture rejection reason
var ticket = Buy(_adaUsdt.Symbol, 1000);
_orderPlaced = true;
if (ticket.Status == OrderStatus.Invalid)
{
throw new RegressionTestException(
$"Order rejected: {ticket.CancelMessage ?? ticket.SubmitRequest.Response?.ErrorMessage}");
} Defensive patterns
Strategy: validation
Validate before calling
// Check order validity before asserting
var ticket = Buy(_adaUsdt.Symbol, 1000);
_orderPlaced = true;
if (ticket.Status == OrderStatus.Invalid)
{
Log($"Order rejected: {ticket.CancelMessage}");
Log($"Submit response: {ticket.SubmitRequest.Response?.ErrorMessage}");
} Type guard
bool IsOrderAccepted(OrderTicket ticket) => ticket.Status != OrderStatus.Invalid;
Prevention
- Verify BNFCR collateral amount covers the maintenance margin for the order size.
- Check SymbolPropertiesDatabase for ADAUSDT crypto future lot size and leverage.
- Log ticket.CancelMessage and SubmitRequest.Response for rejection details.
- Test with a smaller order quantity to isolate margin vs. validation rejections.
When it happens
Trigger: The buying-power model reports insufficient margin (links to error 35), the brokerage model rejects the order quantity or symbol, the crypto future symbol properties are misconfigured, or the order validator blocks the trade for leverage or lot-size reasons.
Common situations: Margin calculation errors in CryptoFutureBuyingPowerModel, brokerage model filtering changes, symbol-properties database missing ADAUSDT futures entry, or order quantity exceeding minimum/maximum lot size.
Related errors
- Expected positive buying power from BNFCR, got {buyingPower.
- ETHUSDC buying power ({ethBuyingPower.Value}) must be less t
- Expected positive TotalMarginUsed, got {Portfolio.TotalMargi
- Expected an open position at end of algorithm
- Invalid buying power model. Found: {buyingPowerModel.GetType
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/8c87a44e7f8689fc.
Report an issue: GitHub.