public override bool GetTickersInfo()
        {
            string text    = string.Empty;
            string address = "http://api.hitbtc.com/api/1/public/symbols";

            try {
                text = GetDownloadString(address);
            }
            catch (Exception) {
                return(false);
            }

            Tickers.Clear();
            Dictionary <string, object> res = null;

            lock (JsonParser) {
                res = (Dictionary <string, object>)JsonParser.Parse(text);
            }
            List <object> symbols = (List <object>)res["symbols"];
            int           index   = 0;

            foreach (Dictionary <string, object> s in symbols)
            {
                HitBtcTicker t = new HitBtcTicker();
                t.Index = index;
                index++;
                t.BaseCurrency   = s["currency"].ToString();
                t.MarketCurrency = s["commodity"].ToString();
                t.Step           = Convert.ToDecimal(s["step"]);
                Tickers.Add(t);
            }

            return(true);
        }
        public bool UpdateTradesStatistic(HitBtcTicker ticker, int count)
        {
            string text    = string.Empty;
            string address = string.Format("http://api.hitbtc.com//api/1/public/{0}/trades?from={1}&by=trade_id&sort=desc&start_index=0&max_results={2}&side=true", ticker.MarketName, ticker.LastTradeId, count);

            try {
                text = GetDownloadString(address);
                if (text == null)
                {
                    return(false);
                }
            }
            catch (Exception) {
                return(false);
            }

            Dictionary <string, object> res = null;

            lock (JsonParser) {
                res = (Dictionary <string, object>)JsonParser.Parse(text);
            }
            List <object> trades = (List <object>)res["trades"];

            if (trades.Count == 0)
            {
                ticker.TradeStatistic.Add(new TradeStatisticsItem()
                {
                    Time = DateTime.Now
                });
                if (ticker.TradeStatistic.Count > 5000)
                {
                    for (int i = 0; i < 100; i++)
                    {
                        ticker.TradeStatistic.RemoveAt(0);
                    }
                }
                return(true);
            }

            TradeStatisticsItem st = new TradeStatisticsItem();

            st.MinBuyPrice  = decimal.MaxValue;
            st.MinSellPrice = decimal.MaxValue;
            st.Time         = DateTime.Now;

            foreach (List <object> obj in trades)
            {
                TradeHistoryItem item   = new TradeHistoryItem();
                decimal          amount = Convert.ToDecimal(obj[1]);
                decimal          price  = Convert.ToDecimal(obj[2]);
                bool             isBuy  = obj[4].ToString().Length == 3;
                if (isBuy)
                {
                    st.BuyAmount  += amount;
                    st.MinBuyPrice = Math.Min(st.MinBuyPrice, price);
                    st.MaxBuyPrice = Math.Max(st.MaxBuyPrice, price);
                    st.BuyVolume  += amount * price;
                }
                else
                {
                    st.SellAmount  += amount;
                    st.MinSellPrice = Math.Min(st.MinSellPrice, price);
                    st.MaxSellPrice = Math.Max(st.MaxSellPrice, price);
                    st.SellVolume  += amount * price;
                }
            }
            if (st.MinSellPrice == decimal.MaxValue)
            {
                st.MinSellPrice = 0;
            }
            if (st.MinBuyPrice == decimal.MaxValue)
            {
                st.MinBuyPrice = 0;
            }
            ticker.LastTradeId            = Convert.ToInt64(((List <object>)trades.First())[0]);
            ticker.LastTradeStatisticTime = DateTime.Now;
            ticker.TradeStatistic.Add(st);
            if (ticker.TradeStatistic.Count > 5000)
            {
                for (int i = 0; i < 100; i++)
                {
                    ticker.TradeStatistic.RemoveAt(0);
                }
            }
            return(true);
        }
        public bool UpdateArbitrageOrderBook(HitBtcTicker ticker, int depth)
        {
            string text    = string.Empty;
            string address = string.Format("http://api.hitbtc.com//api/1/public/{0}/orderbook", ticker.MarketName);

            try {
                text = GetDownloadString(address);
                if (text == null)
                {
                    return(false);
                }
            }
            catch (Exception) {
                return(false);
            }

            Dictionary <string, object> res = null;

            lock (JsonParser) {
                res = (Dictionary <string, object>)JsonParser.Parse(text);
            }

            List <object> bids = (List <object>)res["bids"];
            List <object> asks = (List <object>)res["asks"];

            ticker.OrderBook.GetNewBidAsks();
            int index = 0;

            OrderBookEntry[] list = ticker.OrderBook.Bids;
            foreach (List <object> item in bids)
            {
                OrderBookEntry entry = list[index];
                entry.Value  = (decimal)(double.Parse((string)item.First()));
                entry.Amount = (decimal)(double.Parse((string)item.Last()));
                index++;
                if (index >= list.Length)
                {
                    break;
                }
            }
            index = 0;
            list  = ticker.OrderBook.Asks;
            foreach (List <object> item in asks)
            {
                OrderBookEntry entry = list[index];
                entry.Value  = (decimal)(double.Parse((string)item.First()));
                entry.Amount = (decimal)(double.Parse((string)item.Last()));
                index++;
                if (index >= list.Length)
                {
                    break;
                }
            }

            ticker.OrderBook.UpdateEntries();
            ticker.OrderBook.RaiseOnChanged(new OrderBookUpdateInfo()
            {
                Action = OrderBookUpdateType.RefreshAll
            });
            return(true);
        }