Description
Portfolio Analytics and Simulation Toolkit.
Description
Tools for portfolio construction and risk analytics, including mean-variance optimization, conditional value at risk (expected shortfall) minimization, risk parity, regime clustering, correlation analysis, Monte Carlo simulation, and option pricing. Includes utilities for portfolio evaluation, clustering, and risk reporting. Methods are based in part on Markowitz (1952) <doi:10.1111/j.1540-6261.1952.tb01525.x>, Rockafellar and Uryasev (2000) <doi:10.21314/JOR.2000.038>, Maillard et al. (2010) <doi:10.3905/jpm.2010.36.4.060>, Black and Scholes (1973) <doi:10.1086/260062>, and Cox et al. (1979) <doi:10.1016/0304-405X(79)90015-1>.
README.md
finlabR
Portfolio analytics and simulation toolkit in R. Includes:
- Mean-variance optimization (efficient frontier, max Sharpe, min variance)
- CVaR minimization
- Risk parity (equal risk contribution)
- Regime clustering (k-means)
- Asset correlation and clustering (PCA, EM, k-means)
- VaR/CVaR analysis
- Monte Carlo price simulation
- Option pricing (Monte Carlo, binomial tree, American)
- Limit order book simulation and features
Quick start
library(finlabR)
# load example dataset
prices <- get_example_prices()
rets <- calc_returns(prices[, -1])
# returns matrix (rows = time, cols = assets)
min_var <- mvo_min_variance(rets)
frontier <- mvo_efficient_frontier(rets, n = 30)
max_sharpe <- mvo_max_sharpe(rets, rf = 0.02)
cvar <- cvar_minimize(rets, alpha = 0.95)
rp <- risk_parity_weights(stats::cov(rets))
varcvar <- var_cvar(rets, alpha = 0.95)
# limit order book demo
book <- simulate_orderbook(n_steps = 200, p0 = 100)
lob_features <- extract_features(book)
# run source('runme.R') for Shiny App
Full reference
See REFERENCE.md in the repository for the full list of functions and usage examples. #file <- system.file("extdata/runme.R", package = "finlabR") #source(file)
Run the Shiny dashboard
shiny::runApp(system.file("shiny/finlabR-dashboard", package = "finlabR"))