Exemple #1
0
        public override void GetMarketData()
        {
            //should be user preset
            List <CoinPairDto> coinPair = new List <CoinPairDto>
            {
                new CoinPairDto
                {
                    symbol1 = "BTC",
                    symbol2 = "USD"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "USD"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "BTC"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "EUR"
                },
                new CoinPairDto
                {
                    symbol1 = "BTC",
                    symbol2 = "EUR"
                }
            };

            List <TickerResponse> response = _cexApiClient.TickPairs("BTC", "ETH", "USD", "EUR");

            foreach (CoinPairDto pair in coinPair)
            {
                TickerResponse ticker = response.FirstOrDefault(t => t.Pair == pair.symbol1 + ":" + pair.symbol2);

                if (ticker != null)
                {
                    _elasticClient.SaveRawTickerData(GetApiPairName(pair.symbol1, pair.symbol2), ticker, typeof(TickerResponse), ticker.TimestampDate);
                    _elasticClient.SaveSanitizedDate(SanitizeTickerData(ticker, pair));
                }
            }

            _rsiManager.CalculateValue();
            _emaManager.CalculateValue();
            _forceIndexEcoIndexManager.CalculateValue();
            _coinMonitoringApiClient.InvokeRecalculation(new BaseRestRequest());
        }
Exemple #2
0
        public override void GetMarketData()
        {
            Dictionary <string, PoloniexCurrencyDto> currencies = _poloniexApiClient.GetPoloniexCurrencies();

            List <CoinPairDto> coinPair = new List <CoinPairDto>
            {
                new CoinPairDto
                {
                    symbol1 = "BTC",
                    symbol2 = "USD"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "USD"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "BTC"
                },
                new CoinPairDto
                {
                    symbol1 = "ETH",
                    symbol2 = "EUR"
                },
                new CoinPairDto
                {
                    symbol1 = "BTC",
                    symbol2 = "EUR"
                }
            };

            List <PoloniexCurrencyDto> supportedCurrencyDtos = new List <PoloniexCurrencyDto>();

            foreach (var currency in currencies)
            {
                foreach (var pair in coinPair)
                {
                    if (currency.Key.ToLower() == GetApiPairName(pair.symbol1, pair.symbol2) && supportedCurrencyDtos.FirstOrDefault(c => c.Name == GetApiPairName(pair.symbol1, pair.symbol2)) == null)
                    {
                        currency.Value.Name = currency.Key.ToLower();
                        supportedCurrencyDtos.Add(currency.Value);
                    }
                    else if (currency.Key == "BTC_ETH" && supportedCurrencyDtos.FirstOrDefault(c => c.Name == "eth_btc") == null)
                    {
                        string[] splitName = currency.Key.Split('_');
                        currency.Value.Name = splitName[1].ToLower() + "_" + splitName[0].ToLower();

                        supportedCurrencyDtos.Add(currency.Value);
                    }
                }
            }

            foreach (var pair in coinPair)
            {
                PoloniexCurrencyDto supportedCurrencyDto = supportedCurrencyDtos.FirstOrDefault(t => t.Name == GetApiPairName(pair.symbol1, pair.symbol2));
                if (supportedCurrencyDto != null)
                {
                    _elasticClient.SaveRawTickerData(GetApiPairName(pair.symbol1, pair.symbol2), supportedCurrencyDto, typeof(PoloniexCurrencyDto), DateTime.Now);
                    _elasticClient.SaveSanitizedDate(SanitizeTickerData(supportedCurrencyDto, pair));
                }
            }

            _rsiManager.CalculateValue();
            _emaManager.CalculateValue();
            _forceIndexEcoIndexManager.CalculateValue();
            _coinMonitoringApiClient.InvokeRecalculation(new BaseRestRequest());
        }