extract_statistics: Portfolio Statistics

View source: R/extract_performance.R

extract_statisticsR Documentation

Portfolio Statistics

Description

Computes the portfolio statistics for each period being considered.

Usage

extract_statistics(.data)

Arguments

.data

A tibble from the snoop_rolling.

Value

A tibble with 7 new columns: .weights, .return and .volatility, .skewness and .kurtosis, .value_at_risk and .expected_shortfall.

Examples

stocks <- tibble::tibble(
  time = as.Date('2009-01-01') + 0:99,
  X    = rnorm(100, 0, 1),
  Y    = rnorm(100, 0, 2),
  Z    = rnorm(100, 0, 4)
)

roll <- construct_rolling_infrastructure(stocks, .initial = 50)

rebal <- construct_rebalance_infrastructure(roll)

# Mean Variance Strategy
mu_sigma <- function(.data) {
  list(mu = colMeans(.data), sigma = stats::cov(.data))
}

optimal <- rebalance_portfolio(rebal, mu_sigma, .strategy = "mean_variance")

extract_statistics(optimal)

Reckziegel/snoop documentation built on July 1, 2022, 5:32 a.m.