Ejemplo n.º 1
0
        public Dictionary <string, List <TradingSymbol> > GetExchangeInfo()
        {
            Dictionary <string, List <TradingSymbol> > symbols = new Dictionary <string, List <TradingSymbol> >();
            string url         = Config.ApiUrl + Config.ExchangeInformation;
            string rawresponse = CommonLab.Utility.GetHttpContent(url, "GET", "", Config.Proxy);

            try
            {
                JObject JsonRaw = JObject.Parse(rawresponse);
                TimeZone        = JsonRaw["timezone"].ToString();
                ServerTimeStamp = Convert.ToDouble(JsonRaw["serverTime"].ToString());
                ServerTime      = CommonLab.TimerHelper.ConvertStringToDateTime(ServerTimeStamp / 1000);
                JArray JaSymbols = JArray.Parse(JsonRaw["symbols"].ToString());
                for (int i = 0; i < JaSymbols.Count; i++)
                {
                    TradingSymbol symbol = new TradingSymbol();
                    symbol.Ticker = new BATicker();
                    JObject jSymbol = JObject.Parse(JaSymbols[i].ToString());
                    symbol.Symbol              = jSymbol["symbol"].ToString();
                    symbol.Status              = jSymbol["status"].ToString();
                    symbol.BaseAsset           = jSymbol["baseAsset"].ToString();
                    symbol.baseAssetPrecision  = Convert.ToInt32(jSymbol["baseAssetPrecision"].ToString());
                    symbol.QuoteAsset          = jSymbol["quoteAsset"].ToString();
                    symbol.quoteAssetPrecision = Convert.ToInt32(jSymbol["quotePrecision"].ToString());
                    JArray Jafilters = JArray.Parse(jSymbol["filters"].ToString());
                    for (int j = 0; j < Jafilters.Count; j++)
                    {
                        switch (Jafilters[j]["filterType"].ToString())
                        {
                        case "PRICE_FILTER":
                            symbol.minPrice = Convert.ToDouble(Jafilters[j]["minPrice"].ToString());
                            symbol.maxPrice = Convert.ToDouble(Jafilters[j]["maxPrice"].ToString());
                            break;

                        case "LOT_SIZE":
                            symbol.minQty = Convert.ToDouble(Jafilters[j]["minQty"].ToString());
                            symbol.maxQty = Convert.ToDouble(Jafilters[j]["maxQty"].ToString());
                            break;
                        }
                    }
                    if (!symbols.ContainsKey(symbol.QuoteAsset))
                    {
                        symbols.Add(symbol.QuoteAsset, new List <TradingSymbol>());
                    }
                    symbols[symbol.QuoteAsset].Add(symbol);
                    Symbols.Add(symbol);
                }
            }
            catch
            {
            }
            SymbolsClassByQuoteAsset = symbols;
            return(symbols);
        }
Ejemplo n.º 2
0
        public double CacCoinIndex()
        {
            double index        = 0;
            int    count        = 0;
            double sumpricediff = 0;

            foreach (string key in Config.strategyConfig.SelectedSymbols)
            {
                count++;
                TradingSymbol t = Config.Exchange.Symbols.Where(item => item.Symbol == key).ToArray()[0];
                sumpricediff += t.Ticker.Last / t.HisTicker.Last;
            }
            if (count > 0)
            {
                index = sumpricediff / count;
            }
            return(Math.Round(index, 8));
        }