public override Dictionary <string, MarketCurrent> GetMarketCurrentEnd(string parameters) { string response = DoPublicRequest(parameters); CheckResponseAndThrow(response); dynamic stuff = Newtonsoft.Json.JsonConvert.DeserializeObject(response); Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in stuff) { Pair iteminfo = new Pair(item.Name); MarketCurrent mkt = new MarketCurrent(); mkt.ticker = item.Name; mkt.lastPrice = Helper.ToDouble((string)item.Value["last"]); mkt.volumeBtc = 0; mkt.volumeUSDT = 0; if (iteminfo.currency1 == "BTC") { mkt.volumeBtc = Helper.ToDouble((string)item.Value["baseVolume"]); } else if (iteminfo.currency1 == "USDT") { mkt.volumeUSDT = Helper.ToDouble((string)item.Value["baseVolume"]); } // mkt.volumeBtc = Helper.ToDouble((string)item.Value["quoteVolume"]); mkt.percentChange = Helper.ToDouble((string)item.Value["percentChange"]) * 100.0; markets.Add(item.Name, 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); } 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); CheckResponseAndThrow(response); dynamic jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject(response); } catch (Exception ex) { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); } Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in jdata) { Pair iteminfo = new Pair(item.Name); MarketCurrent mkt = new MarketCurrent(); mkt.ticker = item.Name; mkt.lastPrice = Helper.ToDouble((string)item.Value["last"]); mkt.volumeBtc = 0; mkt.volumeUSDT = 0; if (iteminfo.currency1 == "BTC") { mkt.volumeBtc = Helper.ToDouble((string)item.Value["baseVolume"]); } else if (iteminfo.currency1 == "USDT") { mkt.volumeUSDT = Helper.ToDouble((string)item.Value["baseVolume"]); } // mkt.volumeBtc = Helper.ToDouble((string)item.Value["quoteVolume"]); mkt.percentChange = Helper.ToDouble((string)item.Value["percentChange"]) * 100.0; markets.Add(item.Name, mkt); } return(markets); }
public Dictionary <string, MarketCurrent> GetTickerCurrentEnd(string parameters) { string response = DoPublicRequest(parameters); CheckResponseAndThrow(response); Dictionary <string, YTickerCurrency> jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, YTickerCurrency> >(response); } catch (Exception ex) { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); } Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in jdata) { Pair iteminfo = new Pair(ToUITicker(item.Key)); MarketCurrent mkt = new MarketCurrent(); mkt.ticker = ToUITicker(item.Key); mkt.lastPrice = item.Value.last; mkt.ask = item.Value.sell; mkt.bid = item.Value.buy; mkt.volumeBtc = 0; mkt.volumeUSDT = 0; if (iteminfo.currency2 == "BTC") { mkt.volumeBtc = item.Value.vol; } else if (iteminfo.currency2 == "USD") { mkt.volumeUSDT = item.Value.vol; } mkt.percentChange = 0; markets.Add(ToUITicker(item.Key), mkt); } return(markets); }
public override Dictionary <string, MarketCurrent> GetMarketCurrentEnd(string parameters) { string response = DoPublicRequest(parameters); CheckResponseAndThrow(response); YInfo jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <YInfo>(response); } catch (Exception ex) { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); } Dictionary <string, MarketCurrent> markets = new Dictionary <string, MarketCurrent>(); foreach (var item in jdata.pairs) { string ticker = ToUITicker(item.Key); Pair pairinfo = new Pair(ticker); if (ticker != "RUR_BTC" && ticker != "USD_BTC" && pairinfo.currency1 != "BTC" && pairinfo.currency1 != "USD") { continue; } MarketCurrent mkt = new MarketCurrent(); mkt.ticker = ticker; mkt.lastPrice = 0; mkt.ask = 0; mkt.bid = 0; mkt.volumeBtc = 0; mkt.volumeUSDT = 0; mkt.percentChange = 0; markets.Add(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); }