public async Task <ActionResult> GetCandleStick(GetCandleStickModel model)
    {
        var pair = await _pairsRepository.GetPairByAcronimAsync(model.Acronim.ToUpper());

        if (pair == null)
        {
            return(BadRequest("wrong pair"));
        }

        if (!model.DateStart.HasValue)
        {
            model.DateStart = System.DateTime.Now.AddDays(-2);
        }

        var candleStick = await _candleStickRepository.GetCandleStick(model, pair.SQLTableName);

        var currentCandleStick = await _candleStickRepository.GetCurrentCandleStick(pair.SQLTableName);

        var resultModel = new CandleStickViewModel()
        {
            CurrentCandleStick = currentCandleStick,
            LastCandleSticks   = candleStick
        };

        return(Ok(resultModel));
    }
Exemplo n.º 2
0
        public async Task <ActionResult> GetCandleStick(GetCandleStickModel model)
        {
            if (!model.DateStart.HasValue)
            {
                model.DateStart = System.DateTime.Now.AddDays(-2);
            }

            var candleStick = await _candleStickRepository.Get_BTC_USDT_CandleSticks(model);

            var currentCandleStick = await _candleStickRepository.GetCurrent_BTC_USDT_CandleStick();

            var resultModel = new CandleStickViewModel()
            {
                CurrentCandleStick = currentCandleStick,
                LastCandleSticks   = candleStick
            };

            return(Ok(resultModel));
        }
Exemplo n.º 3
0
        public async Task <List <CandleStickTableModel> > GetCandleStick(GetCandleStickModel model, string sqlPairName)
        {
            try
            {
                var p = new DynamicParameters();
                p.Add("datestart", model.DateStart);
                p.Add("dateend", model.DateEnd);
                p.Add("interval", model.Interval);

                var candleStick = await _db
                                  .QueryAsync <CandleStickTableModel>($"Get_{sqlPairName}_CandleStick",
                                                                      p,
                                                                      commandType : CommandType.StoredProcedure);

                return(candleStick.ToList());
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public async Task <List <CandleStickTableModel> > Get_BTC_USDT_CandleSticks(GetCandleStickModel model)
        {
            try
            {
                if (model.Interval == null)
                {
                    model.Interval = "1h";
                }

                var p = new DynamicParameters();
                p.Add("datestart", model.DateStart);
                p.Add("dateend", model.DateEnd);
                p.Add("interval", model.Interval);

                return((await _db.QueryAsync <CandleStickTableModel>("Get_BTC_USDT_CandleStick", p, commandType: CommandType.StoredProcedure))
                       .ToList());
            }
            catch (Exception ex)
            {
                return(null);
            }
        }