nautilus_trader
nautilus_trader copied to clipboard
Sell order denied due to CUM_NOTIONAL_EXCEEDS_FREE_BALANCE when there is enough balance
Bug Report
Expected Behavior
Sell order is submitted without being blocked by the risk engine
Actual Behavior
Risk engine denies an order due to CUM_NOTIONAL_EXCEEDS_FREE_BALANCE
even though there is enough balance.
Steps to Reproduce the Problem
- Starting balance: 1000000 FDUSD, 0 BTC
- Subscribe to provided quote ticks and run provided strategy
Specifications
- OS platform: Windows
- Python version: 3.12.1
-
nautilus_trader
version: 1.191.0 dummy_strategy.txt quote_ticks_bug.csv
Hi @rubenmarias
I've been able to reproduce the order denial, I used ETHUSDT as a placeholder instrument here but the starting conditions and maths should be the same I think.
After some buy and sell cycles the first occurrence is here:
2024-04-26T02:02:37.539078627Z [DEBUG] BACKTESTER-001.RiskEngine: Total: Money('0.17814000', ETH)
2024-04-26T02:02:37.539078627Z [DEBUG] BACKTESTER-001.RiskEngine: Locked: Money('0.00000000', ETH)
2024-04-26T02:02:37.539078627Z [DEBUG] BACKTESTER-001.RiskEngine: Free: Money('0.17814000', ETH)
2024-04-26T02:02:37.539078627Z [DEBUG] BACKTESTER-001.RiskEngine: Cumulative notional SELL: Money('0.20000000', ETH)
2024-04-26T02:02:37.539078627Z [WARN] BACKTESTER-001.RiskEngine: SubmitOrder for O-20240426-0202-001-000-625 DENIED: CUM_NOTIONAL_EXCEEDS_FREE_BALANCE: free=0.17814000 ETH, cum_notional=0.20000000 ETH
This looks like an order to sell 0.2 ETHUSDT when the available ETH balance is 0.17814000, does this match the observation you see at this timestamp?
Yes @cjdsellers, a couple things that I didn't mention:
- when checking the portfolio the current position is enough for the sell
- by looking at the sequence of buys and sells, the inventory is enough for the sell
thanks
Indeed, I see at that timestamp both the strategy inventory
and portfolio.net_position
both agree at LONG 0.20702.
Now fixed from ae9677a559c4be36fbeaf017a7ad92e23a82de63.