Calculate Sharpe ratio based on a vector of gains (or prices). The formula is: (mean(gains) - rf) / sd(gains). Here rf is some risk-free rate of return, and gains is a vector of gains (usually daily, but could be weekly, monthly, or some other time interval). User can specify prices or gains.
Usage
sharpe(gains = NULL, prices = NULL, rf = 0)
Arguments
gains
Numeric vector of gains.
prices
Numeric vector of stock prices (typically daily closing prices).
rf
Risk-free rate of return hypothetically available to the investor.
Details
NA
Value
Numeric value indicating the Sharpe ratio.
Note
Several definitions of Sharpe ratio are commonly used; this may or may not be the version you prefer.
Author(s)
Dane R. Van Domelen
References
Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.
See Also
sortino, rrr, mdd
Examples
# Randomly generate daily stock gains over a 5-year period
stock.gains <- rnorm(251*5, 0.0005, 0.01)
# Calculate Sharpe ratio using risk-free return of 0
sharpe(stock.gains)