private /*async Task<*/ Dictionary <string, TransforfField> /*>*/ GetBittrexOrderBook(Dictionary <string, TransformInfo> arg) { //return await new Task<Dictionary<string, TransforfField>>(delegate //{ BittrexIdenteti Ident = new BittrexIdenteti(); Ident.Data.result = Ident.Data.result.Where(d => arg.ContainsKey(d.MarketCurrency)).ToList(); Dictionary <string, TransforfField> temp = new Dictionary <string, TransforfField>(); bool flag; foreach (var i in Ident.Data.result) { try { flag = arg[i.MarketCurrency].Data.Status; } catch (KeyNotFoundException) { continue; } if (flag == false) { continue; } string site = String.Format("https://bittrex.com/api/v1.1/public/getorderbook?market={0}&type=both&depth=10", i.MarketName); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(site); WebResponse resp = req.GetResponse(); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); var a = JsonConvert.DeserializeObject <Field>(str); temp.Add(FormatString(i.MarketName), new TransforfField(a.result.sell, a.result.buy)); } } return(temp); //}); }
private async Task <Dictionary <string, TransforfField> > GetBittrexOrderBook() { return(await new Task <Dictionary <string, TransforfField> >(delegate { BittrexIdenteti Ident = new BittrexIdenteti(); BittrexCoinInfo CoinInfo = new BittrexCoinInfo(); Dictionary <string, TransforfField> temp = new Dictionary <string, TransforfField>(); bool flag; foreach (var i in Ident.Data.result) { try { flag = CoinInfo.Data[i.MarketName.Split('-')[1]].Data.Status; } catch (KeyNotFoundException) { continue; } if (flag == false) { continue; } string site = String.Format("https://bittrex.com/api/v1.1/public/getorderbook?market={0}&type=both&depth=10", i.MarketName); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(site); WebResponse resp = req.GetResponse(); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); var a = JsonConvert.DeserializeObject <Field>(str); temp.Add(i.MarketName, new TransforfField(a.result.sell, a.result.buy)); } } return temp; })); }