public override List <OpenOrder> GetOpenOrdersEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); BOpenOrders jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BOpenOrders>(response); //lastRequestMsg = jdata.message; //lastRequestStatus = jdata.success; if (!jdata.success) { throw new MarketAPIException("Market API Error:" + jdata.message); } List <OpenOrder> openOrders = new List <OpenOrder>(); int n = 0; foreach (var item in jdata.result) { n++; OpenOrder order = new OpenOrder { uuid = item.OrderUuid, openUuid = item.OrderUuid, orderType = item.OrderType, ticker = item.Exchange, quantity = item.Quantity, quantityRemaining = item.QuantityRemaining, price = item.Limit, openedDate = item.Opened }; if (order.orderType == "LIMIT_SELL") { order.orderType = "SELL LIMIT"; } if (order.orderType == "LIMIT_BUY") { order.orderType = "BUY LIMIT"; } openOrders.Add(order); } openOrders = openOrders.OrderByDescending(o => o.openedDate).ToList(); return(openOrders); }
public override List <OpenOrder> GetOpenOrdersEnd(string parameters, string ticker) { string response = DoKeyRequest(parameters); // BOpenOrders jdata = Newtonsoft.Json.JsonConvert.DeserializeObject<BOpenOrders>(response); //lastRequestMsg = jdata.message; //lastRequestStatus = jdata.success; // if (!jdata.success) // throw new MarketAPIException("Market API Error:" + jdata.message); string errmsg = ""; string errcaption = ""; BOpenOrders jdata = null; try { jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BOpenOrders>(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 <OpenOrder> openOrders = new List <OpenOrder>(); int n = 0; foreach (var item in jdata.result) { n++; OpenOrder order = new OpenOrder { uuid = item.OrderUuid, openUuid = item.OrderUuid, orderType = item.OrderType, ticker = item.Exchange, quantity = item.Quantity, quantityRemaining = item.QuantityRemaining, price = item.Limit, openedDate = item.Opened }; if (order.orderType == "LIMIT_SELL") { order.orderType = "SELL LIMIT"; } if (order.orderType == "LIMIT_BUY") { order.orderType = "BUY LIMIT"; } openOrders.Add(order); } openOrders = openOrders.OrderByDescending(o => o.openedDate).ToList(); return(openOrders); }