コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="portfolio"></param>
        /// <param name="riskFreeRate">Risk-free rate of return specified as a fractional value, e.g. 0.05 for 5%</param>
        /// <returns></returns>
        public static double SharpeRatio(ITimeSeries <double> portfolio, double riskFreeRate = 0)
        {
            // Check parameters
            if (riskFreeRate >= 1 || riskFreeRate < 0)
            {
                throw new ArgumentException("The risk-free rate should be a value between 0 and 1");
            }

            return(Math.Round((portfolio.AnnualisedMean() - riskFreeRate) / portfolio.AnnualisedStdDev(), DecimalDigits));
        }
コード例 #2
0
 /// <summary>
 /// Calculates the annualised return of the given time series
 /// </summary>
 /// <param name="timeseries">A time series of returns</param>
 /// <returns>Annualised return</returns>
 public static double AnnualisedReturn(ITimeSeries <double> timeseries)
 {
     return(Math.Round(timeseries.AnnualisedMean(), DecimalDigits));
 }
コード例 #3
0
 /// <summary>
 /// Calculates the portfolio active premium, i.e. the difference between the annualised mean of the portfolio and the benchmark return
 /// </summary>
 /// <param name="portfolio">Portfolio time series</param>
 /// <param name="benchmark">Benchmark time series</param>
 /// <returns>Annualised active premium</returns>
 public static double ActivePremium(ITimeSeries <double> portfolio, ITimeSeries <double> benchmark)
 {
     return(Math.Round(portfolio.AnnualisedMean() - benchmark.AnnualisedMean(), DecimalDigits));
 }