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.05k stars 429 forks source link

USDT Futures trading with leverage #1328

Open dungtrandk opened 11 months ago

dungtrandk commented 11 months ago

JUST EDITED TO REFERENCE THE CORRECT CLASS

I am using the Binance.net lib to place futures orders and here is my problem:

When I use the Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiTrading I expected it to place a usdt futures order with the selected leverage on that symbol. But instead it seems to wanting to place a Margin trade on that symbol, but since I dont have any funds in the symbol on my Margin account it says something like "Insufficient margin on account".

I do not want to place margin orders but leverage on USDT-M futures.

ALSO: I HAVE MY MARGIN MODE SET TO "CROSS" AND LEVERAGE SET TO "1" TO TEST.

How do i do that?

dungtrandk commented 11 months ago

Jeff Please help :-)

I Want to place a SOLUSDT futures market order and I am using Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiTrading to place the order async: The code:

var response = await BinanceClient.UsdFuturesApi.Trading.PlaceOrderAsync( "SOLUSDT", Binance.Net.Enums.OrderSide.Buy, Binance.Net.Enums.FuturesOrderType.Market, 10, null, Binance.Net.Enums.PositionSide.Both);

In my Binance account i have set the positionside to both and i have set the SOLUSDT pair to CROSS and leverage is set to 1 (also tried different other leverages). I have more than 1000 USDT on the Futures Account but still, the response is error with the the error message: "Insufficient Margin".

XHighIntell commented 11 months ago

You buy 10 SOL, change your quantity of your order to 1 and try again

dungtrandk commented 10 months ago

Hi XHighIntell

I can try this no problem. But when I do it using the Binance website, I dont need to buy/SELL 10 SOL before.

I just select the leverage, amount i want to buy/sell for and then click buy/sell.

Cant this be achieved using this Library?

MihailDamian commented 1 month ago

For spot api you can do that by set 'quoteQuantity', FuturesApi have only 'quantity' param because thats a Futures thing, even in Binance UI you have same. Its very simple to calculate the size of position based on your desire USD value like that: decimal quantity = USDValue / BestAskPrice;