public Trade[] GetTrades(string tradepair, out string rawresponse, string since = "0") { List <Trade> trades = new List <CommonLab.Trade>(); string url = ApiUrl + "/trades?market=" + tradepair; if (since != "0") { url += "&since=" + since; } rawresponse = CommonLab.Utility.GetHttpContent(url, "GET", "", _proxy); JArray obj = JArray.Parse(rawresponse); for (int i = 0; i < obj.Count; i++) { JObject trade = JObject.Parse(obj[i].ToString()); Trade t = new CommonLab.Trade(); t.TradeID = trade["tid"].ToString(); t.Amount = Convert.ToDouble(trade["amount"].ToString()); t.Price = Convert.ToDouble(trade["price"].ToString()); t.Type = CommonLab.Trade.GetType(trade["type"].ToString()); t.ExchangeTimeStamp = Convert.ToDouble(trade["date"].ToString()); //时间戳 交易所返回的 t.LocalServerTimeStamp = CommonLab.TimerHelper.GetTimeStampMilliSeconds(DateTime.Now); //本地时间戳 t.BuyOrderID = ""; //成交的交易号 t.SellOrderID = ""; //成交的交易号 trades.Add(t); } if (trades.Count > 0) { return(trades.ToArray()); } return(null); }
public Trade[] GetTrades(string tradepair, out string rawresponse, string since = "0") { List <Trade> trades = new List <CommonLab.Trade>(); string url = GetPublicApiURL("symbol=" + tradepair + "&limit=50", "api/v1/trades"); if (since != "0") { url += "&since=" + since; } rawresponse = CommonLab.Utility.GetHttpContent(url, "GET", "", _proxy); JArray obj = JArray.Parse(rawresponse); for (int i = 0; i < obj.Count; i++) { JObject trade = JObject.Parse(obj[i].ToString()); Trade t = new CommonLab.Trade(); t.TradeID = trade["id"].ToString(); t.Amount = Convert.ToDouble(trade["qty"].ToString()); t.Price = Convert.ToDouble(trade["price"].ToString()); if (Convert.ToBoolean(trade["isBuyerMaker"].ToString())) { t.Type = TradeType.Buy; } else { t.Type = TradeType.Sell; } t.ExchangeTimeStamp = Convert.ToDouble(trade["time"].ToString()); //时间戳 交易所返回的 t.LocalServerTimeStamp = CommonLab.TimerHelper.GetTimeStampMilliSeconds(DateTime.Now); //本地时间戳 t.BuyOrderID = ""; //成交的交易号 t.SellOrderID = ""; //成交的交易号 trades.Add(t); } if (trades.Count > 0) { return(trades.ToArray()); } return(null); }