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.04k stars 428 forks source link

Error: Modify Isolated Position Margin for Future Coin #534

Closed dante1989 closed 3 years ago

dante1989 commented 3 years ago

Hello, for isolated mode, after fixing, the Future USDT is working for ModifyPositionMarginAsync very well. But Coin Future is not working for ModifyPositionMarginAsync clientBinance.FuturesUsdt.ModifyPositionMarginAsync: Work well clientBinance.FuturesCoin.ModifyPositionMarginAsync: Not Work and got error Please check error with FuturesCoin. I think it sends a GET request while it should be a POST Here it is error:

2021/01/05 22:01:36:674 | Binance | Debug | Client configuration: LogVerbosity: Debug, Writers: 1, Credentials: -, BaseAddress: https://api.binance.com/, Proxy: -, RateLimiters: 0, RateLimitBehaviour: Wait, RequestTimeout: 00:00:30 2021/01/05 22:01:36:685 | Binance | Debug | Setting api credentials 2021/01/05 22:01:36:695 | Binance | Debug | [1] Creating request for https://api.binance.com/api/v3/time 'Bot Trade.exe' (CLR v4.0.30319: Bot Trade.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 2021/01/05 22:01:36:713 | Binance | Debug | [1] Sending GET request to https://api.binance.com/api/v3/time 2021/01/05 22:01:36:996 | Binance | Debug | [1] Response received in 272ms: {"serverTime":1609858898491} 2021/01/05 22:01:37:021 | Binance | Debug | [2] Creating request for https://api.binance.com/api/v3/time 2021/01/05 22:01:37:023 | Binance | Debug | [2] Sending GET request to https://api.binance.com/api/v3/time 2021/01/05 22:01:37:106 | Binance | Debug | [2] Response received in 81ms: {"serverTime":1609858898669} 2021/01/05 22:01:37:107 | Binance | Info | Time offset set to 1647.7371ms 2021/01/05 22:01:37:144 | Binance | Debug | [3] Creating request for https://dapi.binance.com/dapi/v1/positionMargin Exception thrown: 'System.NullReferenceException' in mscorlib.dll Object reference not set to an instance of an object.

JKorf commented 3 years ago

Ah I responded in the other (closed) issue, but let's continue here.

The call is the same for USDT and Coin futures, just with slightly changed endpoints. If the USDT futures is correct, the Coin futures should also be correct (or at least send the same HTTP method). Your logging doesn't show that the request was actually sent to the server. I would expect a Sending POST request to xxx message, but there are only those for the timestamp.

Are you sure the issue isn't somewhere in you code?

dante1989 commented 3 years ago

I did the same thing for USDT Future and Coin Future. USDT Future is successful but Future coin is faulty, I will double-check again and report back to you.

dante1989 commented 3 years ago

This is my Code: Dim clientBinance = New BinanceClient(New BinanceClientOptions With {.LogVerbosity = LogVerbosity.Debug}) 'API Binance Future clientBinance.SetApiCredentials(API_Binance2, Secret_Binance2)

Dim TestUSDTFuture As WebCallResult(Of BinanceFuturesPositionMarginResult) = Await clientBinance.FuturesUsdt.ModifyPositionMarginAsync(Symbol, 10, FuturesMarginChangeDirectionType.Add, positionSide:=PositionSide.Long)

_Dim TestCoinFuture As WebCallResult(Of BinanceFuturesPositionMarginResult) = Await clientBinance.FuturesCoin.ModifyPositionMarginAsync(Symbol_CoinFuture , 0.01, FuturesMarginChangeDirectionType.Add, positionSide:=PositionSide.Long)_

TestUSDTFuture is success but TestCoinFuture is fail. Both of them is isolated mode. I have enough money for both. i do not know why?

dante1989 commented 3 years ago

Hi, I have checked again, because I was wrong with Symbol_CoinFuture (not correct), Sorry for wasting your time, I have send a donation (ETH) to you for your support, thank you for your time

JKorf commented 3 years ago

No problem, thanks for the donation :)