using MarketData.MarketDataModel;
using MarketData.Utils;
using System;
using System.Collections.Generic;
using System.Text;

namespace MarketData.Generator.MovingAverage
{
    public class MovingAverageCrossovers : List<MovingAverageCrossover>
    {
      public MovingAverageCrossovers()
      {
      }

      public MovingAverageCrossovers(List<MovingAverageCrossover> movingAverageCrossovers)
      {
        foreach(MovingAverageCrossover movingAverageCrossover in movingAverageCrossovers)
        {
          Add(movingAverageCrossover);
        }
      }
    }

    public class MovingAverageCrossover
    {
      public enum CrossoverDirectionEnum{UpCross, DownCross, UpStart, DownStart, NeutralStart};
      public String Symbol { get; set; }
      public DateTime EventDate { get; set; }
      public CrossoverDirectionEnum CrossOverDirection {get; set;}
      public bool IsChangeInTrend { get; set; }
      public double ChangePercent { get; set; }
      public DMAPrice SlowDMAPrice { get; set; }   // the slow DMA price associated with this crossover
      public DMAPrice FastDMAPrice { get; set; }   // the fast DMA price associated with this crossover
      public double CurrentPrice {get{return SlowDMAPrice.CurrentPrice;}} // it doesn't matter if sourced from slow or fast  since they both refer to the same underlying price
      public override string ToString()
      {
        StringBuilder sb = new StringBuilder();
        sb.Append("Symbol:").Append(Symbol);
        sb.Append(" Date:").Append(EventDate.ToShortDateString());
        sb.Append(" Direction:").Append(CrossOverDirection.ToString());
        sb.Append(" IsChangeInTrend:").Append(IsChangeInTrend.ToString());
        sb.Append(" ChangePercent:").Append(Utility.FormatNumber(ChangePercent,2));
        sb.Append(" ClosePrice:").Append(Utility.FormatCurrency(CurrentPrice));
        return sb.ToString();
      }
    }
}
