public override Dictionary <string, MarketCurrent> GetMarketCurrentEnd(string parameters) { string response = DoPublicRequest(parameters); BMarket24HourSummary jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BMarket24HourSummary>(response); if (!jdata.success) { throw new MarketAPIException("Market API Error:" + jdata.message); } Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in jdata.result) { Pair iteminfo = new Pair(Helper.ToStandartTicker(item.MarketName)); MarketCurrent mkt = new MarketCurrent(); mkt.ticker = Helper.ToStandartTicker(item.MarketName); mkt.lastPrice = item.Last; double prevPrice = item.PrevDay; mkt.volumeBtc = 0; mkt.volumeUSDT = 0; if (iteminfo.currency1 == "BTC") { mkt.volumeBtc = item.BaseVolume; } else if (iteminfo.currency1 == "USDT") { mkt.volumeUSDT = item.BaseVolume; } // mkt.volumeBtc = item.Volume; if (item.PrevDay != 0) { mkt.percentChange = ((item.Last - item.PrevDay) / item.PrevDay) * 100.0; } else { mkt.percentChange = 0; } markets.Add(mkt.ticker, mkt); } return(markets); }
public override Dictionary <string, MarketCurrent> GetMarketCurrentEnd(string parameters) { string response = DoPublicRequest(parameters); // BMarket24HourSummary jdata = Newtonsoft.Json.JsonConvert.DeserializeObject<BMarket24HourSummary>(response); // if (!jdata.success) // throw new MarketAPIException("Market API Error:" + jdata.message); string errmsg = ""; string errcaption = ""; BMarket24HourSummary jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BMarket24HourSummary>(response); if (!jdata.success) { errcaption = "Market API Error:"; errmsg = jdata.message; } if (jdata.result == null) { errcaption += "Market API Error:"; errmsg += "DataResult=Null >>> " + response; } } catch (Exception ex) { errcaption = "Parsing Response Error:"; errmsg = ex.Message + " >>> " + response; } if (errmsg != "") { throw new MarketAPIException(errcaption + " >> " + errmsg); } Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in jdata.result) { Pair iteminfo = new Pair(Helper.ToStandartTicker(item.MarketName)); MarketCurrent mkt = new MarketCurrent(); mkt.ticker = Helper.ToStandartTicker(item.MarketName); mkt.lastPrice = item.Last; double prevPrice = item.PrevDay; mkt.volumeBtc = 0; mkt.volumeUSDT = 0; if (iteminfo.currency1 == "BTC") { mkt.volumeBtc = item.BaseVolume; } else if (iteminfo.currency1 == "USDT") { mkt.volumeUSDT = item.BaseVolume; } // mkt.volumeBtc = item.Volume; if (item.PrevDay != 0) { mkt.percentChange = ((item.Last - item.PrevDay) / item.PrevDay) * 100.0; } else { mkt.percentChange = 0; } markets.Add(mkt.ticker, mkt); } return(markets); }