コード例 #1
0
        public decimal CalculateEma(List <TickerFormattedDto> tickers, Domain.Dtos.EcoIndex.EcoIndex lastEMA)
        {
            if (tickers.Count > 0)
            {
                decimal SMA        = tickers.Average(t => t.Last);
                decimal multiplier = 2M / (tickers.Count + 1M);

                TickerFormattedDto lastTickerFormattedDto = tickers?.LastOrDefault();

                if (lastTickerFormattedDto == null)
                {
                    return(0M);
                }

                decimal lastEMAValue = 0M;

                if (lastEMA != null)
                {
                    lastEMAValue = lastEMA.Value;
                }

                decimal EMA = (lastTickerFormattedDto.Last - lastEMAValue) * multiplier + lastEMAValue;

                if (EMA < 0)
                {
                    return(0M);
                }

                return(EMA);
            }

            return(0M);
        }
コード例 #2
0
        public void SaveSanitizedDate(TickerFormattedDto formattedDto)
        {
            RestRequest request = PrepareSaveRequest(Method.POST, ElasticApiUrlHolder.DataType.FORMATTED, formattedDto.PairType.ToString().ToLower(), formattedDto, typeof(TickerFormattedDto), formattedDto.Time);

            HandleElasticResponse(_client.Execute(request));
        }