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

namespace TradeBlotter.Model
{
  public class OptionStrike
  {
    public OptionStrike(DateTime expirationDate, double strikePrice)
    {
      ExpirationDate = expirationDate;
      StrikePrice = strikePrice;
    }
    public DateTime ExpirationDate { get; set; }
    public double StrikePrice { get; set; }
  }
  public class OptionStrikes : List<OptionStrike>
  {
  }
  public class OptionStrikeModel
  {
    private OptionStrikeModel()
    {
    }
    public static CompositeDataSource OptionStrikes(OptionStrikes optionStrikes)
    {
      if (null == optionStrikes) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(optionStrikes.Select(x => x.ExpirationDate.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(optionStrikes.Select(y => y.StrikePrice));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
