From b9c5b7e9e59f512ccbc3e86da6969f7f102d5a54 Mon Sep 17 00:00:00 2001 From: exposurem <135@fib.co> Date: Sun, 16 Dec 2018 00:10:25 +1000 Subject: [PATCH] Binance API bad market fix --- Core/MarketAnalyzer/Binance.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Core/MarketAnalyzer/Binance.cs b/Core/MarketAnalyzer/Binance.cs index 83984e3..1b31c0d 100644 --- a/Core/MarketAnalyzer/Binance.cs +++ b/Core/MarketAnalyzer/Binance.cs @@ -68,8 +68,13 @@ namespace Core.MarketAnalyzer foreach (Newtonsoft.Json.Linq.JObject currencyTicker in jsonArray) { string marketName = currencyTicker["symbol"].ToString(); + //New variables for filtering out bad markets + float marketLastPrice = currencyTicker["lastPrice"].ToObject(); + float marketVolume = currencyTicker["volume"].ToObject(); if (marketName.EndsWith(mainMarket, StringComparison.InvariantCultureIgnoreCase)) { + if(marketLastPrice > 0 && marketVolume > 0 ) + { // Set last values in case any error occurs lastMarket = marketName; @@ -86,6 +91,12 @@ namespace Core.MarketAnalyzer markets.Add(market.Name, market); result.Add(market.Name); + } + else + { + //Let the user know that the problem market was ignored. + log.DoLogInfo("Binance - Ignoring bad market data for " + marketName); + } } }