roll_sharpe: Calculate a time series of Sharpe ratios over a rolling...

View source: R/HighFreq.R

roll_sharpeR Documentation

Calculate a time series of Sharpe ratios over a rolling look-back interval for an OHLC time series.

Description

Calculate a time series of Sharpe ratios over a rolling look-back interval for an OHLC time series.

Usage

roll_sharpe(ohlc, look_back = 11)

Arguments

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.

Details

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.

Value

An xts time series with a single column and the same number of rows as the argument ohlc.

Examples

# Calculate rolling Sharpe ratio over SPY
sharpe_rolling <- roll_sharpe(ohlc=HighFreq::SPY, look_back=11)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.