public Dictionary <string, TransformInfo> GetInfo() { string site = "https://api.livecoin.net/info/coinInfo"; Dictionary <string, TransformInfo> temp; WebResponse resp = LiveCoinGetRequst.Requst(site); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); if (!str.Contains("Error 502")) { var res = JsonConvert.DeserializeObject <Fields>(str); temp = res.info.ToDictionary(d => d.symbol, x => new TransformInfo(x)); } else { temp = new Dictionary <string, TransformInfo>(); } } return(temp); }
public TransformOrders GetOrder(string MainCoinName, string SecondCoinName) { if (MainCoinName == "USDT") { return(new TransformOrders()); } string site = String.Format("https://api.livecoin.net/exchange/order_book?currencyPair={0}", SecondCoinName + "/" + MainCoinName); List <List <decimal> > asks = new List <List <decimal> >(); List <List <decimal> > bids = new List <List <decimal> >(); try { WebResponse resp = LiveCoinGetRequst.Requst(site); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); dynamic res = JsonConvert.DeserializeObject(str); if (res.success == null) { foreach (var item in res.asks) { string first = item.First.Value; decimal cost = Decimal.Parse(first.Replace('.', ','), NumberStyles.Float); long second = item.Last.Value; decimal weight = second; var temp = new List <decimal>(); temp.Add(cost); temp.Add(weight); asks.Add(temp); } foreach (var item in res.bids) { string first = item.First.Value; decimal cost = Decimal.Parse(first.Replace('.', ','), NumberStyles.Float); long second = item.Last.Value; decimal weight = second; var temp = new List <decimal>(); temp.Add(cost); temp.Add(weight); bids.Add(temp); } } } return(new TransformOrders(asks, bids)); } catch (WebException e) { string message = e.Message; //MessageBoxButtons buttons = MessageBoxButtons.OK; //MessageBox.Show(message, "LIVECOIN", buttons); return(new TransformOrders()); } }