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

Error: Margin is insufficient #341

Closed dante1989 closed 4 years ago

dante1989 commented 4 years ago

I'm trying make order Stop Limit in Binance Future by API:

Dim clientFutureBinance = New BinanceFuturesClient 'API Binance Future clientFutureBinance.SetApiCredentials(API_Binance2, Secret_Binance2)

    Dim Symbol As String = "BTCUSDT"

    Dim ItemFuturesAccountBalance As WebCallResult(Of IEnumerable(Of BinanceFuturesAccountBalance))
    ItemFuturesAccountBalance = Await clientFutureBinance.GetFuturesAccountBalanceAsync

    MsgBox(ItemFuturesAccountBalance.Data(0).Balance.ToString)

    Await clientFutureBinance.ChangeInitialLeverageAsync(Symbol, 50,)
    Await clientFutureBinance.ChangeMarginTypeAsync(Symbol, FuturesMarginType.Isolated)

    Dim ItemBuyLongBinance As WebCallResult(Of BinanceFuturesPlacedOrder)
    ItemBuyLongBinance = Await clientFutureBinance.PlaceOrderAsync(Symbol, BinanceOjectsOrderSide.Buy, BinanceOjectsOrderType.Stop, 1, price:=20000, stopPrice:=20000)

    MsgBox(ItemBuyLongBinance.Error.Message)

Result: My balance is 1000 USDT, but i got Error: Margin is insufficient I have tested place order by manually, it is ok. I can put max (2.5 Bit) with Leverage X50 by manually, but API have that error for 2 bit, 1 bit, 0.5 bit. but 0.05 bit is success. Maybe something wrong

Could you help me to fix that error, thank you so much. Please put your comment with your USDT wallet, i want to donate for your hard working

eros1453 commented 4 years ago

Price 20000 ?? Really

My use is like this :

private void GoShortMarketbutton_Click(object sender, EventArgs e) { Task.Run(() => { decimal trade_amount = Math.Round(TradeAmount * Leverage / bestBid, PRECISION); using (var bfc = new BinanceFuturesClient()) { var ShortOrderResult = bfc.PlaceOrder(ASSET, side: OrderSide.Sell, type: OrderType.Market, quantity: trade_amount); if (ShortOrderResult.Success) { OpenOrders(); OpenPositions(); } else { MessageBox.Show($"Order placing failed: {ShortOrderResult.Error.Message}", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } } }); }

dante1989 commented 4 years ago

i found the problem, because i use price 20K (so high)