Portfolio Statistics
extract_statistics.Rd
Computes the portfolio statistics for each period being considered.
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)
#> # A tibble: 50 × 11
#> .date .analysis .assessment .optimization .weights .return .volatility
#> <date> <list> <list> <list> <list> <dbl> <dbl>
#> 1 2009-02-20 <tibble> <tibble> <named list> <dbl [3]> 0.0975 0.784
#> 2 2009-02-21 <tibble> <tibble> <named list> <dbl [3]> -1.07 0.741
#> 3 2009-02-22 <tibble> <tibble> <named list> <dbl [3]> -0.685 0.756
#> 4 2009-02-23 <tibble> <tibble> <named list> <dbl [3]> 0.701 0.751
#> 5 2009-02-24 <tibble> <tibble> <named list> <dbl [3]> -1.12 0.756
#> 6 2009-02-25 <tibble> <tibble> <named list> <dbl [3]> 0.424 0.768
#> 7 2009-02-26 <tibble> <tibble> <named list> <dbl [3]> 0.617 0.756
#> 8 2009-02-27 <tibble> <tibble> <named list> <dbl [3]> -0.302 0.758
#> 9 2009-02-28 <tibble> <tibble> <named list> <dbl [3]> -0.950 0.714
#> 10 2009-03-01 <tibble> <tibble> <named list> <dbl [3]> -1.62 0.722
#> # … with 40 more rows, and 4 more variables: .skewness <dbl>, .kurtosis <dbl>,
#> # .value_at_risk <dbl>, .expected_shortfall <dbl>