Shihan Mahfuz

Veris shows its working

Veris

A platform for learning how portfolio risk works, built on one rule: investors deserve to see the maths behind every number they are shown. You learn a method, pass a quiz, and the tool that uses it unlocks.

Built with
Askar Kassimov
Version
v3.0 · 29 Apr 2026
Stack
Python, FastAPI, SQLAlchemy, vanilla JS, Plotly
The Veris Monte Carlo risk panel with a return histogram and simulated paths.
Plate 1 Monte Carlo risk on a sample portfolio (AAPL, MSFT, GOOGL), from a local run on 19 Nov 2026: 10,000 correlated Student-t paths, VaR and CVaR, and the percentile fan.

From the professorCourse feedback from the professor at NYU Stern. Quoted as written; cuts marked with ellipses.

…your end product is almost worth trying to sell or making a startup. I would encourage you to share this!

The course professor, NYU Stern1 of 5 in the Prof/TF ranking · 2 of 5 in the peer rankings
  • APIsOn the API front, you’ve got a ton of API calls; this is very impressive.
  • DatabaseThe DB schema design is well structured and done. Here again you excelled.
  • VisualisationThe visualization in the project was well done. Here you were among the best in class…
  • ModellingOn the ML/AI/modeling side you had an extremely large number of models they were well executed and made sense in the context.
  • Front endThe frontend had many pages and I love the [educational] aspect.
  • Prediction marketsThe prediction market add on was also really nice and useful. I think one of the most impressive parts.
  • RankingYou got 1 of 5 in the Prof/TF ranking and 2 of 5 in the peer rankings.

Who built whatFrom the project’s own contributor table.

Askar Kassimov

The core platform: the FastAPI backend, the yfinance, FRED and SEC data pipeline, the base portfolio analytics, the Colab integration with ngrok, and the first dashboard.

Shihan Mahfuz

The analytics rebuild to an institutional standard, the risk management system, the database layer, the Veris identity, and every feature listed below: prediction markets, trading tools, options, stress testing, learning mode and the command palette.

Question

How much of a portfolio’s risk is visible in summary numbers, and how much hides in the joint behaviour of its assets?

Investors are shown risk numbers without knowing where they come from. Can a tool show its working and still be pleasant to use?

Method

Log returns; full-covariance volatility; Monte Carlo VaR and CVaR from 10,000 Student-t paths through a Cholesky decomposition; a Ledoit-Wolf frontier.

One engine that exposes each step, plus prediction markets, options, stress tests and a learning mode so beginners can follow along.

Why these choices

Student-t paths for fat tails; shrinkage because sample covariance is noisy with many assets; rescaling so simulated covariance matches the sample.

Every number on screen can be traced to a formula a user can read.

Result

An open, inspectable implementation of standard risk methods, with a test suite that checks it against the spec.

First in the class in the professor and TF ranking, second in the peer ranking. Open source on GitHub.

Learn it, then use itNine stages, 56 lessons and 34 quizzes. Twenty-five of the dashboard’s panels stay locked until you pass the stage that explains them, with 70% as the pass mark.

  1. The Trader’s DeskAdd stocks, view prices, read the news.
  2. Reading the TapeWhat the portfolio numbers mean.
  3. Understanding RiskHow much you could lose.
  4. Building a Better PortfolioCorrelation, diversification and the efficient frontier.
  5. When Markets BreakStress tests, factor models and past crises.
  6. The Real Cost of InvestingTaxes, tariffs and what a position really costs.
  7. Options and DerivativesCalls, puts, the Greeks and implied volatility.
  8. Prediction MarketsProbability, calibration and betting markets.
  9. Finding EdgeArbitrage, the Kelly criterion and following large traders.

Each lesson links out to further reading: 55 videos and 38 articles in all. Progress earns points, five ranks and nine badges.

What is insideNine parts, with the file each one lives in.

Analytics engineportfolio.py

  • Log returns across the pipeline, Bessel-corrected
  • Full-covariance volatility, σ = √(wᵀΣw)
  • 252-day OLS beta against SPY
  • Sortino, Treynor, Calmar, information ratio, Jensen’s alpha
  • HHI, effective N, diversification ratio
  • Tax engine with loss-harvesting flags

Monte Carlo riskadvanced_analytics.py

  • 10,000 simulations, 30-day horizon
  • Student-t marginals fitted per asset by MLE
  • Cholesky-correlated draws, rescaled so simulated covariance matches the sample
  • VaR and CVaR at 95% and 99%, percentile fan

Efficient frontieradvanced_analytics.py

  • Ledoit-Wolf shrinkage on the covariance
  • Black-Litterman-style expected returns
  • Box constraints of 5–60% per name, so portfolios are investable

Prediction marketsdata_fetcher.py

  • Polymarket and Kalshi in one feed
  • Bellman-Ford arbitrage scanner across 500+ Polymarket and 350+ Kalshi markets
  • Calibration curve from 500 resolved markets, with Brier score
  • EV calculator and fractional Kelly sizing

Options and stressoptions_math.py

  • Black-Scholes with delta, gamma, theta, vega, rho
  • Risk-free rate from the 10-year Treasury via FRED
  • Beta-adjusted losses in five historical crises
  • Reverse stress test and regime-conditional VaR

Learning modelearn.js

  • 9 stages, 56 lessons, 34 quizzes
  • XP, five ranks and nine badges
  • 25 dashboard panels unlock as you learn
  • Built so a first-time investor can follow the maths

Intraday tapedata_fetcher.py

  • Minute bars from 1m to 1h
  • UTC-normalised timestamps and a freshness flag on every bar
  • Interval-tuned caching

Persistencedatabase/

  • SQLAlchemy ORM with 8 models
  • SQLite by default; MySQL and PostgreSQL supported
  • PBKDF2 password hashing, audit log, auto-snapshots
  • 30 CRUD endpoints

Interfacefrontend/static/

  • 33 panels in vanilla JavaScript, Plotly and Chart.js
  • Cmd+K command palette
  • What-if trade simulator with before-and-after metrics

More platesScreenshots from a local run on a sample portfolio. No personal holdings.

How it fits together

  Google Colab (T4)     FRED      Polymarket     Kalshi      Yahoo
  FinGPT LoRA, 4-bit      │            │            │           │
        │ ngrok            │            │            │           │
        ▼                  ▼            ▼            ▼           ▼
  ┌──────────────────────────────────────────────────────────────────┐
  │  FastAPI backend · 57 endpoints                                  │
  │  portfolio.py ............ core analytics                        │
  │  advanced_analytics.py ... Monte Carlo, frontier, stress, regime │
  │  options_math.py ......... Black-Scholes and Greeks              │
  │  data_fetcher.py ......... yfinance, FRED, SEC, Polymarket, Kalshi│
  │  database/ ............... SQLAlchemy, 8 models, audit log       │
  └──────────────────────────────────────────────────────────────────┘
        │ JSON :8000                         │ SQL
        ▼                                    ▼
  Veris dashboard: 33 panels,          SQLite · MySQL · PostgreSQL
  learning mode, Cmd+K palette