JKorf / OKX.Net

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

Exception in SetAccountLeverageAsync #21

Closed danielhw2 closed 7 months ago

danielhw2 commented 8 months ago

When I call this code

ClienteRest.UnifiedApi.Account.SetAccountLeverageAsync(7, OKX.Net.Enums.OKXMarginMode.Isolated).Result;

It gives me this Exception:

System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (Either instId or ccy is required; if both are passed, instId will be used by default.)
  Source=System.Private.CoreLib
  StackTrace:
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   ...

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
ArgumentException: Either instId or ccy is required; if both are passed, instId will be used by default.

CryptoExchange.Net 6.2.1 JK.OKX.Net 1.4.3 .NET 8.0

JKorf commented 8 months ago

You need to also pass in either the asset or symbol parameter

danielhw2 commented 8 months ago

Hello, thanks for the answer.

I managed to work passing the symbol parameter, but with the asset it returns this error:

"Parameter mgnMode error"

The code:

ClienteRest.UnifiedApi.Account.SetAccountLeverageAsync(7, OKXMarginMode.Isolated, "BTC", null, OKXPositionSide.Long, CancellationToken.None).Result;

JKorf commented 7 months ago

Hm not sure why that is, but I think it might not be a valid scenario. See https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-leverage for possible options

danielhw2 commented 7 months ago

Ok. I resolved the issue by only using the symbol parameter... Thanks!