Пример #1
0
        /// <summary>
        /// Berechnet die ReturnRiskRatio und legt das Ergebnis in einem neuen Datencontainer ab.
        /// </summary>
        /// <param name="source">Datensatz, von dem die ReturnRiskRatio gebildet werden soll</param>
        /// <param name="nRange">Anzahl der einzubeziehenden Daten pro Berechnung</param>
        /// <returns>Neuer DatenContainer mit den Ergebnisdaten</returns>
        public static DataContainer CreateFrom(DataContainer source, int nRange)
        {
            //DataContainer sourceperf   = RelativePerformance.CreateFrom(source);
            DataContainer sourcechange = RelativeChange.CreateFrom(source);
            DataContainer changemovavg = MovingAverage.CreateFrom(sourcechange, nRange);
            DataContainer volatility   = Volatility.CreateFrom(sourcechange, nRange);
            DataContainer result       = new DataContainer();

            //WorkDate historydate = volatility.OldestDate.Clone() - (int)nRange;
            WorkDate workdate = volatility.OldestDate.Clone();

            for (; workdate <= volatility.YoungestDate; workdate++ /*, historydate++*/)
            {
                double dReturn = changemovavg[workdate]; //sourceperf[workdate] - sourceperf[historydate];
                double dRisk   = volatility[workdate];   // Standardabweichung
                //result[workdate] = dReturn  / (dRisk + 1.0);
                result[workdate] = dReturn - dRisk;
            }

            return(result);
        }