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

WebSocket OrderBookTrading.MarketData.SubscribeToCandlesticksAsync is not working #46

Closed sonpxc005472 closed 11 months ago

sonpxc005472 commented 11 months ago

I don't see any data pushed after I subscribe a candlestick

overstartup commented 11 months ago

Could you share your code?

sonpxc005472 commented 11 months ago

Just like the sample: var sample_pairs = new List<string> { "BCH-USDT-SWAP", "ETH-USDT-SWAP" }; var ws = new OKXWebSocketApiClient(); foreach (var pair in sample_pairs) { await ws.OrderBookTrading.MarketData.SubscribeToCandlesticksAsync((data) => { if (data != null) { // ... Your logic here } }, pair, OkxPeriod.FiveMinutes); } After investigating, I see OKX already changed the websocket address follow this link. Now, the address is: wss://ws.okx.com:8443/ws/v5/business. Please take a look and update the lib

sonpxc005472 commented 11 months ago

Btw, the endpoint: api.PublicData.UnitConvertAsync(symbol, quantity, price, OkxConvertType.ContractToCurrency, OkxConvertUnit.Coin). The price and unit is optional for converting contract to currency and vice versa but if a do not pass one of these params the endpoint will be failed

burakoner commented 11 months ago

OKX divided websocket endpoints into public, private and business. In your case you get response below

{ "event": "error", "msg": "This channel has been migrated to the '/business' URL. Please subscribe using the new URL. More details can refer to: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url", "code": "64001" }

So, this problem is nbot related only one websocket endpoint. It's related with all websocket methods. I've fixed this issue.

Thanks for your feedback

burakoner commented 11 months ago

Version 1.4.0 has been released. Please check these out https://github.com/burakoner/OKX.Api/commit/a2332273d6d885f3b58a532bc5d63793da3634d8 https://www.nuget.org/packages/OKX.Api/