sonvister / Binance

A .NET Standard Binance API library.
MIT License
229 stars 77 forks source link

unable to parse result when using GetOrderBookTopsAsync #127

Open pavlexander opened 4 years ago

pavlexander commented 4 years ago

Using .Net Core 3.1 console app:

    static async Task Main(string[] args)
    {
        Console.WriteLine("Hello World!");

        var apikey = "<>";
        var apisecret = "<>";

        var user = new BinanceApiUser(apikey, apisecret);
        var api = new BinanceApi();

        //var sth = await api.GetOrderBookTopsAsync(); // this will fail!
        var sth2 = await api.GetOrderBookTopAsync("ETHBTC");
        var sth3 = await api.GetOrderBookAsync("ETHBTC", 10);

        Console.WriteLine("End");
        Console.ReadKey();
    }

The first line var sth = await api.GetOrderBookTopsAsync(); will crash the program with error:

Binance.BinanceApiException HResult=0x80131500 Message=BinanceApi.GetOrderBookTopsAsync failed to parse JSON api response: " ... Inner Exception 1: ArgumentException: OrderBookTop ask price must be greater than the bid price. (Parameter 'Price')

error_details.txt

binance 0.2.0-beta902

ogzkc commented 4 years ago

It's about the AskPrice, some symbols that which in BREAK mode comes with zero AskPrice. Then in constructor of OrderBookTop it throws that Exception because BidPrice is not zero and AskPrice is zero. I guess API v1's behavior is changed.