public bool ReloadBooking() { var bookings = client.GetOrderBooking(pairs.ToList(), 10); if (bookings != null && bookings.Any()) { var tables = new List <BookingTable>(); foreach (var b in bookings) { var table = new BookingTable(); string[] spiltIndex = b.Pair.Split('_'); table.Currency = spiltIndex[1]; table.Coin = spiltIndex[0]; table.Pair = b.Pair; table.Platform = this.platform; table.Asks = JsonConvert.SerializeObject(b.Ask); table.Bids = JsonConvert.SerializeObject(b.Bid); tables.Add(table); } var dao = new BookingTableDao(); dao.InsertOrUpdate(tables); } return(true); }
public bool ReloadBooking() { var bookings = new List <BookingTable>(); foreach (var aPair in pairs) { var depth = client.GetOrderBook(aPair, 5); var res = depth["result"] as JsonObject; var xrp = res[aPair] as JsonObject; var asks = xrp["asks"].ToString(); var bids = xrp["bids"].ToString(); int spiltIndex = (int)Math.Ceiling((double)aPair.Length / 2); string coin = aPair.Substring(0, spiltIndex); string currency = aPair.Substring(spiltIndex, aPair.Length - spiltIndex); if (coin.StartsWith("X")) { coin = coin.Substring(1); } if (currency.StartsWith("Z")) { currency = currency.Substring(1); } var booking = new BookingTable() { Pair = aPair, Coin = coin.Replace("XBT", "BTC"), Currency = currency, Platform = this.platform, Asks = asks, Bids = bids }; bookings.Add(booking); } var dao = new BookingTableDao(); dao.InsertOrUpdate(bookings); return(true); }