AB.Measure exposure. Understand uncertainty. Decide with context.All projects

Financial Analytics

Casablanca Risk

A Casablanca Stock Exchange risk-intelligence platform combining a 124,562-row historical panel, stock and portfolio risk analysis, volatility and regime models, simulation, and structured news context.

Web ScrapingFinancial RiskGARCH / HMMPortfolio AnalyticsNews Classification
View source repository↗
Casablanca Risk interface

Why it matters

Makes local market exposure and uncertainty understandable without presenting risk analytics as price prediction or investment advice.

My role

Financial data analyst and solution developer

  1. 01Engineered quote and financial-news collectors with Requests, Beautiful Soup, Pandas, source adapters, robots.txt checks, caching, scheduling, validation, deduplication, and failure-safe atomic writes.
  2. 02Assembled and validated 124,562 daily observations across 78 symbols, delayed quotes, issuer references, portfolio records, and multilingual financial news.
  3. 03Implemented stock, market, tail, liquidity, regime, portfolio, simulation, and event-level risk analysis with explicit validation and investability gates.
  4. 04Translated risk evidence into rankings, profiles, portfolio scorecards, news context, and virtual trading without presenting analytics as price prediction.
01

Situation

Free per-stock Casablanca Stock Exchange history is fragmented, and existing sources rarely connect price data to risk context or explain uncertainty rather than predicting price.

02

Task

Build a risk-intelligence platform that assembles a reliable local-market panel, quantifies stock and portfolio risk, and translates it into decision support, without presenting analytics as price prediction or investment advice.

03

Action

  • Python collectors built with Requests, Beautiful Soup, and Pandas retrieve delayed quotes and French/Arabic financial news from Casablanca Bourse, AMMC, Medias24, L'Economiste, Boursenews, Finances News Hebdo, and La Vie Eco, respecting robots.txt, caching raw HTML, and writing atomically so a failed refresh never corrupts the last valid snapshot. The resulting panel holds 124,562 daily observations across 78 symbols from January 2015 to June 2026.
  • Stock and market risk are measured with annualised volatility, Sharpe ratio, maximum drawdown, beta to MASI, historical VaR, and Expected Shortfall, while Amihud illiquidity and coverage checks gate stale or hard-to-trade names out of portfolio conclusions. GARCH forecasts volatility and HMM identifies market regimes, with Kupiec backtesting checking VaR exceedances.
  • Equal weight, minimum variance, Hierarchical Risk Parity, and MASI buy-and-hold portfolios are compared with Ledoit-Wolf covariance shrinkage and out-of-sample walk-forward testing. The latest run shows minimum variance at roughly 11.0% annualised return, 11.5% volatility, and a 0.75 Sharpe ratio, versus about 5.4%, 13.3%, and 0.28 for MASI buy-and-hold. A 10,000-path Monte Carlo simulation reports a full outcome distribution: about 35.7% probability of loss, 6.5% median return, and a negative 14.9% median maximum drawdown.
  • Market-model event studies calculate abnormal returns and CAR windows around news, while deterministic company, sector, and theme mappings attach auditable risk or opportunity tags to French and Arabic financial news, without issuing buy or sell signals.
04

Result

The platform surfaces that domestic diversification can be limited by bank and telecom concentration, while the MASI's lower correlation with global indices may make Moroccan equities more relevant for international diversification. It is delivered through searchable snapshots, risk profiles, rankings, and a virtual trading simulator that keep uncertainty and data limitations visible rather than hidden.

Technical implementation

How the solution was built.

Each layer connects an implementation choice to the decision or workflow it supports.

07 layers
LayerImplementationOperational purpose
Market collectionRequests, Beautiful Soup and source-specific adapters for delayed quotes and issuer dataBuild a consistent local-market panel from fragmented public sources
News collectionFrench and Arabic financial-news scraping with normalized headlines, provenance and cross-source deduplicationConnect market analysis to traceable company, sector and macro context
Data reliabilityrobots.txt checks, raw-response caching, schema validation, lock files, scheduling and atomic writesPreserve the last valid dataset and expose stale or failed refreshes honestly
Risk measurementVolatility, beta, drawdown, historical VaR, Expected Shortfall, correlation and liquidity indicatorsCompare stock and portfolio exposure with interpretable downside measures
Risk modellingGARCH volatility forecasts, HMM regimes and Kupiec VaR backtestingEstimate changing risk conditions and verify whether loss thresholds remain credible
Portfolio analysisMinimum variance, Hierarchical Risk Parity, Ledoit-Wolf covariance and walk-forward testingCompare allocations using out-of-sample evidence, costs and investability gates
Simulation and events10,000-path Monte Carlo distributions and market-model event studiesQuantify ranges of outcomes and examine abnormal behaviour around news events

Product walkthrough

Screens connected to decisions.

11 screens
Casablanca Risk: concept art
01
concept art

Sets the visual direction for the platform before the functional screens that follow.

Casablanca Risk: market snapshot
02
market snapshot

Makes the listed market searchable and comparable through price, volume, capitalization, and recent movement.

Casablanca Risk: stock detail
03
stock detail

Combines historical price context with market value, traded value, and relative-risk indicators.

Casablanca Risk: stock risk profile
04
stock risk profile

Translates volatility, VaR, expected shortfall, and drawdown into a readable risk profile.

Casablanca Risk: stock news disclosures
05
stock news disclosures

Connects company-level disclosures and sentiment context to the security being examined.

Casablanca Risk: news risk context
06
news risk context

Maps news to stocks, sectors, and macro themes to distinguish risk signals from opportunity context.

Casablanca Risk: practice account summary
07
practice account summary

Keeps virtual cash, invested capital, positions, and return visible before entering the simulator.

Casablanca Risk: tracked risk ranking
08
tracked risk ranking

Ranks tracked securities by comparable risk measures instead of implying price direction.

Casablanca Risk: paper trading simulator
09
paper trading simulator

Lets users test their own analysis with virtual money, delayed prices, and explicit transaction costs.

Casablanca Risk: holdings risk scorecard
10
holdings risk scorecard

Connects position-level P&L with portfolio concentration, weighted volatility, and beta.

Casablanca Risk: news signal details
11
news signal details

Expands each article into traceable risk and opportunity tags with source and confidence context.

Continue exploring03 / 11
Next project · Data AnalyticsExecutive Performance AnalyticsA dashboard earns its place when a metric changes a decision.↗
← Previous · FaultForgeView project archive
Project archiveGitHub repository ↗Discuss this work ↗