Exemple #1
0
        public GetChartDataResponse GetChartData(GetChartDataRequest request)
        {
            RestRequest restRequest = new RestRequest("Trade/GetChartData", Method.POST);

            restRequest.AddJsonBody(request);

            IRestResponse <GetChartDataResponse> response = _client.Execute <GetChartDataResponse>(restRequest);

            return(response.Data);
        }
Exemple #2
0
        public ChartData GetChartData(GetChartDataRequest request)
        {
            try
            {
                var stringData = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "dal/data.txt"));
                var data       = JsonSerializer.Deserialize <ChartData>(stringData);

                data.ListDataPerDay = data.ListDataPerDay.Where(x => x.Day.Date >= request.From.Date && x.Day.Date <= request.To.Date);

                return(data);
            }
            catch (Exception ex)
            {
                //write to log
                return(null);
            }
        }
Exemple #3
0
        public JsonResult GetChartData(GetChartDataRequest request)
        {
            GetChartDataResponse response = _scheduleFacade.GetChartData(request);

            ChartData chartResponse = new ChartData
            {
                ChartPointsMain = response.ChartPoints,
                Name            = request.Symbol1 + "/" + request.Symbol2
            };

            if (response.EcoPoints.ContainsKey(1) && request.ShowRSI)
            {
                chartResponse.RSI = new EcoIndexChart
                {
                    Name   = "RSI",
                    Points = response.EcoPoints[1]
                };
            }

            if (response.EcoPoints.ContainsKey(2) && request.ShowEMA)
            {
                chartResponse.EMA = new EcoIndexChart
                {
                    Name   = "EMA",
                    Points = response.EcoPoints[2]
                };
            }

            if (response.EcoPoints.ContainsKey(3) && request.ShowFI)
            {
                chartResponse.ForceIndex = new EcoIndexChart
                {
                    Name   = "ForceIndex",
                    Points = response.EcoPoints[3]
                };
            }

            return(Json(chartResponse, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public ChartData GetChartData(GetChartDataRequest request)
        {
            var res = _dalManager.GetChartData(request);

            return(res);
        }
        public GetChartDataResponse GetChartData(GetChartDataRequest request)
        {
            GetFormattedDataRequest formattedDataRequest = new GetFormattedDataRequest
            {
                PatterName   = request.ExchangeType == 1 ? "cex_formatted" : "poloniex_formatted",
                From         = DateTime.Now.AddMinutes(-25),
                To           = DateTime.Now,
                ExchangeType = request.ExchangeType,
                size         = 300,
                PairType     = (int)ResolvePairTypeEnum(request.Symbol1, request.Symbol2)
            };

            GetFormattedDataResponse  formattedDataResponse = _elasticClient.GetFormattedTickers(formattedDataRequest);
            List <TickerFormattedDto> tickers = formattedDataResponse.hits.hits.Select(r => r._source).ToList();

            GetChartDataResponse response = new GetChartDataResponse
            {
                Success     = true,
                Error       = "",
                ChartPoints = new List <ChartPoint>(),
                EcoPoints   = new Dictionary <int, List <EcoPoint> >
                {
                    { 1, new List <EcoPoint>() },
                    { 2, new List <EcoPoint>() },
                    { 3, new List <EcoPoint>() }
                }
            };

            foreach (TickerFormattedDto corTicker in tickers)
            {
                response.ChartPoints.Add(new ChartPoint
                {
                    High   = corTicker.High,
                    Last   = corTicker.Last,
                    Low    = corTicker.Low,
                    Time   = corTicker.Time,
                    Volume = corTicker.Volume
                });
            }
            string pairName = request.Symbol1.ToLower() + "_" + request.Symbol2.ToLower();

            if (pairName == "btc_eth")
            {
                pairName = "eth_btc";
            }

            if (request.ShowRSI)
            {
                GetEcoIndexDataRequest ecoIndexDataRequest = new GetEcoIndexDataRequest
                {
                    PatterName = request.ExchangeType == 1 ? "cex_eco_index" : "poloniex_eco_index",
                    From       = DateTime.Now.AddMinutes(-25),
                    To         = DateTime.Now,
                    EcoIndexNr = (int)EcoIndexEnum.RSI,
                    size       = 300,
                    PairName   = pairName
                };

                GetEcoIndexDataResponse ecoIndexDataResponse = _elasticClient.GetEcoIndexData(ecoIndexDataRequest);
                List <EcoIndex>         ecoIndexDtos         = ecoIndexDataResponse.hits.hits.Select(r => r._source).ToList();

                List <EcoPoint> rsiPoints = response.EcoPoints.FirstOrDefault(k => k.Key == (int)EcoIndexEnum.RSI).Value;

                foreach (var ecoIndex in ecoIndexDtos)
                {
                    rsiPoints.Add(new EcoPoint
                    {
                        Id    = (int)EcoIndexEnum.RSI,
                        Time  = ecoIndex.Time,
                        Value = ecoIndex.Value
                    });
                }
            }

            if (request.ShowEMA)
            {
                GetEcoIndexDataRequest ecoIndexDataRequest = new GetEcoIndexDataRequest
                {
                    PatterName = request.ExchangeType == 1 ? "cex_eco_index" : "poloniex_eco_index",
                    From       = DateTime.Now.AddMinutes(-25),
                    To         = DateTime.Now,
                    EcoIndexNr = (int)EcoIndexEnum.EMA,
                    size       = 300,
                    PairName   = pairName
                };

                GetEcoIndexDataResponse ecoIndexDataResponse = _elasticClient.GetEcoIndexData(ecoIndexDataRequest);
                List <EcoIndex>         ecoIndexDtos         = ecoIndexDataResponse.hits.hits.Select(r => r._source).ToList();

                List <EcoPoint> emaPoints = response.EcoPoints.FirstOrDefault(k => k.Key == (int)EcoIndexEnum.EMA).Value;

                foreach (var ecoIndex in ecoIndexDtos)
                {
                    emaPoints.Add(new EcoPoint
                    {
                        Id    = (int)EcoIndexEnum.EMA,
                        Time  = ecoIndex.Time,
                        Value = ecoIndex.Value
                    });
                }
            }

            if (request.ShowFI)
            {
                GetEcoIndexDataRequest ecoIndexDataRequest = new GetEcoIndexDataRequest
                {
                    PatterName = request.ExchangeType == 1 ? "cex_eco_index" : "poloniex_eco_index",
                    From       = DateTime.Now.AddMinutes(-25),
                    To         = DateTime.Now,
                    EcoIndexNr = (int)EcoIndexEnum.ForceIndex,
                    size       = 300,
                    PairName   = pairName
                };

                GetEcoIndexDataResponse ecoIndexDataResponse = _elasticClient.GetEcoIndexData(ecoIndexDataRequest);
                List <EcoIndex>         ecoIndexDtos         = ecoIndexDataResponse.hits.hits.Select(r => r._source).ToList();

                List <EcoPoint> emaPoints = response.EcoPoints.FirstOrDefault(k => k.Key == (int)EcoIndexEnum.ForceIndex).Value;

                foreach (var ecoIndex in ecoIndexDtos)
                {
                    emaPoints.Add(new EcoPoint
                    {
                        Id    = (int)EcoIndexEnum.ForceIndex,
                        Time  = ecoIndex.Time,
                        Value = ecoIndex.Value
                    });
                }
            }

            return(response);
        }
Exemple #6
0
        public ActionResult <ChartData> GetChartData(GetChartDataRequest request)
        {
            var data = _chartManager.GetChartData(request);

            return(data);
        }
Exemple #7
0
        public GetChartDataResponse GetChartData(GetChartDataRequest request)
        {
            GetChartDataResponse response = _client.GetChartData(request);

            return(response);
        }
Exemple #8
0
        public GetChartDataResponse GetChartData([FromBody] GetChartDataRequest request)
        {
            GetChartDataResponse response = _tradeFacade.GetChartData(request);

            return(response);
        }