Skip to content

About

Portfolio construction & risk laboratory for the Bourse de Casablanca — mean-variance to Monte Carlo, VaR 95%, factor screens, and a LUKS-secured data workflow.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Casablanca Quant Framework (BVC)

Quantitative research environment for the Bourse de Casablanca (BVC): portfolio simulation via Monte Carlo, Value-at-Risk, and portfolio optimization on real Moroccan market data — with a secured, reproducible Linux workflow for handling the underlying price data.

Case study and results on the published portfolio: deyirviel.com/posts/casablanca-quant-framework.

What it produces

  • Monte-Carlo engine — 1,000 simulated trajectories per run for the covered assets (Akdital, Attijariwafa Bank, etc.), built from historical price series committed in historical_data/.
  • Value-at-Risk (95%) — the loss threshold that holds across 95% of simulated scenarios; the headline figure for the published case study is 794,571 MAD on a one-year horizon.
  • Portfolio optimizer — Sharpe ratio and efficient-frontier computation to move from an allocation call to a number.
  • Secured data workflow — raw BVC exports never sit on disk in plaintext; see "Trusted storage design" below.

Trusted storage design

Financial data (BVC exports, SQLite databases) is handled inside a LUKS-encrypted loop image rather than as plaintext on the host filesystem.

  • LUKS encryption — data lives in an encrypted 500 MB disk image.
  • XFS filesystem — chosen for the financial dataset workload.
  • Git isolation — the encrypted container (finance.img) is ignored by Git, keeping raw data out of the repository and the cloud.

Getting started

The project is automated for Fedora/RHEL via Makefile targets. Clone, then:

git clone https://github.com/yirvisom/casablanca-quant-framework.git

Install Python dependencies into an isolated virtual environment:

make setup

Initialize the encrypted vault (you will choose a strong passphrase):

make vault_setup

Daily workflow:

make vault_open    # unlock and mount the vault
make data_clean    # clean data into the secure vault
make run           # launch Jupyter Lab

When done:

make vault_close   # unmount the volume

Project structure

  • historical_data/ — committed price histories for the covered BVC assets.
  • notebooks/ — interactive analysis and visualizations.
  • data_secure/ — vault contents; only accessible while the vault is mounted.
  • scripts/ — data cleaning, vault setup, and the simulator.
  • Makefile — project control plane.
  • requirements.txt — pinned Python environment.

Output

A simulation run produces a fan chart of the 1,000 simulated trajectories with the mean scenario highlighted:

Monte Carlo fan chart

Methodological note: simulations assume returns follow a log-normal process and that 2025 volatility persists into 2026.


Author: Yirviel Somé — MSc candidate in Finance, FMVA® & BIDA® certified.

About

Portfolio construction & risk laboratory for the Bourse de Casablanca — mean-variance to Monte Carlo, VaR 95%, factor screens, and a LUKS-secured data workflow.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages