ccxt-net / ccxt.net

CCXT.NET – CryptoCurrency eXchange Trading Library for .NET
MIT License
196 stars 65 forks source link

Binance Public API FetchTicker/FetchTickers will return an error: "An item with the same key has already been added. Key: BCH/BNB" #12

Closed aliesenli closed 4 years ago

aliesenli commented 4 years ago

Hello, I'm kinda struggling with the Binance API... My working code for Binance API stopped working. Everytime I try to fetch a ticker or multiple tickers I get the same error:

"An item with the same key has already been added. Key: BCH/BNB"

I think there's something messed up in ccxt.net source code... How can we fix this issue?

lisa3907 commented 4 years ago

Try it with v1.3.2 in the link below and let us know the result.

https://github.com/lisa3907/ccxt.net/releases/tag/v1.3.2

lisa3907 commented 4 years ago

Binance public API "exchangeInfo" error. The same market-id is occurring twice for BCH/BNB. So if the same market-id is found, I modified it to skip.

lisa3907 commented 4 years ago

https://github.com/lisa3907/ccxt.net/tree/master/sample/binance

        private static int __step_no = 0;

        private static async Task Main(string[] args)
        {
            var _api = new CCXT.NET.Binance.Public.PublicApi();

            if (__step_no == 0 || __step_no == 1)
            {
                var _tickers = await _api.FetchTickers();
                if (_tickers.success == true)
                {
                    foreach (var _t in _tickers.result)
                        Console.Out.WriteLine($"symbol: {_t.symbol}, closePrice: {_t.closePrice}");
                }
                else
                {
                    Console.Out.WriteLine($"error: {_tickers.message}");
                }
            }

            Console.Out.WriteLine("hit return to exit...");
            Console.ReadLine();
        }