Skip to content

Vedant-0102/Amethyst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Amethyst — Quantitative Finance Education & Simulation Platform

A full-stack quant finance platform with 30+ financial models, real-time market data, paper trading, and interactive visualizations — built for learning and exploration.


Features

Live Ticker Tape — Scrolling real-time prices for 80+ global instruments across NYSE (USA), LSE (UK), NSE/BSE (India), HKEX (Hong Kong), XETRA (Germany), TSE (Japan), ASX (Australia). Covers stocks, ETFs, crypto, forex, and commodity futures with multi-currency display and timezone-aware market hours.

Model Catalog — 30+ financial models organized by category. Each page has parameter inputs, mathematical formulas, interactive Chart.js visualizations, educational tooltips, and methodology explanations.

Paper Trading — Trade stocks at live prices with a virtual $100,000. Tracks positions, P&L, and trade history with 0.1% commission. State persists in localStorage.

Offline Mode — When the backend is unavailable, the frontend uses client-side GBM simulation (Box-Muller transform) to keep prices animated. Health checks retry every 30 seconds.


Quick Start

python run.py

Starts the backend on http://localhost:8000 and frontend on http://localhost:5173.

Or run separately:

# Backend
cd backend && pip install -r requirements.txt && python start.py

# Frontend
cd frontend && npm install && npm run dev

Models

Stochastic Processes

Model Description
Monte Carlo Simulation Simulates thousands of GBM price paths to produce return distributions and probability estimates.
Geometric Brownian Motion Exact log-normal price path simulation with drift analysis and terminal distribution.
Heston Stochastic Volatility Two-factor model with correlated price and variance processes; generates the volatility smile.
Ornstein-Uhlenbeck Process Continuous mean-reversion model used for interest rates and pairs trading spread dynamics.
Ito's Lemma Educational demo comparing corrected GBM vs naive simulation to illustrate the drift correction term.
Girsanov's Theorem Shows measure change from real-world to risk-neutral probability via likelihood ratio paths.
Feynman-Kac Theorem Links PDEs to stochastic expectations; solves the heat equation via Monte Carlo path averaging.

Option Pricing

Model Description
Black-Scholes Closed-form European call/put pricing with all five Greeks and implied volatility surface.
CRR Binomial Tree Discrete-time lattice pricing with visualized tree structure and early exercise premium for American options.
Finite Difference Methods Solves the Black-Scholes PDE numerically via explicit, implicit, and Crank-Nicolson schemes.
Risk-Neutral Valuation Monte Carlo option pricing under the Q-measure with convergence analysis and put-call parity verification.

Interest Rate Models

Model Description
Vasicek Model Mean-reverting short rate model with analytical bond pricing and yield curve generation.
Short Rate Models Side-by-side comparison of Vasicek and CIR models with calibrated parameters and simulated rate paths.

Portfolio Theory

Model Description
CAPM Estimates beta and alpha relative to a benchmark, plots the Security Market Line and rolling beta.
Markowitz MVO Generates the efficient frontier with minimum-variance and maximum-Sharpe portfolios highlighted.

Risk Management

Model Description
Value at Risk (VaR) Computes VaR and CVaR via historical, parametric, and Monte Carlo methods for tail risk analysis.
Risk Management Suite Full risk dashboard: VaR, CVaR, Sharpe, Sortino, max drawdown, beta, alpha, and stress scenarios.
Copula Models Models joint tail dependence between assets using Gaussian and Student-t copulas.

Volatility

Model Description
Volatility Suite Historical, Parkinson, and GARCH(1,1) volatility with regime detection and volatility cone charts.

Fundamental Analysis

Model Description
DCF Valuation Projects free cash flows and terminal value to estimate fair value per share with BUY/HOLD/SELL signal.

Machine Learning — Regression

All regression models use 13 engineered features (SMA, EMA, MACD, RSI, Bollinger Bands, momentum, volatility, lagged returns) with an 80/20 train/test split.

Model Description
Linear Regression Standard OLS baseline for price prediction with residual diagnostics.
Ridge Regression L2-regularized regression to reduce overfitting on correlated technical features.
Lasso Regression L1-regularized regression that performs feature selection by zeroing out weak predictors.
Elastic Net Combines L1 and L2 penalties for a balance between feature selection and coefficient shrinkage.
Polynomial Regression Captures non-linear price relationships by expanding features to higher-degree terms.
Random Forest Ensemble of decision trees with feature importance ranking and out-of-bag error estimate.
Gradient Boosting Sequential boosting that fits each tree to the residuals of the previous, improving accuracy iteratively.
SVR (Support Vector Regression) Kernel-based regression that finds a tube minimizing prediction error with margin tolerance.
XGBoost Optimized gradient boosting with regularization, pruning, and fast training on tabular data.

Machine Learning — Classification

Predicts next-day price direction (Bullish / Bearish) using the same 13 engineered features with an 80/20 train/test split. Each classifier has its own dedicated page with model-specific parameters, full metrics (accuracy, precision, recall, F1, ROC-AUC), confusion matrix visualization, per-day signal chart with up-probability, and feature importance. A combined comparison page lets you switch between all four in one view.

Model Description
Logistic Regression Classifier L2-regularized binary classifier (tunable C) that learns a linear decision boundary. Feature weights directly show which indicators (RSI, MACD, momentum) drive the bullish/bearish signal — the most interpretable classifier.
Random Forest Classifier Ensemble of 200 decision trees with balanced class weights and max_depth=8. Aggregates votes for calibrated probabilities; outputs Gini-based feature importance ranking all 13 technical indicators.
SVM Classifier RBF kernel SVM that finds the maximum-margin hyperplane in a high-dimensional kernel space. Reports support vector count and Platt-calibrated class probabilities for each test day.
XGBoost Classifier Gradient-boosted trees with histogram splits, column subsampling, and automatic class-imbalance correction via scale_pos_weight. Outputs gain-based feature importance alongside full classification metrics.
ML Direction Classifier (Combined) Unified comparison page — switch between all four classifiers on the same ticker and period to compare accuracy, ROC-AUC, confusion matrices, and signal charts side-by-side.

Time Series Forecasting

Model Description
ARIMA AutoRegressive Integrated Moving Average with automatic order selection for price forecasting.
SARIMA Extends ARIMA with seasonal components to capture periodic patterns in price data.

Market Dynamics

Model Description
Markov Chains Models market regimes (Bear / Neutral / Bull) as a discrete Markov process with transition probabilities and steady-state distribution.
Pairs Trading Identifies cointegrated stock pairs and generates mean-reversion entry/exit signals using the spread z-score.

Tech Stack

Backend: Python, FastAPI, NumPy, SciPy, pandas, scikit-learn, statsmodels, yfinance

Frontend: React 19, Vite, Tailwind CSS 4, Chart.js, Framer Motion, React Router

About

Quantitative Finance Simulator | Paper Trading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors