using System;
using System.Collections.Generic;
using System.Linq;
using MarketData.MarketDataModel;
using Microsoft.Research.DynamicDataDisplay.DataSources;

namespace TradeBlotter.Model
{
  public class MACDModel
  {
    private MACDModel()
    {
    }
    public static CompositeDataSource Signals(Signals signals,double anchor)
    {
      if (null == signals) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(signals.Select(x => x.SignalDate.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(signals.Select(y => anchor));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
    public static CompositeDataSource SignalSlow(MACDFastSlowSignals macdFastSlowSignals)
    {
      if (null == macdFastSlowSignals) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(macdFastSlowSignals.Select(x => x.Date.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(macdFastSlowSignals.Select(y => y.SignalSlow));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
    public static CompositeDataSource MACDSlow(MACDFastSlowSignals macdFastSlowSignals)
    {
      if (null == macdFastSlowSignals) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(macdFastSlowSignals.Select(x => x.Date.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(macdFastSlowSignals.Select(y => y.MACDSlow));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
    public static CompositeDataSource SignalFast(MACDFastSlowSignals macdFastSlowSignals)
    {
      if (null == macdFastSlowSignals) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(macdFastSlowSignals.Select(x => x.Date.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(macdFastSlowSignals.Select(y => y.SignalFast));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
    public static CompositeDataSource MACDFast(MACDFastSlowSignals macdFastSlowSignals)
    {
      if (null == macdFastSlowSignals) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(macdFastSlowSignals.Select(x => x.Date.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(macdFastSlowSignals.Select(y => y.MACDFast));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
