# sawee4/pricer architecture

> Architecture diagram of the GitHub repository sawee4/pricer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sawee4/pricer
- Repository: https://github.com/sawee4/pricer

## Overview

pricer is a C++17 option-pricing library. A caller supplies an Option contract and MarketData to a pricing engine and receives a price, with uncertainty fields for simulation. The documented capabilities include analytic and tree pricing, Monte Carlo, Greeks, implied volatility, and path-dependent Asian/barrier options. The graph follows those domain stages and includes the shared numerical utilities. Some relationships are supported by README descriptions or the SOURCE INDEX rather than inspected implementation excerpts; those limits are reflected in the evidence paths.

Main entry points: [`src/monte_carlo_pricer.cpp`](https://github.com/sawee4/pricer/blob/main/src/monte_carlo_pricer.cpp) (Monte Carlo), [`src/path_dependent_pricer.cpp`](https://github.com/sawee4/pricer/blob/main/src/path_dependent_pricer.cpp) (Path Simulation), [`src/monte_carlo_greeks.cpp`](https://github.com/sawee4/pricer/blob/main/src/monte_carlo_greeks.cpp) (Monte Carlo Greeks), [`src/random.cpp`](https://github.com/sawee4/pricer/blob/main/src/random.cpp) (Portable Randomness)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_contracts["Contracts and Inputs"]
  node_option["Option Contract<br/>[option.cpp]"]
  node_payoff["Terminal Payoffs<br/>[payoff.cpp]"]
  node_market["Market Data<br/>[market_data.cpp]"]
  node_path_payoff["Asian and Barriers<br/>[path_payoff.cpp]"]
end

subgraph group_engines["Pricing Engines"]
  node_pricer_api["Pricer Interface<br/>[pricer.hpp]"]
  node_analytic["Analytic Pricer"]
  node_binomial["CRR Binomial"]
  node_monte_carlo["Monte Carlo"]
  node_path_engine["Path Simulation"]
end

subgraph group_analytics["Analytics"]
  node_bs["Black-Scholes Formulas<br/>[black_scholes.cpp]"]
  node_exotic_formulas["Exotic Formulas"]
  node_implied_vol["Implied Volatility<br/>[implied_vol.cpp]"]
  node_mc_greeks["Monte Carlo Greeks"]
end

subgraph group_simulation["Simulation Utilities"]
  node_rng["Portable Randomness<br/>[random.cpp]"]
  node_statistics["Running Statistics<br/>[statistics.hpp]"]
  node_normal["Normal Distribution<br/>[normal.cpp]"]
end

node_caller(("Library Caller"))

node_caller -->|"defines contract"| node_option
node_caller -->|"provides inputs"| node_market
node_caller -->|"requests price"| node_analytic
node_caller -->|"requests price"| node_monte_carlo
node_caller -->|"requests price"| node_binomial
node_option -->|"owns payoff"| node_payoff
node_analytic -->|"uses formulas"| node_bs
node_analytic -->|"evaluates payoff"| node_payoff
node_binomial -->|"implements"| node_pricer_api
node_monte_carlo -->|"implements"| node_pricer_api
node_monte_carlo -->|"draws normals"| node_rng
node_monte_carlo -->|"accumulates estimates"| node_statistics
node_rng -->|"transforms uniforms"| node_normal
node_path_engine -->|"evaluates paths"| node_path_payoff
node_path_engine -->|"draws normals"| node_rng
node_path_engine -->|"accumulates estimates"| node_statistics
node_path_payoff -->|"adapts terminal payoff"| node_payoff
node_path_payoff -->|"uses pricing inputs"| node_bs
node_implied_vol -->|"solves against prices"| node_bs
node_exotic_formulas -->|"uses distribution"| node_normal
node_mc_greeks -->|"revalues bumped inputs"| node_monte_carlo
node_mc_greeks -->|"simulates paths"| node_rng
node_mc_greeks -->|"estimates Greeks"| node_statistics
node_caller -->|"requests exotic price"| node_path_engine
node_caller -->|"solves volatility"| node_implied_vol
node_caller -->|"estimates Greeks"| node_mc_greeks
node_caller -->|"uses closed forms"| node_exotic_formulas

click node_option "https://github.com/sawee4/pricer/blob/main/src/option.cpp"
click node_payoff "https://github.com/sawee4/pricer/blob/main/src/payoff.cpp"
click node_market "https://github.com/sawee4/pricer/blob/main/src/market_data.cpp"
click node_pricer_api "https://github.com/sawee4/pricer/blob/main/include/pricer/pricer.hpp"
click node_analytic "https://github.com/sawee4/pricer/blob/main/src/analytic_pricer.cpp"
click node_binomial "https://github.com/sawee4/pricer/blob/main/src/binomial_pricer.cpp"
click node_monte_carlo "https://github.com/sawee4/pricer/blob/main/src/monte_carlo_pricer.cpp"
click node_path_payoff "https://github.com/sawee4/pricer/blob/main/src/path_payoff.cpp"
click node_path_engine "https://github.com/sawee4/pricer/blob/main/src/path_dependent_pricer.cpp"
click node_bs "https://github.com/sawee4/pricer/blob/main/src/black_scholes.cpp"
click node_exotic_formulas "https://github.com/sawee4/pricer/blob/main/src/exotic_formulas.cpp"
click node_implied_vol "https://github.com/sawee4/pricer/blob/main/src/implied_vol.cpp"
click node_mc_greeks "https://github.com/sawee4/pricer/blob/main/src/monte_carlo_greeks.cpp"
click node_rng "https://github.com/sawee4/pricer/blob/main/src/random.cpp"
click node_statistics "https://github.com/sawee4/pricer/blob/main/include/pricer/statistics.hpp"
click node_normal "https://github.com/sawee4/pricer/blob/main/src/normal.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_option,node_payoff,node_market,node_path_payoff toneBlue
class node_pricer_api,node_analytic,node_binomial,node_monte_carlo,node_path_engine toneAmber
class node_bs,node_exotic_formulas,node_implied_vol,node_mc_greeks toneMint
class node_rng,node_statistics,node_normal toneRose
class node_caller toneIndigo
```

## Components

### Contracts and Inputs

- [Option Contract](https://github.com/sawee4/pricer/blob/main/src/option.cpp): `src/option.cpp`
- [Terminal Payoffs](https://github.com/sawee4/pricer/blob/main/src/payoff.cpp): `src/payoff.cpp`
- [Market Data](https://github.com/sawee4/pricer/blob/main/src/market_data.cpp): `src/market_data.cpp`
- [Asian and Barriers](https://github.com/sawee4/pricer/blob/main/src/path_payoff.cpp): `src/path_payoff.cpp`

### Pricing Engines

- [Pricer Interface](https://github.com/sawee4/pricer/blob/main/include/pricer/pricer.hpp): `include/pricer/pricer.hpp`
- [Analytic Pricer](https://github.com/sawee4/pricer/blob/main/src/analytic_pricer.cpp): `src/analytic_pricer.cpp`
- [CRR Binomial](https://github.com/sawee4/pricer/blob/main/src/binomial_pricer.cpp): `src/binomial_pricer.cpp`
- [Monte Carlo](https://github.com/sawee4/pricer/blob/main/src/monte_carlo_pricer.cpp): `src/monte_carlo_pricer.cpp`
- [Path Simulation](https://github.com/sawee4/pricer/blob/main/src/path_dependent_pricer.cpp): `src/path_dependent_pricer.cpp`

### Analytics

- [Black-Scholes Formulas](https://github.com/sawee4/pricer/blob/main/src/black_scholes.cpp): `src/black_scholes.cpp`
- [Exotic Formulas](https://github.com/sawee4/pricer/blob/main/src/exotic_formulas.cpp): `src/exotic_formulas.cpp`
- [Implied Volatility](https://github.com/sawee4/pricer/blob/main/src/implied_vol.cpp): `src/implied_vol.cpp`
- [Monte Carlo Greeks](https://github.com/sawee4/pricer/blob/main/src/monte_carlo_greeks.cpp): `src/monte_carlo_greeks.cpp`

### Simulation Utilities

- [Portable Randomness](https://github.com/sawee4/pricer/blob/main/src/random.cpp): `src/random.cpp`
- [Running Statistics](https://github.com/sawee4/pricer/blob/main/include/pricer/statistics.hpp): `include/pricer/statistics.hpp`
- [Normal Distribution](https://github.com/sawee4/pricer/blob/main/src/normal.cpp): `src/normal.cpp`

### Other components

- **Library Caller**

## Connections

- Library Caller → Option Contract: defines contract (evidence: `README.md`)
- Library Caller → Market Data: provides inputs (evidence: `README.md`)
- Library Caller → Analytic Pricer: requests price (evidence: `README.md`)
- Library Caller → Monte Carlo: requests price (evidence: `README.md`)
- Library Caller → CRR Binomial: requests price (evidence: `README.md`)
- Option Contract → Terminal Payoffs: owns payoff (evidence: `README.md`)
- Analytic Pricer → Black-Scholes Formulas: uses formulas (evidence: `src/analytic_pricer.cpp`)
- Analytic Pricer → Terminal Payoffs: evaluates payoff (evidence: `src/analytic_pricer.cpp`)
- CRR Binomial → Pricer Interface: implements
- Monte Carlo → Pricer Interface: implements
- Monte Carlo → Portable Randomness: draws normals (evidence: `src/monte_carlo_pricer.cpp`)
- Monte Carlo → Running Statistics: accumulates estimates (evidence: `src/monte_carlo_pricer.cpp`)
- Portable Randomness → Normal Distribution: transforms uniforms (evidence: `src/random.cpp`)
- Path Simulation → Asian and Barriers: evaluates paths
- Path Simulation → Portable Randomness: draws normals (evidence: `src/path_dependent_pricer.cpp`)
- Path Simulation → Running Statistics: accumulates estimates (evidence: `src/path_dependent_pricer.cpp`)
- Asian and Barriers → Terminal Payoffs: adapts terminal payoff
- Asian and Barriers → Black-Scholes Formulas: uses pricing inputs
- Implied Volatility → Black-Scholes Formulas: solves against prices (evidence: `src/implied_vol.cpp`)
- Exotic Formulas → Normal Distribution: uses distribution (evidence: `src/exotic_formulas.cpp`)
- Monte Carlo Greeks → Monte Carlo: revalues bumped inputs (evidence: `src/monte_carlo_greeks.cpp`)
- Monte Carlo Greeks → Portable Randomness: simulates paths (evidence: `src/monte_carlo_greeks.cpp`)
- Monte Carlo Greeks → Running Statistics: estimates Greeks (evidence: `src/monte_carlo_greeks.cpp`)
- Library Caller → Path Simulation: requests exotic price (evidence: `README.md`)
- Library Caller → Implied Volatility: solves volatility (evidence: `README.md`)
- Library Caller → Monte Carlo Greeks: estimates Greeks (evidence: `README.md`)
- Library Caller → Exotic Formulas: uses closed forms (evidence: `README.md`)
