The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

End-to-End Workflow

library(finlabR)

1. Load prices and compute returns

prices <- get_example_prices()
rets <- calc_returns(prices[, -1], method = "log")

2. Correlation analysis across assets

cor_mat <- asset_correlation(rets)
cor_mat[1:3, 1:3]
#>              EQ1          EQ2         EQ3
#> EQ1  1.000000000  0.006707895 -0.02176708
#> EQ2  0.006707895  1.000000000 -0.01836227
#> EQ3 -0.021767078 -0.018362273  1.00000000

3. Mean-variance optimization

ef <- mvo_efficient_frontier(rets, n = 25, rf = 0.02)
max_sharpe <- mvo_max_sharpe(rets, rf = 0.02)
min_var <- mvo_min_variance(rets)

4. CVaR and risk parity portfolios

cvar <- cvar_minimize(rets, alpha = 0.95)
rp <- risk_parity_weights(stats::cov(rets))

5. Regime clustering and asset clustering

regimes <- market_regime_kmeans(rets, k = 3, window = 60)
clusters <- asset_clustering(rets, method = "kmeans", reduce = "pca", k = 3)

6. Risk analytics

var_cvar(rets, alpha = 0.95)
#>     asset         VaR        CVaR
#> 1     EQ1 0.018348805 0.023653700
#> 2     EQ2 0.015278103 0.019074063
#> 3     EQ3 0.024202496 0.029746296
#> 4    CMD1 0.025586040 0.032379499
#> 5 CRYPTO1 0.086507269 0.107429605
#> 6   BOND1 0.005233202 0.006338586

7. Monte Carlo and option pricing

paths <- simulate_gbm_paths(100, 0.08, 0.2, time_horizon = 1, n_steps = 252, n_sims = 500)
price_option_mc(100, 100, 0.02, 0.2, time_to_maturity = 1, n_sims = 10000)
#> $price
#> [1] 9.065308
#> 
#> $std_error
#> [1] 0.1414864
price_option_binomial(100, 100, 0.02, 0.2, time_to_maturity = 1, n_steps = 200, american = TRUE)
#> [1] 8.906137

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.