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, lookb = 11)

Arguments

ohlc

An OHLC time series of prices in xts format.

lookb

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
sharper <- roll_sharpe(ohlc=HighFreq::SPY, lookb=11)


algoquant/HighFreq documentation built on June 10, 2025, 3:54 p.m.