public static void GetCryptopiaPriceData() { var exchange = GlobalData.Exchange.Cryptopia; GlobalData db = GlobalData.Instance; List <Transaction> tList = db.GetTransSubListByExchange(exchange); string URLBuilder = "https://www.cryptopia.co.nz/api/GetMarketOrderGroups/"; foreach (Transaction t in tList) { URLBuilder = URLBuilder + t.identifier + '-'; } URLBuilder = URLBuilder.Remove(URLBuilder.LastIndexOf('-')); URLBuilder = URLBuilder + "/10"; dynamic orderbook = JsonConvert.DeserializeObject(WebReq(URLBuilder)); string id; List <decimal[]> orderbookBuilderA; List <decimal[]> orderbookBuilderB; decimal[] order; foreach (var c in orderbook.Data) { id = c.TradePairId.Value.ToString(); if (db.ExistsTransaction(exchange, id)) { orderbookBuilderA = new List <decimal[]>(); orderbookBuilderB = new List <decimal[]>(); foreach (var o in c.Sell) { order = new decimal[] { 0, 0 }; order[0] = (decimal)o.Price.Value; order[1] = (decimal)o.Volume.Value; orderbookBuilderA.Add(order); } order = new decimal[] { 0, 0 }; foreach (var o in c.Buy) { order = new decimal[] { 0, 0 }; order[0] = (decimal)o.Price.Value; order[1] = (decimal)o.Volume.Value; orderbookBuilderB.Add(order); } db.UpdateTransaction(exchange, id, orderbookBuilderB, orderbookBuilderA); } } }
//Dear Reader, This is not a great way to do this. I did it this way to collect data as fast as possible so I could do analysis on it. public static void GetPoloniexTransactionData() { dynamic orderbook = JsonConvert.DeserializeObject(WebReq("https://poloniex.com/public?command=returnOrderBook¤cyPair=ALL&depth=10")); var exchange = GlobalData.Exchange.Poloniex; GlobalData db = GlobalData.Instance; string id; List <decimal[]> orderbookBuilderA; List <decimal[]> orderbookBuilderB; foreach (var c in orderbook) { id = c.Name; if (db.ExistsTransaction(exchange, id)) { orderbookBuilderA = new List <decimal[]>(); orderbookBuilderB = new List <decimal[]>(); foreach (var o in c.First.asks) { orderbookBuilderA.Add(new decimal[] { decimal.Parse(o.First.Value), (decimal)o.Last.Value }); } foreach (var o in c.First.bids) { orderbookBuilderB.Add(new decimal[] { decimal.Parse(o.First.Value), (decimal)o.Last.Value }); } db.UpdateTransaction(exchange, id, orderbookBuilderB, orderbookBuilderA); } } }