Skip to content

Joshua92500/portfolio-var-model

Repository files navigation

Portfolio VaR Model

Monte Carlo Value at Risk (VaR) model for stock portfolios. Uses parametric simulation (geometric Brownian motion) across 10,000 paths. Reports 90%, 95%, 99% confidence VaR over a 21-day horizon.

Requirements

install.packages(c("prettydoc", "knitr", "rmarkdown"))

prettydoc is required to knit the HTML report. knitr and rmarkdown are required by RStudio's knit button.

Run the R Script

  1. Open var_project.R in RStudio.
  2. Press Ctrl+Shift+S (source with echo) — or run source("var_project.R").
  3. Console prompts for share count per ticker — enter an integer and press Enter for each.
  4. Outputs: portfolio value (PLN), histogram of simulated P&L, VaR at 90/95/99% confidence.

Knit the HTML Report

  1. Open VaR Markdown Report.Rmd in RStudio.
  2. Click Knit (or press Ctrl+Shift+K).
  3. Share counts are hardcoded in the Rmd (md_Num_Shares vector) — edit that vector before knitting if needed.
  4. Output: VaR-Markdown-Report.html using the prettydoc cayman theme.

Data Format

Each CSV must have at minimum:

Column Description
Date Trading date
Close Daily closing price

Example Portfolio

Six Polish equities in data/ (ALE, DNP, MAK, PCO, PKO, TAR) sourced from Stooq.

Notes

  • Volatility = annualized historical vol (252 trading days).
  • Risk-free rate hardcoded to 5.08% (4-week T-bill, May 31 2023) — update rfr_invest in var_project.R as needed.
  • Currency: Polish złoty (zł).

About

Monte Carlo Value at Risk (VaR) model for stock portfolios

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages