burakoner / OKX.Api

Up-to-date, most-complete, well-organized, well-documented, easy-to-use, multi-task and multi-thread compatible OKX Cryptocurrency Exchange Rest and Websocket Api Wrapper
MIT License
39 stars 15 forks source link

Timestamp issue #47

Closed overstartup closed 1 year ago

overstartup commented 1 year ago

i'm trying to get account info:

var balance = api.TradingAccount.GetAccountBalanceAsync().Result;

but it returns this error:

2023/09/19 10:54:39:556 | Information | OKX RestApi | [1] Creating request for https://www.okx.com/api/v5/public/time
2023/09/19 10:54:39:795 | Debug | OKX RestApi | [1] Response received in 234ms
2023/09/19 10:54:39:803 | Information | OKX RestApi | OKX RestApi Time offset set to 754808ms
2023/09/19 10:54:39:812 | Information | OKX RestApi | [1] Creating request for https://www.okx.com/api/v5/account/balance
2023/09/19 10:54:40:102 | Warning | OKX RestApi | [1] Error received in 281ms: {"msg":"Timestamp request expired","code":"50102"}

my configuration are:

   api = new OKXRestApiClient(new OKXRestApiClientOptions
            {
                DemoTradingService = configurationOptions.DemoTradingService,
                LogLevel = LogLevel.Debug
            });
            api.SetApiCredentials(ConfigurationOptions.ApiKey, ConfigurationOptions.SecretKey, ConfigurationOptions.Passphrase);

i just added this config to solve but it still has error:

AutoTimestamp = true,
 AutoTimestampInterval = TimeSpan.FromSeconds(60)

It was working correctly but after new update it gives this error.