what’s the calculation to get this max value for both long and short?
I tried: available balance * leverage / mark price
best bid, and best ask too but it appears to not be that
thanks
what’s the calculation to get this max value for both long and short?
I tried: available balance * leverage / mark price
best bid, and best ask too but it appears to not be that
thanks
There’s a position limit at your current leverage level, which is called maxNotionalValue.
You can check the trading rules.
Yeah but nope. maxNotionalValue gives us the max authorized, if you have less balance you can’t go until this value. Furthermore, we clearly see that for long and shorting it’s not the same value
Within your maxNotionalValue, if you want to put a limit order with a bid price higher than the mark price now, the system will regard the total price difference as your loss, and the remain balance * leverage / bid price will be the approximate quantity you can order. The short side is the same,
Mhh not sure to understand but I will try to find. Here’s what I write it down:
and the binance ui show me these max:
I have caculated the fomula for your question to figure out the maxPosition you can open for both sides.
When you’re trying to open Long Side, take the plus. And take the minus if you want to open Short Side.
Use BTCUSDT as a simple example, with MarkPrice of 39330.4, Leverage of 5, and no Opened Positions.
When I put a Limit Bid Order at the price of 40888.8, my fomula can give you the answer of 223.989.
This is only an approximate quantity because the MarkPrice changes every millisecond.
Just test and it doesn’t work for me. Maybe because I look with market order. I have to adjust with this I think: Comment calculer le coût requis pour ouvrir une position sur un contrat à terme perpétuel | Binance Support
@passingsword can you tell me in your formula the open loss part to adjust for market orders please?
The value displayed by Binance UI is calculated by the browser through Javascript, and it is not calculated in real time, so it is inevitable that there is a gap with the theoretical value.
If you have find any mistakes or new discoveries, of the formula, just point out and refine it for me.
In this formula of Max, what does below variable stand for:
notional
price
I know there is a gap but I have a big gap here ^^ are you available in discord? (DevChris#2112)
I’m not using discord…
Don’t know why your gap is so big.
I tried and it works for me.
Where can we discuss in a voice channel if you’re ok?
Maybe the formula is wrong with already open position or idk I think there is something to do with this max notional. Maybe if max = X, we can go to -X to X then if we’re shorting 1 and max is 10 we can go to 11 in long nope?
@passingsword Yeah I really think you are missing when there is already open position, and maybe the open loss
Here’s the formula:
First you need to get the available balance and take into account the position if you have already notional in it.
nBalance = available balance * leverage
price = side == "BUY" ? best ask * 1.0005 : max(best bid, mark price)
dir = side == "BUY" ? 1 : -1
available = min(nBalance, maxNotional)
IF side == "BUY" AND notional > 0 OR side == "SELL" AND notional > 0 {
available = available + abs(notional)
}
and after that you need to take into account the open loss:
o = abs { min(0, (mark price - price) * dir) }
maxAmount = available / (o * leverage + price)
IF side == "BUY" AND notional > 0 OR side == "SELL" AND notional > 0 {
maxAmount = maxAmount + abs(position amount)
}
then you have your max amount for market order
hello, i dont understand your solution. what programming language is this? i want to implement it in python. thanks
Here’s my function in typescript, ask if you don’t understand something in there: maxQtyAllowed · GitHub
i am new to programming so it is only python i understand. is there a formula you use in calculating that i can just implement in python? thanks
Github gist is gone
Do you have an updated version?