Skip to content

halim-quantlab/option-pricing-engine-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Option Pricing Engine (C++)

A modular C++ option pricing engine implementing analytical and numerical methods for derivative pricing, including Black-Scholes, Monte Carlo simulation, variance reduction techniques, and performance benchmarking.


πŸš€ Features

πŸ“Š Pricing Models

  • Black-Scholes (closed-form)
  • Monte Carlo Simulation
    • European options
    • Asian options (arithmetic average)

βš™οΈ Advanced Monte Carlo

  • Standard Monte Carlo
  • Antithetic Variates (variance reduction)
  • Confidence Intervals (95%)
  • Standard Error estimation

πŸ“ Greeks (Black-Scholes)

  • Delta
  • Gamma
  • Vega
  • Theta
  • Rho

πŸ” Validation & Analysis

  • Call-Put Parity (Black-Scholes & Monte Carlo)
  • Black-Scholes vs Monte Carlo comparison
  • Monte Carlo convergence analysis

⚑ Performance Benchmark

  • Runtime comparison:
    • Black-Scholes (ΞΌs)
    • Monte Carlo Standard (ms)
    • Monte Carlo Antithetic (ms)

πŸ§‘β€πŸ’» Interactive CLI

  • User inputs all parameters dynamically:
    • S0, K, r, y, sigma, T
    • pricing method (Black-Scholes / Monte Carlo)
    • payoff style (European / Asian)
    • option type (Call / Put)
    • simulation count
    • antithetic variates toggle

🧠 Mathematical Models

Black-Scholes Formula

[ C = S_0 e^{-yT} N(d_1) - K e^{-rT} N(d_2) ]

[ d_1 = \frac{\ln(S_0/K) + (r - y + 0.5\sigma^2)T}{\sigma \sqrt{T}} ]

[ d_2 = d_1 - \sigma \sqrt{T} ]


Geometric Brownian Motion (GBM)

[ S_T = S_0 \exp\left((r - y - 0.5\sigma^2)T + \sigma \sqrt{T} Z \right) ]


Monte Carlo Estimator

[ V = e^{-rT} \cdot \mathbb{E}[\text{Payoff}] ]


Antithetic Variates

Use paired samples: [ Z \quad \text{and} \quad -Z ]

To reduce variance in Monte Carlo estimation.


πŸ“ Project Structure

Input

image


Example Output

image


Compile

g++ -std=c++17 main.cpp src/math_utils.cpp src/black_scholes.cpp src/monte_carlo.cpp src/analysis.cpp -o option_engine ./option_engine


🎯 Key Learnings

β€’	Built a modular C++ derivatives pricing engine
β€’	Implemented stochastic simulation with GBM
β€’	Applied Monte Carlo variance reduction
β€’	Validated numerical methods against analytical pricing
β€’	Performed convergence and runtime analysis
β€’	Structured the codebase using reusable headers and source files

🧩 Model Interpretation

Black-Scholes Assumptions

- Asset follows Geometric Brownian Motion (GBM)
- Constant volatility
- Constant risk-free rate
- Continuous dividend yield
- No arbitrage opportunities
- Frictionless markets (no transaction cost, perfect liquidity)
- Continuous trading
- Lognormal return distribution

βΈ»

When Black-Scholes Breaks

- Volatility is not constant (volatility smile/skew)
- Sudden jumps (earnings, macro shocks) violate GBM
- Interest rates and dividends change over time
- Transaction costs and liquidity constraints exist
- Discrete hedging introduces errors
- Not suitable for path-dependent options like arithmetic Asian

βΈ»

Monte Carlo Assumptions

- Underlying follows GBM
- Random variables are normally distributed
- Large number of simulations ensures convergence
- Constant discount rate

βΈ»

Monte Carlo Limitations

- Model risk persists (depends on GBM assumption)
- Slow convergence for high accuracy
- High computational cost
- Tail risks may be underrepresented
- No closed-form benchmark for some exotic options

πŸš€ Future Improvements

Pricing Models

- Binomial Tree
- Trinomial Tree
- Barrier Options
- Lookback Options
- Digital Options

This project is designed as a foundational quantitative finance engine for:

- Understanding derivatives pricing
- Comparing analytical vs numerical methods
- Studying Monte Carlo convergence
- Building reusable C++ quant infrastructure

πŸ‘€ Author Wielly Halim Aspiring Quant Researcher | C++ & Python | Derivatives Pricing

If you found this project insightful, consider starring the repository.

About

Modular C++ option pricing engine with flexible inputs and support for multiple pricing models

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages