コード例 #1
0
ファイル: Poloniex.cs プロジェクト: SuffArt/BitWhiskey
        public override AllOrders GetOrderBookEnd(string parameters)
        {
            string response = DoPublicRequest(parameters);

            CheckResponseAndThrow(response);

            POrderBook items  = Newtonsoft.Json.JsonConvert.DeserializeObject <POrderBook>(response);
            AllOrders  orders = new AllOrders();

            orders.buyOrders  = new List <BuyOrder>();
            orders.sellOrders = new List <SellOrder>();
            int n = 0;

            foreach (var item in items.bids)
            {
                n++;
                orders.buyOrders.Add(new BuyOrder {
                    quantity = Helper.ToDouble(item[1].ToString()), rate = Helper.ToDouble((string)item[0])
                });
            }
            n = 0;
            foreach (var item in items.asks)
            {
                n++;
                orders.sellOrders.Add(new SellOrder {
                    quantity = Helper.ToDouble(item[1].ToString()), rate = Helper.ToDouble((string)item[0])
                });
            }
            orders.sellOrders = orders.sellOrders.OrderBy(o => o.rate).ToList();
            orders.buyOrders  = orders.buyOrders.OrderByDescending(o => o.rate).ToList();

            return(orders);
        }
コード例 #2
0
        public override AllOrders GetOrderBookEnd(string parameters)
        {
            string response = DoPublicRequest(parameters);

            CheckResponseAndThrow(response);

            POrderBook jdata = null;

            try
            {
                jdata = Newtonsoft.Json.JsonConvert.DeserializeObject <POrderBook>(response);
            }
            catch (Exception ex)
            { throw new MarketAPIException("Parsing Response Error" + " >>>> " + ex.Message + " ## Response: ## " + response); }


            AllOrders orders = new AllOrders();

            orders.buyOrders  = new List <BuyOrder>();
            orders.sellOrders = new List <SellOrder>();
            int n = 0;

            foreach (var item in jdata.bids)
            {
                n++;
                orders.buyOrders.Add(new BuyOrder {
                    quantity = Helper.ToDouble(item[1].ToString()), rate = Helper.ToDouble((string)item[0])
                });
            }
            n = 0;
            foreach (var item in jdata.asks)
            {
                n++;
                orders.sellOrders.Add(new SellOrder {
                    quantity = Helper.ToDouble(item[1].ToString()), rate = Helper.ToDouble((string)item[0])
                });
            }
            orders.sellOrders = orders.sellOrders.OrderBy(o => o.rate).ToList();
            orders.buyOrders  = orders.buyOrders.OrderByDescending(o => o.rate).ToList();

            return(orders);
        }