コード例 #1
0
        public override void ApplyTo(StockSerie stockSerie)
        {
            StockSerie seasonSerie = stockSerie.CalculateSeasonality();
             FloatSerie seasonCloseSerie = new FloatSerie(stockSerie.Count);

             int i = 0;
             float previousClose = stockSerie.Values.First().CLOSE;
             FloatSerie seasonClose = seasonSerie.GetSerie(StockDataType.CLOSE);
             int indexOfDate;
             int previousIndexOfDate = 0;
             foreach (StockDailyValue dailyValue in stockSerie.Values)
             {
            indexOfDate = seasonSerie.IndexOf(new DateTime(2000, dailyValue.DATE.Month, dailyValue.DATE.Day));
            if (indexOfDate != -1)
            {
               if (indexOfDate >= previousIndexOfDate)
               {
                  seasonCloseSerie[i] = previousClose * (1 + (seasonClose[indexOfDate] - seasonClose[previousIndexOfDate]) / seasonClose[previousIndexOfDate]);
               }
               previousIndexOfDate = indexOfDate;
            }
            else
            {
               seasonCloseSerie[i] = previousClose;
            }
            previousClose = seasonCloseSerie[i];
            i++;
             }

             this.series[0] = stockSerie.GetSerie(StockDataType.CLOSE).CalculateCorrelation(seasonCloseSerie, (int)parameters[0]);
             this.Series[0].Name = this.Name;
        }