Portfolio Analytics and Simulation Toolkit

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) , Rockafellar and Uryasev (2000) , Maillard et al. (2010) , Black and Scholes (1973) , and Cox et al. (1979) .


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"))

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("finlabR")

1.0.0 by Suyash Jindal, 6 months ago


Browse source code at https://github.com/cran/finlabR


Authors: Suyash Jindal [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports stats, utils, quadprog, ggplot2, PerformanceAnalytics, zoo, class, quantmod, reshape2, mclust, shiny

Suggests bslib, TTR, DT, xts, yfR, cryptoQuotes, tidyquant, Rtsne, umap, testthat, knitr, rmarkdown


See at CRAN