Exemple #1
0
        public override List <Trade> GetTradeHistoryEnd(string parameters)
        {
            string response = DoPublicRequest(parameters);

            BTradeHistory jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BTradeHistory>(response);

            //lastRequestMsg = jdata.message;
            //lastRequestStatus = jdata.success;
            if (!jdata.success)
            {
                throw new MarketAPIException("Market API Error:" + jdata.message);
            }

            List <Trade> tradeHistory = new List <Trade>();
            int          n            = 0;

            foreach (var item in jdata.result)
            {
                n++;
                Trade trade = new Trade
                {
                    id        = item.Id,
                    tradeDate = item.TimeStamp,
                    quantity  = item.Quantity,
                    price     = item.Price,
                    total     = item.Total,
                    orderType = item.OrderType,
                    fillType  = item.FillType
                };

                tradeHistory.Add(trade);
            }
            tradeHistory = tradeHistory.OrderByDescending(o => o.tradeDate).ToList();
            return(tradeHistory);
        }
Exemple #2
0
        public override List <Trade> GetTradeHistoryEnd(string parameters)
        {
            string response = DoPublicRequest(parameters);

            // BTradeHistory jdata = Newtonsoft.Json.JsonConvert.DeserializeObject<BTradeHistory>(response);
            //lastRequestMsg = jdata.message;
            //lastRequestStatus = jdata.success;
            // if (!jdata.success)
            //     throw new MarketAPIException("Market API Error:" + jdata.message);

            string        errmsg     = "";
            string        errcaption = "";
            BTradeHistory jdata      = null;

            try
            {
                jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <BTradeHistory>(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 <Trade> tradeHistory = new List <Trade>();
            int          n            = 0;

            foreach (var item in jdata.result)
            {
                n++;
                Trade trade = new Trade
                {
                    id        = item.Id,
                    tradeDate = item.TimeStamp,
                    quantity  = item.Quantity,
                    price     = item.Price,
                    total     = item.Total,
                    orderType = item.OrderType,
                    fillType  = item.FillType
                };

                tradeHistory.Add(trade);
            }
            tradeHistory = tradeHistory.OrderByDescending(o => o.tradeDate).ToList();
            return(tradeHistory);
        }