public override List <OrderDone> GetMyOrdersHistoryEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); CheckResponseAndThrow(response); YMyTrades jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <YMyTrades>(response); } catch (Exception ex) { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); } if (jdata.@return == null) { throw new MarketAPIException("Market API error: Data=null , Response: " + response); } List <OrderDone> myOrdersHistory = new List <OrderDone>(); foreach (var pair in jdata.@return) { YMyTrade item = pair.Value; OrderDone order = new OrderDone { uuid = item.order_id.ToString(), ticker = ToUITicker(item.pair), doneDate = Helper.UnixToDateTime(item.timestamp), orderType = item.type, price = item.rate, quantity = item.amount, quantityRemaining = 0, commission = 0, totalSum = item.amount * item.rate }; if (order.orderType == "sell") { order.orderType = "S"; } if (order.orderType == "buy") { order.orderType = "B"; } myOrdersHistory.Add(order); } myOrdersHistory = myOrdersHistory.OrderByDescending(o => o.doneDate).ToList(); return(myOrdersHistory); }
public override List <OrderDone> GetMyOrdersHistoryEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); CheckResponseAndThrow(response); List <PMyTradeHistory> jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PMyTradeHistory> >(response); } catch (Exception ex) { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); } List <OrderDone> myOrdersHistory = new List <OrderDone>(); foreach (PMyTradeHistory item in jdata) { OrderDone order = new OrderDone { uuid = item.globalTradeID.ToString(), ticker = ticker, doneDate = Helper.StringToDateTimeExact(item.date), orderType = item.type, price = Helper.ToDouble(item.rate), quantity = Helper.ToDouble(item.amount), quantityRemaining = 0, commission = Helper.ToDouble(item.fee), totalSum = Helper.ToDouble(item.total) }; if (order.orderType == "LIMIT_SELL") { order.orderType = "S"; } if (order.orderType == "LIMIT_BUY") { order.orderType = "B"; } myOrdersHistory.Add(order); } myOrdersHistory = myOrdersHistory.OrderByDescending(o => o.doneDate).ToList(); return(myOrdersHistory); }
public override List <OrderDone> GetMyOrdersHistoryEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); BMyOrdersHistory jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BMyOrdersHistory>(response); //lastRequestMsg = jdata.message; //lastRequestStatus = jdata.success; if (!jdata.success) { throw new MarketAPIException("Market API Error:" + jdata.message); } List <OrderDone> myOrdersHistory = new List <OrderDone>(); int n = 0; foreach (var item in jdata.result) { n++; OrderDone order = new OrderDone { uuid = item.OrderUuid, ticker = item.Exchange, doneDate = item.TimeStamp, orderType = item.OrderType, price = item.Limit, quantity = item.Quantity, quantityRemaining = item.QuantityRemaining, commission = item.Commission, totalSum = item.Price }; if (order.orderType == "LIMIT_SELL") { order.orderType = "S"; } if (order.orderType == "LIMIT_BUY") { order.orderType = "B"; } myOrdersHistory.Add(order); } myOrdersHistory = myOrdersHistory.OrderByDescending(o => o.doneDate).ToList(); return(myOrdersHistory); }
public override List <OrderDone> GetMyOrdersHistoryEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); string errmsg = ""; string errcaption = ""; BMyOrdersHistory jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BMyOrdersHistory>(response); if (!jdata.success) { errcaption = "Market API Error:"; errmsg = jdata.message; } if (jdata.result == null) { errcaption += "Market API Error:"; errmsg += "DataResult=Null >>> " + response; } } catch (Exception ex) { errcaption = "Parsing Response Error:"; errmsg = ex.Message + " >>> " + response; } if (errmsg != "") { throw new MarketAPIException(errcaption + " >> " + errmsg); } List <OrderDone> myOrdersHistory = new List <OrderDone>(); int n = 0; foreach (var item in jdata.result) { n++; OrderDone order = new OrderDone { uuid = item.OrderUuid, ticker = item.Exchange, doneDate = item.TimeStamp, orderType = item.OrderType, price = item.Limit, quantity = item.Quantity, quantityRemaining = item.QuantityRemaining, commission = item.Commission, totalSum = item.Price }; if (order.orderType == "LIMIT_SELL") { order.orderType = "S"; } if (order.orderType == "LIMIT_BUY") { order.orderType = "B"; } myOrdersHistory.Add(order); } myOrdersHistory = myOrdersHistory.OrderByDescending(o => o.doneDate).ToList(); return(myOrdersHistory); }