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

Public endpoint "GetInstruments" returns response from live API instead from demo trading API #42

Closed Radimersky closed 1 year ago

Radimersky commented 1 year ago

Hello, I have OKXRestApiClient instantiated like this: new OKXRestApiClient(new OKXRestApiClientOptions { LogLevel = LogLevel.Debug, DemoTradingService = true, DebugMode = true });

Using this client instance, when calling PublicData.GetInstrumentsAsync(OkxInstrumentType.Swap) returns a response from live API instead of demo trading API even when I have DemoTradingService set to true.

The issue is solved when I either add SignPublicRequests = true to the OKXRestApiClientOptions or set the "signed" parameter in GetInstrumentsAsync to true.

I am not sure if this is a bug or if I am missing something significant but I would expect that when using a client with DemoTradingService set to true then every called API endpoint will use DemoTradingService.

burakoner commented 1 year ago

Try this

        OKXApiAddresses.Default = OKXApiAddresses.Demo;
        var api = new OKXRestApiClient(new OKXRestApiClientOptions
        {
            DemoTradingService = true,
        });
burakoner commented 1 year ago

I'll release a newer version and you wont need to first line anymore.