//更新Orderinfo表,即存储orderhistory的数据 public async void UpdateOrderHistory() { List <OrderInfo> historyOrders = await bitfinxMethed.GetOrdersHistory(100); List <OrderInfo> newHistoryOrders = SelectNewOrdersHist(historyOrders); //如果新增的记录条数不为0,则更新数据库 if (newHistoryOrders.Count != 0) { bitfinexSqlOper.AddOrderInfo(newHistoryOrders); } }
//获取订单历史 public async Task <string> GetOrdersHistory(int limit = 100) //public string GetOrdersHistory(int limit = 100) { //此函数用到数据库,以数据库为缓存 int timeStamp = GetTimeStamp(DateTime.Now); long lastUpdateTime = BitSqlOper.GetLastUpdateTime("orderinfo"); if (timeStamp - lastUpdateTime > 61) { var result = await Bitfinex.GetOrdersHistory(limit); BitSqlOper.UpdateOrderHistory(result); return(JsonConvert.SerializeObject(result)); } else { var result = BitSqlOper.GetOrderHistory(limit); return(JsonConvert.SerializeObject(result)); } }