コード例 #1
0
        private void ParseData(string str)
        {
            if (Container.StateCalculated)
            {
                return;
            }

            try
            {
                // var pairsCoin = CoinPair.GetAllPairsCoin();
                //  var namesPairsCoin = pairsCoin.Select(x => x.ToString()).ToList();
                var obj = JToken.Parse(str);

                if (!obj["stream"].ToString().Equals("!miniTicker@arr@3000ms"))
                {
                    return;
                }

                var listObj = (JArray)obj["data"];
                foreach (var item in listObj)
                {
                    var name = item["s"].ToString();

                    var coinPair = CoinPair.GetCoinPairForName(name);
                    if (coinPair == null)
                    {
                        continue;
                    }

                    //if (!namesPairsCoin.Contains(name) || usedCoin.Contains(name))
                    //{
                    //    continue;
                    //}


                    MarketData market = new MarketData();

                    market.Pair        = coinPair;
                    market.NameObmenik = "Binance";
                    market.Price       = Convert.ToDecimal(item["c"].ToString());

                    Container.AddBinanceMarket(market);
                }
            }
            catch (Exception e)
            {
            }
        }