Description Usage Arguments Value Note Author(s) References See Also Examples
Calculate Sharpe ratio based on a vector of investment 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 any time interval).
1 2 3 4 | sharpe.ratio(gains = NULL,
prices = NULL,
rf = 0,
nas = FALSE)
|
gains |
Numeric vector of investment gains. |
prices |
Numeric vector of investment prices (typically daily closing prices). |
rf |
Risk-free rate of return hypothetically available to the investor. |
nas |
If |
Numeric value indicating the Sharpe ratio.
Several definitions of Sharpe ratio are commonly used; this may or may not be the version you prefer.
Dane R. Van Domelen
Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.
gains.rate
, prices.rate
, mdd
,
sortino.ratio
, rrr
1 2 3 4 5 6 | # Randomly generate daily stock gains over a 5-year period
set.seed(123)
stock.gains <- rnorm(252 * 5, 0.0005, 0.01)
# Calculate Sharpe ratio using risk-free return of 0
sharpe.ratio(stock.gains)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.