Pryce is a cutting-edge, open-source compiler infrastructure for quantitative finance, derivatives pricing, and risk analytics. Built atop LLVM/MLIR, Pryce empowers quants, HFT engineers, and researchers to express, simulate, and risk financial contracts in a symbolic, human-readable DSL—then compiles them to lightning-fast native code.
- Expressive DSL: Write contracts, payoffs, and risk logic in a symbolic, readable form.
- Compiler-Grade Speed: Leverage MLIR/LLVM for high-performance Monte Carlo, scenario, and adjoint risk analytics.
- Research to Production: Go from prototype to HFT-grade execution in one pipeline.
- Extensible: Easily add new financial instruments, risk hooks, or analytics.
- Transparency: Symbolic-to-executable workflow, golden outputs, and full test coverage.
Pryce supports advanced variance reduction strategies for Monte Carlo simulation, used by real quant desks to achieve accurate pricing with fewer paths:
- Antithetic Variates: Simulate pairs of paths with opposite random draws for lower variance.
- Control Variates: Use analytical prices (e.g., Black-Scholes) to adjust MC results for hard-to-simulate payoffs.
- Importance Sampling: Shift probability measures to sample rare, impactful regions more efficiently.
Why it matters:
- Demonstrates deep quant knowledge (variance convergence)
- Shows compiler control over simulation mechanics
- Bridges numerical finance and compiler IR execution
See full example and results: examples/variance_reduction/
graph TD;
A[Quant/Researcher: YAML/DSL] --> B[YAML→MLIR Converter];
B --> C[Symbolic MLIR Risk DSL];
C --> D[MLIR Lowering Passes];
D --> E[Lowered MLIR: MC, Greeks, Scenarios];
E --> F[LLVM IR → Native Code];
F --> G[Runtime: Scenario/Shock Engine];
G --> H[Output: CSV/Arrow];
- Custom MLIR Dialect:
simulate_gbm,payoff_call,payoff_digital_call,discount, and more. - Automatic Differentiation: Symbolic adjoint/Enzyme integration for Greeks (Delta, Gamma, Vega).
- Scenario & Stress Testing: Scenario grid, shocks, and full risk analytics.
- Symbolic Contract DSL: Human-readable contract/risk logic, YAML→MLIR conversion.
- Golden Outputs & Fuzzing: Regression, fuzz, and property-based tests for reliability.
- Professional Examples: Each feature is showcased in a dedicated, reproducible example folder.
- Clone & Setup:
git clone <your-fork-or-upstream> cd pryce ./scripts/setup_env.sh
- Build:
mkdir build && cd build cmake .. && make -j
- Run an Example:
cd examples/european_call bash run_pipeline.sh python3 black_scholes.py
For full details, see steps.md and each example's README.
- What: Monte Carlo pricing of a vanilla European call option.
- How: Symbolic MLIR input (
call_option.mlir) simulates GBM, computes call payoff, averages, discounts. - Compare: Python script (
black_scholes.py) for analytical price; pipeline script for MC output. - Why it matters: Classic quant test, demonstrates correctness and speed.
- What: Pricing a digital (binary) option with non-linear payoff.
- How: Custom op
payoff_digital_callin MLIR; scenario grid and MC simulation. - Compare: Analytical Black-Scholes digital price in Python.
- Why it matters: Shows extensibility and ability to handle exotic payoffs and conditional logic.
- What: Automatic differentiation (adjoint/Enzyme) for Greeks (Delta, Gamma) of a call option.
- How: Symbolic pricing logic differentiated wrt spot; both price and sensitivities compiled and executed natively.
- Compare: Python script for analytical Greeks.
- Why it matters: Demonstrates compiler IR transformation, risk sensitivity, and numerical stability.
- What: Portfolio-defining symbolic risk DSL: contracts, risk hooks, scenarios, and adjoint analytics in one pipeline.
- How:
- Write contract/risk logic in YAML or symbolic MLIR
- Convert with
yaml_to_mlir.py - Lower, compile, and run scenario grid with
run_pipeline.sh - Output: scenario P&L, Delta, Gamma, Vega, shocked results
- Why it matters: This is the infrastructure used by top HFT/quant firms for large-scale scenario and risk management.
- What: Advanced variance reduction strategies for Monte Carlo simulation, used by real quant desks to achieve accurate pricing with fewer paths:
- Antithetic Variates: Simulate pairs of paths with opposite random draws for lower variance.
- Control Variates: Use analytical prices (e.g., Black-Scholes) to adjust MC results for hard-to-simulate payoffs.
- Importance Sampling: Shift probability measures to sample rare, impactful regions more efficiently.
- Why it matters: Demonstrates deep quant knowledge (variance convergence) and shows compiler control over simulation mechanics.
mlir/include/DerivLab/— TableGen dialect and opsmlir/lib/— C++ dialect/lowering/transform passesruntime/— C++ runtime helpers (MC, Black-Scholes, scenario engine)examples/— Advanced, reproducible example foldersscripts/— Helper scripts for pipeline, regression, fuzz, and benchmarkingtest/— Unit, integration, regression, and fuzz testsdocs/— Architecture, usage, and design documentation
- See each example's
README.mdfor details. docs/architecture.mdfor in-depth design.- Contributions, issues, and feature requests welcome!
Pryce is designed for clarity, extensibility, and performance. Whether you’re a quant researcher, HFT engineer, or academic, Pryce lets you:
- Prototype new contracts and risk logic
- Validate and benchmark MC vs analytical results
- Run scenario and adjoint risk analytics at scale
- Build the next generation of quant finance infrastructure
ready to price, risk, and innovate? welcome to Pryce.
built with ❤️ by aditi ramakrishnan