Rasheed
Khoshnaw

Software Engineer

VaR and CVaR Risk Calculator

Project Overview

Deployed Site: https://var-cvar-risk.streamlit.app/

GitHub Repo: https://github.com/gitRasheed/var-cvar-streamlit-risk-analyzer

I developed a comprehensive Value at Risk (VaR) and Conditional Value at Risk (CVaR) calculator as a Streamlit web application after first learning of CVaR from this interview with Stanislav Uryasev.

Development Process

1. Research and Planning:

  • Studied various VaR and CVaR calculation methodologies.

  • Planned the application structure and user interface.

2. Data Handling Implementation:

  • Integrated yfinance for real-time stock data retrieval.

  • Implemented data preprocessing using Pandas.

3. Core Calculation Engine:

  • Developed modules for Historical, Parametric, and Monte Carlo VaR/CVaR calculations.

  • Utilized NumPy and SciPy.

4. Streamlit UI Development:

  • Designed it so that all the relevant input parameters can me manpiulating easily in the sidebar, everything is responsive.

  • Created interactive visualizations using Plotly for clear risk representation.

5. Testing and Refinement:

  • Implemented unit tests with Pytest to ensure calculation accuracy, followed TDD and implemented the tests alongside each class.


Final Application Features

  • Dynamic Portfolio Analysis: Users can input multiple stock tickers and weights, with real-time data fetching.

  • Comprehensive Risk Calculations: Offers Historical, Parametric, and Monte Carlo VaR/CVaR calculations.

  • Flexible Risk Parameters: Adjustable confidence levels, time horizons, and historical data ranges.

  • Interactive Visualizations:

    • Returns distribution histograms with VaR and CVaR cutoffs.

    • Rolling VaR/CVaR charts for historical risk trends.

  • Responsive Design: Adapts seamlessly to different screen sizes and devices.

  • Educational Component: Includes explanations of VaR and CVaR concepts for user understanding.



Key Learnings

It was really cool to work on this project, as once it was finished, I was able to understand why each parameter was causing its respective change in price. Playing around with the paramters and seeing their changes in visualisations (like the convergence or divergence of VaR & CVaR) helped build my understanding of different condition's effects on risk.

This project not only showcases my technical skills in Python, data analysis, and web development but also demonstrates my ability to create practical tools for financial risk management. It waas rewarding to work on a project that required learning about risk and the maths behind it, and then implementing that in a visually intuitive and simple way.