예제 #1
0
        private void OnClassificationRequest(IDailyClassificationInput input,
                                             ParameterListPresenter statisticsPresenter, AdxInputsPresenter adxInputsPresenter,
                                             MovingAverageInputsPresenter movingAverageInputsPresenter, SeriesIndicatorPresenter seriesPresenter)
        {
            List <DailyClassification> classifications = DoAnalysis(input.GetMethod())
                                                         .ToList();

            view.LoadClassifications(classifications);
            ClassificationStatistics statistics = GetClassificationStatistics(classifications);

            statisticsPresenter.LoadData(statistics.GetParameters());
            LoadSeriesIndicators(adxInputsPresenter, movingAverageInputsPresenter, seriesPresenter);
        }
예제 #2
0
        private void LoadSeriesIndicators(
            AdxInputsPresenter adxInputsPresenter,
            MovingAverageInputsPresenter movingAverageInputsPresenter,
            SeriesIndicatorPresenter seriesPresenter)
        {
            if (view.SelectedDay == DateTime.MinValue)
            {
                return;
            }
            CandleTimeSeries series = Context.Instance.HistoryCandleTimeSeries.Candles
                                      .Where(candle => candle.Start >= view.SelectedDay.Date.AddMonths(-3) &&
                                             candle.Start <= view.SelectedDay.Date)
                                      .ToCandleTimeSeries();
            IEnumerable <(TimeSeries, Color)> indicators = UtilsPresenter.GetIndicators(
                series: Context.Instance.HistoryCandleTimeSeries,
                indicatorPeriod: adxInputsPresenter.GetDxPeriod(),
                smoothingPeriod: adxInputsPresenter.GetMovingAveragePeriod());
            TimeSeries timeSeries = series.Candles
                                    .Select(candle => new DateValue(candle.Start, candle.Close))
                                    .ToTimeSeries();

            TimeSeries slowMovingAverage = timeSeries
                                           .GetExponentialMovingAverage(movingAverageInputsPresenter.SlowMovingAveragePeriod)
                                           .ToTimeSeries("Slow MA");
            TimeSeries mediumMovingAverage = timeSeries
                                             .GetExponentialMovingAverage(movingAverageInputsPresenter.MediumMovingAveragePeriod)
                                             .ToTimeSeries("Medium MA");
            TimeSeries fastMovingAverage = timeSeries
                                           .GetExponentialMovingAverage(movingAverageInputsPresenter.FastMovingAveragePeriod)
                                           .ToTimeSeries("Fast MA");

            seriesPresenter.LoadData(
                series: series,
                indicators: indicators,
                slowMovingAverage: slowMovingAverage,
                mediumMovingAverage: mediumMovingAverage,
                fastMovingAverage: fastMovingAverage
                );
        }
예제 #3
0
        public DailyClassificationPresenter(IDailyClassificationView view)
        {
            this.view = view;

            AdxInputsPresenter           adxInputsPresenter           = new AdxInputsPresenter(view.GetAdxInputsView());
            MovingAverageInputsPresenter movingAverageInputsPresenter = new MovingAverageInputsPresenter(view.GetMovingAverageInputView());
            ParameterListPresenter       statisticsPresenter          = new ParameterListPresenter(view.GetClassificationStatisticsView());
            SeriesIndicatorPresenter     seriesPresenter = new SeriesIndicatorPresenter(view.GetSeriesIndicatorView());

            adxInputsPresenter.DoClassificationRequest += input => OnClassificationRequest(input,
                                                                                           statisticsPresenter,
                                                                                           adxInputsPresenter,
                                                                                           movingAverageInputsPresenter,
                                                                                           seriesPresenter);
            movingAverageInputsPresenter.DoClassificationRequest += input => OnClassificationRequest(input,
                                                                                                     statisticsPresenter,
                                                                                                     adxInputsPresenter,
                                                                                                     movingAverageInputsPresenter,
                                                                                                     seriesPresenter);
            this.view.SelectedDayChanged += () => LoadSeriesIndicators(adxInputsPresenter,
                                                                       movingAverageInputsPresenter,
                                                                       seriesPresenter);
        }