/// <summary> /// 根据用户ID 和品种编号,查询当前品种 所有还在队列中的委托单。 /// </summary> /// <param name="userId"></param> /// <param name="_coinSymbol"></param> /// <returns></returns> public static List <Order> OureyAllOrder(long userId, string _coinSymbol) { string URL = "exchange/order/un_deal/{memberId}/{productNum}"; try { var r = new RestRequest(URL, Method.GET); r.AddUrlSegment("memberId", userId); r.AddUrlSegment("productNum", _coinSymbol); IRestResponse response = HttpRestQurey(r); if (response == null) { return(null); } string json = response.Content; response_Order ro = JsonConvert.DeserializeObject <response_Order>(json); if (ro != null && ro.code == 0 && ro.data != null) { return(ro.data); } return(null); }catch { return(null); } }
/// <summary> /// 请求卖出 /// </summary> /// <param name="_userId">用户ID</param> /// <param name="_symbol">产品编号</param> /// <param name="_vol">数量</param> /// <param name="_price">价格</param> /// <returns>返回报单信息---Json 格式</returns> public static request_OrderLimit QureySell(long _userId, string _coinSymbol, string _vol, string _price, string orderId = "") { string URL = "exchange/order/trade"; try { request_OrderLimit orderLimit = new request_OrderLimit(); orderLimit.baseSymbol = "CNY"; orderLimit.coinSymbol = _coinSymbol; orderLimit.symbol = _coinSymbol + "/CNY"; orderLimit.direction = request_OrderLimit.direction_SELL; //卖出 orderLimit.type = request_OrderLimit.type_LIMIT; //限价 orderLimit.orderCate = request_OrderLimit.orderCate_TRADE; //交易 orderLimit.orderMemberType = request_OrderLimit.orderMemberType_ROBOT; //机器人 if (orderId == "") { orderLimit.orderId = ProduceOrderID.GetOrderID(EnumBuySellType.转让); //订单ID } else { orderLimit.orderId = orderId; } orderLimit.memberId = _userId; //用户ID orderLimit.price = _price; //价格 orderLimit.amount = _vol; //数量 var jsonReq = JsonConvert.SerializeObject(orderLimit); RestRequest r = new RestRequest(URL, Method.POST); r.AddParameter("application/json", jsonReq, ParameterType.RequestBody); IRestResponse restResponse = HttpRestQurey(r); if (restResponse == null) { return(null); } string json = restResponse.Content; response_Order rol = JsonConvert.DeserializeObject <response_Order>(json); if (rol != null && rol.code == 0) { return(orderLimit); } return(null); }catch { return(null); } }