Hello,
When I place a futures limit post-only order in cross-margin-mode, I want to calculate in advance if my margin is enough to execute the order (since changing from market orders to limit orders I often get “Margin is insufficient.”). I tried to understand the calculations mainly from these pages:
Let’s start with my confusions:
- I understand that the main check is cost <= available_balance and this only applies to “orders that open a position” as Binance defines it:
- Is there a way to stream (not REST API) the available_balance?
- I found different calculations for the available_balance. Which is correct?
Available Balance = Wallet Balance - Initial Margin + Unrealized PNL or
Available for Order = max(0, crossWalletBalance + ∑cross Unrealized P&L - (∑cross initial margin + ∑isolated open order initial margin)) - What is the formula for initial_margin (with leverage 1)?
abs(position_size)*mark_price or abs(position_size)*limit_order_price
- The formula for cost Cost = Initial Margin + Open Loss seems not right in all possible scenarios:
- scenario 1: I am holding 0 BTCUSDT and post a limit buy order of 1 BTCUSDT at 10’000USD. For this scenario the formula is right
- scenario 2: I am holding -1 BTCUSDT with notional 10’000USD (mark price 10’000USD) and post a limit buy order 1.5 BTCUSDT at 10’000USD. According to the formula I need 15’000USD margin for the order. According to my logic, I have already allocated 10’000USD margin to the short position, close it and open a long position of 0.5 BTCUSDT worth 5’000USD. The margin needed would be 5’000USD. Where is my confusion?
- There is also the formula Margin Requirement = Max(Abs(Position Notional Value** + Bid Order Value***), Abs(Position Notional Value - Ask Order Value)) / Leverage
- Let’s assume scenario 2 from above: According to this formula margin_requirement = max(abs(-10’000 + 1.5*10’000), abs(-10’000 - 0))/1 = 10’000USD. Again another value
- What is correct?
I hope, somebody can clarify my confusions. Thanks!