burakoner / OKEx.Net

Open source .Net API wrapper for the @OKEx V5 Rest API and V5 Websocket API
MIT License
86 stars 49 forks source link

- Add ToUpper() #8

Closed damob-byun closed 3 years ago

damob-byun commented 3 years ago

### ISSUE

WebSocket does not work

Before log

PAIR : BTC-USDT
2020-12-21 18:24:43:685 | Okex       | Debug | Socket 1 connecting
2020-12-21 18:24:44:071 | Okex       | Debug | Socket 1 connected
2020-12-21 18:24:44:082 | Okex       | Debug | Socket 1 sending data: {"op":"subscribe","args":["spot/depth:btc-usdt"]}
2020-12-21 18:24:44:201 | Okex       | Debug | Socket 1 received data: {"event":"error","message":"Channel spot/depth:btc-usdt doesn't exist","errorCode":30040}
2020-12-21 18:24:44:207 | Okex       | Warning | Subscription failed: Channel spot/depth:btc-usdt doesn't exist
2020-12-21 18:24:44:212 | Okex       | Debug | Socket 1 closing
2020-12-21 18:24:44:329 | Okex       | Info | Socket 1 closed
2020-12-21 18:24:46:226 | Okex       | Debug | Socket 1 closed
2020-12-21 18:24:46:227 | Okex       | Debug | Socket 1 disposing websocket

symbol variable is made lowercase by OkexExtensions.ValidateSymbol function symbol = symbol.ValidateSymbol(); I don't know your intentions, I only fixed the part that I used

public static string ValidateSymbol(this string symbol, string messagePrefix="", string messageSuffix="")
        {
            if (string.IsNullOrEmpty(symbol))
                throw new ArgumentException($"{messagePrefix}{(messagePrefix.Length > 0 ? " " : "")}Symbol is not provided{(messageSuffix.Length > 0 ? " " : "")}{messageSuffix}");

            symbol = symbol.ToLower(CultureInfo.InvariantCulture);
            if (!Regex.IsMatch(symbol, "^(([a-z]|[A-Z]|-|[0-9]){4,})$"))
                throw new ArgumentException($"{messagePrefix}{(messagePrefix.Length > 0 ? " " : "")}{symbol} is not a valid Okex Symbol. Should be [QuoteCurrency]-[BaseCurrency], e.g. ETH-BTC{(messageSuffix.Length > 0 ? " " : "")}{messageSuffix}");

            return symbol;
        }

After Log

2020-12-21 18:26:57:435 | Okex       | Debug | Socket 1 connecting
2020-12-21 18:26:57:796 | Okex       | Debug | Socket 1 connected
2020-12-21 18:26:57:809 | Okex       | Debug | Socket 1 sending data: {"op":"subscribe","args":["spot/depth:BTC-USDT"]}
2020-12-21 18:26:57:928 | Okex       | Debug | Socket 1 received data: {"event":"subscribe","channel":"spot/depth:BTC-USDT"}
2020-12-21 18:26:57:932 | Okex       | Debug | Subscription completed

It works.

burakoner commented 3 years ago

I am working on websocket part and fixed it. I have some jobts to to but I can push current snapshot in one minute.

burakoner commented 3 years ago

You can check it here https://github.com/burakoner/OKEx.Net/commit/70d204df5fdeb5d61469afbdfbf6cfb188130de2

damob-byun commented 3 years ago

thx :)

damob-byun commented 3 years ago

and one more exist issue If I do spotPlaceOrder on BTC market. price parameter error occured. perhaps there is a problem in the process of convert decimal into strings. @burakoner

burakoner commented 3 years ago

AS you can see in the codes I dont check price filter. Okex does that. You need send request according to Okex rules.