Ankit3445/options_pricing
Options Pricing Platform — Complete Guide
What Is This Project?
This is a real-time web application that calculates the price of financial options — contracts that give you the right to buy or sell a stock at a fixed price in the future. It uses two mathematical methods:
- Black-Scholes (a precise formula for simple options)
- Monte Carlo simulation (runs thousands of random scenarios for complex options)
The app fetches live stock prices (or generates realistic synthetic prices) and displays everything on an interactive dashboard in your browser.
Objective
Build a working, real-time options pricing and risk-analysis tool accessible from any web browser, to demonstrate:
- How option prices are calculated using math and simulation
- How risk is measured (Delta, Gamma, Vega, etc.)
- How different trading strategies behave
- How Monte Carlo accuracy improves with more simulation paths
- All with live updating data and interactive charts
How to Use the Platform
.
The Toolbar (Top Bar)
The badge on the right shows Running or Paused, and the number of positions and symbols tracked.
Tab 1: Portfolio (Main Dashboard)
This is the default tab. It shows the current state of all your option positions.
Greeks Cards (top-left box)
Shows the overall risk numbers for your entire portfolio:
- Positions — total number of option contracts
- Last Spot — most recent stock price received
- Delta / Gamma / Vega / Theta / Rho — risk measurements (explained in glossary)
- IV (avg) — average implied volatility across all positions
- HV (annual) — historical volatility (how much the stock actually moved)
Numbers are color-coded: green = positive, red = negative, gray = neutral.
P&L Summary (top-right box)
- Total Cost — how much you paid for all positions
- Portfolio Value (BS) — what your positions are worth now (Black-Scholes estimate)
- Unrealized P&L — profit or loss (green = profit, red = loss)
- Ticker — the last stock that was updated
Below this is a P&L chart that updates live — a line showing how your profit/loss changes over time.
Risk Analytics (bottom-left)
- Sharpe Ratio — risk-adjusted return (higher is better)
- VaR (95%) — Value at Risk: the maximum you could lose 95% of the time
- VaR (99%) — Value at Risk at 99% confidence
- Max Drawdown — biggest drop from peak to trough
Stress Scenarios
- Market Crash (-10%) — what happens to your portfolio if all stocks drop 10%
- Vol Spike (+20%) — what happens if volatility jumps 20%
- Rate Shock (+1%) — what happens if interest rates rise 1%
Vol Surface Heatmap (bottom-right)
A colored grid showing implied volatility across different strike prices and expiry dates for each stock. Darker colors = higher volatility. Helps you see which options are expensive or cheap.
Greeks Surface Table (full-width table)
A sortable table showing each stock's total risk numbers. Click any stock name to expand its full option chain (all strikes, expiries, and their individual prices and Greeks).
Positions Table (below surface table)
Shows the most recent 10 option positions with all details: ticker, spot price, strike price, expiry, type (CALL/PUT), Delta, Gamma, Vega, IV, and price. Click column headers to sort.
The data refreshes automatically every 3–5 seconds.
Tab 2: Convergence Analysis
This tab demonstrates that Monte Carlo simulation gets more accurate as you run more paths.
How to use:
- Enter: Spot price, Strike price, Expiry (years), Interest rate (%), Volatility (%), Option type (Call/Put)
- Choose max paths (10K, 50K, 100K, 200K)
- Click Run
What you'll see:
- A table showing MC price vs BS exact price at 7 different path counts (1K to 100K)
- A chart showing MC prices converging toward the BS price line as paths increase
- The error column shows MC price minus BS price (should approach zero)
- The std error column shows the statistical uncertainty (should shrink)
Tab 3: Exotic Options
Prices path-dependent options that can't be priced with a simple formula.
How to use:
- Style — choose Asian (average), Barrier, or Lookback
- Option Type — Call or Put
- Ticker — select a stock
- Spot, Strike, Expiry, Rate, Vol — enter the option parameters
- If Barrier is selected, also enter the Barrier price and direction (Down-and-Out / Up-and-Out)
- Click Price
What you'll see:
- The calculated price (MC simulation result)
- Delta risk measure
- All input parameters shown for reference
Tab 4: Strategies
Build and visualize multi-leg option strategies — combinations of multiple options that create specific profit/loss patterns.
How to use:
- Click Build Strategy
- Choose a Strategy Type from the dropdown
- Enter the required parameters (they change based on strategy type)
- Click Build & View
Strategy Types Explained:
What you'll see:
- A P&L diagram (chart showing profit/loss at different stock prices at expiry)
- Strategy info — name, ticker, cost, risk numbers
- Legs — each individual option in the strategy
Terminology Glossary
Basic Stock Market Terms
Option Terms
Exotic Option Terms
Risk Measurement Terms (The Greeks)
Portfolio Analytics Terms
Pricing Method Terms
Tech Terms
Technical Details (For Developers)
Architecture
Web Browser (Chart.js dashboard)
↕ HTTP / SSE
Boost.Beast HTTP Server
↕
Alpha Vantage Client ← → ThreadSafe Queue ← → Worker Threads → Portfolio Manager
(fetches data) (holds pending (compute prices) (stores results)
ticks)- Alpha Vantage Client fetches stock prices from the Alpha Vantage API every 12 seconds, generates 30 option positions per stock, and puts them in a queue
- Worker threads pick up positions from the queue, compute prices using both Black-Scholes and Monte Carlo, and save the results
- HTTP Server serves the web page and API data from the Portfolio Manager
CLI Arguments
options_pricer API_KEY [SYMBOLS...] [options]
Options:
--mc-paths N Number of Monte Carlo paths (default: 5000 on HF, 100000 local)
--rate-limit S Seconds between API calls (default: 12)
--port P HTTP server port (default: 8080)
--calls-only Only generate CALL options
--puts-only Only generate PUT options
--help Show help
Examples:
options_pricer API_KEY AAPL MSFT TSLA
options_pricer API_KEY AAPL --mc-paths 50000 --port 9090API Endpoints
Live Deployed URL
https://ankit3445-options-pricing.hf.space
GitHub Repository
https://github.com/Ankit-06679/C-_Options_pricing_project
Source Files
Technologies Used
- C++20 — latest C++ standard
- Boost.Beast + Boost.Asio — HTTP server and networking
- OpenSSL — secure HTTPS connections to Alpha Vantage
- nlohmann/json — JSON parsing and generation
- Chart.js — browser-based interactive charts
- Docker — containerized deployment
- CMake — build system
