/// <summary> /// 查询订单信息 /// </summary> /// <param name="orderID">订单ID -1:未完成订单,否则查询相应订单号的订单</param> /// <returns></returns> public List <Order> OrderInfo(string orderID) { List <Order> orderInfoList = null; try { Dictionary <string, string> paramList = new Dictionary <string, string>(); paramList.Add("api_key", this.api_key); paramList.Add("symbol", (tickerType == TickerType.BTC ? "btc_cny" : "ltc_cny")); paramList.Add("order_id", orderID); JObject json = Post(GET_API_URL("order_info.do"), paramList); bool queryResult = json["result"].Value <bool>(); if (queryResult) { orderInfoList = new List <Order>(); JToken token = json["orders"]; for (int i = 0; i < token.Count(); i++) { Order item = new Order(); UInt64 timeValue = token[i]["create_date"].Value <UInt64>(); item.create_date = UnixTime.FromInt32((int)(timeValue / 1000)); item.amount = token[i]["amount"].Value <decimal>(); item.avg_price = token[i]["avg_price"].Value <decimal>(); item.deal_amount = token[i]["deal_amount"].Value <decimal>(); item.order_id = token[i]["order_id"].Value <string>(); item.orders_id = token[i]["orders_id"].Value <string>(); item.price = token[i]["price"].Value <decimal>(); item.status = token[i]["status"].Value <string>(); item.symbol = token[i]["symbol"].Value <string>(); item.type = token[i]["type"].Value <string>(); orderInfoList.Add(item); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(orderInfoList); }
public List <Ticker> Load(DateTime beginTime, DateTime endTime) { List <Ticker> tickerList = new List <Ticker>(); int iTime = 0; DateTime dTime = DateTime.MinValue; Decimal high = 0, low = 0, buy = 0, sell = 0, last = 0, volume = 0; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { if (fs == null || fs.Length < 1) { return(tickerList); } using (BinaryReader binaryReader = new BinaryReader(fs)) { while (true) { try { iTime = binaryReader.ReadInt32(); dTime = UnixTime.FromInt32(iTime); high = binaryReader.ReadDecimal(); low = binaryReader.ReadDecimal(); buy = binaryReader.ReadDecimal(); sell = binaryReader.ReadDecimal(); last = binaryReader.ReadDecimal(); volume = binaryReader.ReadDecimal(); if (dTime > beginTime && dTime <= endTime) { Ticker ticker = new Ticker(); ticker.Time = dTime; ticker.High = high; ticker.Low = low; ticker.Buy = buy; ticker.Sell = sell; ticker.Last = last; ticker.Volume = volume; tickerList.Add(ticker); } } catch (EndOfStreamException ex) { break; } } } } List <Ticker> sortList = (from entry in tickerList orderby entry.Time ascending select entry).ToList(); return(sortList); }