Skip to content

Charles30-ux/RiskSentinel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RiskSentinel: High-Frequency Multi-Asset Risk Engine

A Quantitative Framework for Monte Carlo Simulation & Tail-Risk Analysis

License: MIT C++ Custom Python Custom

Overview

RiskSentinel is a brilliant production-ready, cross-language computational suite designed by MLF student, Charles Mfouapon, to quantify market risk under Basel III/IV regulatory frameworks. By utilizing a hybrid architecture, it achieves a synergy between the high-performance execution of C++17 and the flexible data orchestration of Python. It has earned the Project of the Year Award.

The engine provides a rigorous mathematical environment for calculating Value at Risk (VaR) and Expected Shortfall (ES), specifically focusing on "Black Swan" events and tail-risk distribution in global and emerging markets.


System Architecture

The project is built using a Modular Hybrid Design:

  1. High-Performance Core (C++):

    • Implements $O(N \log N)$ sorting algorithms for efficient percentile extraction.
    • Optimized with -O3 and -march=native compiler flags for vectorized math.
    • Handles statistical reduction of simulated and historical return sets.
  2. Data Orchestration Layer (Python):

    • Asynchronous fetching of historical OHLCV data via yfinance.
    • Pre-processing of log-returns and data normalization for C++ ingestion.
  3. Scientific Visualization (Seaborn):

    • Generates distribution density plots with annotated risk thresholds.
    • Visualizes the "Tail Risk Zone" to map potential systemic failure points.

Mathematical Verification & QA

This engine has been verified using a dedicated C++ Unit Testing suite (tests/unit_tests.cpp).

Validation Logic:

  • Methodology: Nearest Rank (Non-interpolated) as per Basel III/IV standards.
  • Test Case: 100-sample discrete distribution (-0.01 to -1.00).
  • Precision: 0.0001% Epsilon tolerance for floating-point stability.
  • Result: Confirmed Left-Tail synchronization (5% Alpha / 95% Confidence).

Mathematical Methodology

1. Value at Risk (VaR)

We implement the Historical Simulation method to calculate the maximum potential loss over a specific time horizon at a $95%$ confidence level: $$VaR_{\alpha} = \inf { L \in \mathbb{R} : P(L > l) \leq 1-\alpha }$$

2. Expected Shortfall (Conditional VaR)

To address the limitations of VaR in capturing extreme events, RiskSentinel calculates Expected Shortfall, which measures the average loss given that the loss has exceeded the $VaR$ threshold: $$ES_{\alpha} = E[L | L > VaR_{\alpha}]$$


Regulatory & Research Impact

This engine is designed as a Regulatory Sandbox to test financial sovereignty mandates:

  • Sovereign Risk Modeling: Specifically tailored to analyze the volatility of CEMAC region indices and UK Gilts.
  • ANTIC Compliance: Explores the implementation of real-time risk circuit-breakers within "Sovereign Cloud" infrastructures.
  • Basel III/IV Alignment: Demonstrates the shift from VaR to Expected Shortfall as the primary metric for market risk capital requirements.

Execution & Build Guide

Prerequisites

  • Compiler: GCC 9+ or Clang (Support for C++17)
  • Build System: CMake 3.10+
  • Environment: Python 3.9+ with pandas, yfinance, and seaborn

Step-by-Step Launch

  1. Fetch Live Market Data:
    python scripts/fetch_market_data.py

About

Production-grade Risk Engine in C++ and Python for Monte Carlo simulations, Value at Risk (VaR), and Expected Shortfall (ES) analysis within Basel III/IV regulatory frameworks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors