Esempio n. 1
0
        public MarketOrderBook returnMarketOrderBook(Pair pair, Int32 depth)
        {
            String url = String.Concat(GetUrl
                                       , "returnOrderBook&currencyPair="
                                       , pair.ToString()
                                       , "&depth="
                                       , depth);

            WebClient client = new WebClient();

            var content = client.DownloadString(url);
            RawMarketOrderBook rMarketBook = JsonConvert.DeserializeObject <RawMarketOrderBook>(content);

            return(new MarketOrderBook(rMarketBook, pair));
        }
Esempio n. 2
0
        public MarketOrderBook(RawMarketOrderBook rbook, Pair ppair)
        {
            Bids = new List <MarketOrder>();
            Asks = new List <MarketOrder>();
            foreach (var item in rbook.Raw_bids.OrderByDescending(p => Convert.ToDouble(p[0], CultureInfo.InvariantCulture)))
            {
                Bids.Add(new MarketOrder {
                    Amount = Convert.ToDouble(item[1]), rate = Convert.ToDouble(item[0], CultureInfo.InvariantCulture)
                });
            }
            foreach (var item in rbook.Raw_asks.OrderBy(p => Convert.ToDouble(p[0], CultureInfo.InvariantCulture)))
            {
                Asks.Add(new MarketOrder {
                    Amount = Convert.ToDouble(item[1]), rate = Convert.ToDouble(item[0], CultureInfo.InvariantCulture)
                });
            }

            pair = ppair;
        }