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.
- 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.
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.
The project is automated for Fedora/RHEL via Makefile targets. Clone, then:
git clone https://github.com/yirvisom/casablanca-quant-framework.gitInstall Python dependencies into an isolated virtual environment:
make setupInitialize the encrypted vault (you will choose a strong passphrase):
make vault_setupDaily workflow:
make vault_open # unlock and mount the vault
make data_clean # clean data into the secure vault
make run # launch Jupyter LabWhen done:
make vault_close # unmount the volumehistorical_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.
A simulation run produces a fan chart of the 1,000 simulated trajectories with the mean scenario highlighted:
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.
