Skip to content

Commit 4b66433

Browse files
Allow emtpy BNFCR cash through (#9247)
1 parent 4b2f203 commit 4b66433

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Common/Util/CashAmountUtil.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public static class CashAmountUtil
3131
public static bool ShouldAddCashBalance(CashAmount balance, string accountCurrency)
3232
{
3333
// Don't add zero quantity currencies except the account currency
34-
return balance.Amount != 0 || balance.Currency == accountCurrency;
34+
// we do add 'BNFCR' even if zero as it's used to track brokerage fees, we need lean to setup conversion rates for it
35+
return balance.Amount != 0 || balance.Currency == accountCurrency || balance.Currency == "BNFCR";
3536
}
3637
}
37-
}
38+
}

Tests/Engine/Setup/BrokerageSetupHandlerTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ public void ZeroQuantityCurrenciesAreNotAddedToCashBook()
617617
{
618618
new CashAmount(0, "USD"),
619619
new CashAmount(0, "EUR"),
620+
new CashAmount(0, "BNFCR"),
620621
new CashAmount(123, "ETH")
621622
});
622623

@@ -639,6 +640,8 @@ public void ZeroQuantityCurrenciesAreNotAddedToCashBook()
639640
Assert.IsFalse(algorithm.Portfolio.CashBook.ContainsKey("EUR"));
640641
// ETH should be present
641642
Assert.IsTrue(algorithm.Portfolio.CashBook.ContainsKey("ETH"));
643+
// special case used in binance future fees
644+
Assert.IsTrue(algorithm.Portfolio.CashBook.ContainsKey("BNFCR"));
642645
}
643646

644647
private void TestLoadExistingHoldingsAndOrders(IAlgorithm algorithm, Func<List<Holding>> getHoldings, Func<List<Order>> getOrders, bool expected)

0 commit comments

Comments
 (0)