sharpe: Sharpe Ratio

Description Usage Arguments Value Examples

View source: R/sharpe.R

Description

Calculates Sharpe ratio from vector of gains or prices. The formula is: (mean(gains) - rf) / sd(gains), where rf is some risk-free rate of return.

Usage

1
sharpe(gains = NULL, prices = NULL, rf = 0)

Arguments

gains

Numeric vector of gains.

prices

Numeric vector of prices.

rf

Numeric value.

Value

Numeric value.

Examples

1
2
3
4
5
6
# Simulate daily 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(stock.gains)

vandomed/stocks documentation built on July 22, 2020, 3:25 a.m.