using System;
using System.Collections.Generic;
using System.Linq;
using TradeBlotter.Views;
using MarketData.MarketDataModel;
using MarketData.Generator;
using Microsoft.Research.DynamicDataDisplay.DataSources;
using MarketData.Numerical;

namespace TradeBlotter.Model
{
  public class StopLimitCompositeModel
  {
    private StopLimitCompositeModel()
    {
    }
    public static CompositeDataSource CreateCompositeDataSource(StopLimits stopLimits)
    {
      if(null==stopLimits) return null;
      CompositeDataSource compositeDataSource;
      var xData=new EnumerableDataSource<DateTime>(stopLimits.Select(x => x.EffectiveDate.Date));
      xData.SetXMapping(x => (x.Ticks/10000000000.0));
      var yData=new EnumerableDataSource<double>(stopLimits.Select(y => y.StopPrice));
      yData.SetYMapping(y => y);
      compositeDataSource=xData.Join(yData);
      return compositeDataSource;
    }
  }
}
