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

namespace TradeBlotter.Model
{
  public class PortfolioTradeModel
  {
    private PortfolioTradeModel()
    {
    }
    public static CompositeDataSource PortfolioTrades(PortfolioTrades portfolioTrades)
    {
      if (null == portfolioTrades || 0 == portfolioTrades.Count) return new CompositeDataSource();
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(portfolioTrades.Select(x => x.TradeDate.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(portfolioTrades.Select(y => y.Price));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
