예제 #1
0
        public TickerFormattedDto SanitizeTickerData(BaseRestResponse response, CoinPairDto pair)
        {
            PoloniexCurrencyDto ticker = (PoloniexCurrencyDto)response;

            if (ticker != null)
            {
                return(new TickerFormattedDto
                {
                    ExchangeType = ExchangeTypeEnum.Poloniex,
                    PairType = ResolvePairType(pair.symbol1, pair.symbol2),
                    High = ticker.highestBid,
                    Last = ticker.last,
                    Low = ticker.lowestAsk,
                    Time = DateTime.Now,
                    Volume = ticker.baseVolume
                });
            }

            Logger.ErrorFormat("Failed to convert Cex ticker response to sanitized data the response is null");
            throw new Exception("Failed to convert Cex ticker response to sanitized data the response is null");
        }
예제 #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());
        }