예제 #1
0
        public async Task <IActionResult> Get([FromRoute] Strategy strategy, [FromQuery] Coin coin)
        {
            _logger.LogInformation($"Evaluating the strategy {strategy}");

            var productId = "BTC-EUR";

            if (strategy == Strategy.MA5)
            {
                var candles = await _ratesRepository.GetDailyRates(coin, 5);

                var currentPrice = await _ratesRepository.GetCurrentPrice(productId);

                var strategyExecutor = new MovingAverageStrategy(candles, currentPrice);
                var result           = strategyExecutor.Execute();

                _logger.LogInformation($"{candles.Count} Days Moving average is {result.ThresholdPrice}");
                _logger.LogInformation($"The current {productId} price is {currentPrice.price}");

                return(Ok(result));
            }

            return(BadRequest($"The {strategy} strategy is not implemented"));
        }
예제 #2
0
 public async Task <IList <Candle> > Get([FromRoute] Coin coin, [FromQuery] int days)
 {
     return(await _ratesRepository.GetDailyRates(coin, days));
 }