JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 421 forks source link

Increase the Maintenance Margin for futures order #944

Open KomodoCrypto opened 2 years ago

KomodoCrypto commented 2 years ago

I am using the library in my application to handle spot and futures orders successfully. However, I am being liquidated in futures orders because a very small maintenance ratio of the orders.

Context example: future LONG order, with shares calculated based on 100$. My account has 500$ with available isolated leverage x10.

var resultPlaceOrder = privateClient.FuturesUsdt.Order.PlaceOrderAsync("AVAXUSDT", OrderSide.Buy, OrderType.Market, newClientOrderId: DateTimeEntry, quantity: shares).Result;

The order is executed successfully.

Problem: the margin is set to only about 2$, and the liquidation price is consequently 98$. Why? If I add some margin, 100$, with following method, it works too:

    `var result = privateClient.FuturesUsdt.ModifyPositionMarginAsync("AVAXUSDT", 100m, FuturesMarginChangeDirectionType.Add).Result;`

Then my liquidation price is calculated and set as expected, so I assume that it is not a matter of margin funds. But, this is obviously not a solution, because it’s too risky, so between the order execution event and the execution of margin increase, there are a few ms that can liquidate the future.

I am then stacked trying to know why the default maintenance ratio is so low… These lower values don't make sense to me. How could I increase it? How the default maintenance margin is calculated? Is there any method to set it into my account?

JKorf commented 2 years ago

I don't have enough knowledge about this to answer you. You could try this Binance API forum: https://dev.binance.vision/

KomodoCrypto commented 2 years ago

Ok, I do, thanks. If anybody else faced the same problem, I keep this thread open for discussion. I will post the answer or related link from binance here if any. Thank you for your great work.

techno2mahi commented 2 years ago

+1 Looking for the same API where I can increase the margin of placed orders.

techno2mahi commented 2 years ago

+1

hiliev commented 1 year ago

This happens because you are in isolated margin mode. When in cross margin mode, all the available funds in the futures wallet are used as margin shared between all assets. When in isolated margin mode, the initial margin for a particular asset is the notional value divided by the leverage, i.e. it is equivalent to what you are paying to open the position. This is described in the documentation, more specifically the liquidation price calculation page notes that in isolated mode only the isolated position margin counts and the cost page shows that the initial margin is the notional value divided by the leverage.

You have to manually allocate more or less margin funds to an isolated position and so manage the risk. This is the sole reason isolated positions exist.