roll_sharpe | R Documentation |
Calculate a time series of Sharpe ratios over a rolling look-back interval for an OHLC time series.
roll_sharpe(ohlc, look_back = 11)
ohlc |
An OHLC time series of prices in xts format. |
look_back |
The size of the look-back interval, equal to the number of rows of data used for aggregating the OHLC prices. |
The function roll_sharpe()
calculates the rolling Sharpe
ratio defined as the ratio of percentage returns over the look-back
interval, divided by the average volatility of percentage returns.
An xts time series with a single column and the same number of
rows as the argument ohlc
.
# Calculate rolling Sharpe ratio over SPY
sharpe_rolling <- roll_sharpe(ohlc=HighFreq::SPY, look_back=11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.