VelesQuant is a high-performance financial valuation library written in C++ and exposed to Python using pybind11. It provides tools for pricing complex financial derivatives using advanced models and numerical techniques.
VelesQuant provides high-level Python wrappers in velesquant.models for ease of use.
import numpy as np
from velesquant.models import SabrModel, HestonModel, HullWhiteModel
from velesquant.market.curves import DiscountCurve
# --- SABR Volatility Model ---
sabr = SabrModel(maturity=1.0, forward=100.0, beta=0.5)
# Calibrate to market data
strikes = [90.0, 100.0, 110.0]
quotes = [0.25, 0.20, 0.22] # Implied volatilities
sabr.calibrate(strikes=strikes, quotes=quotes, calibration_target="Volatility")
print(f"Calibrated SABR: alpha={sabr.alpha:.4f}, nu={sabr.nu:.4f}, rho={sabr.rho:.4f}")
# Get implied volatility for a strike
iv = sabr.implied_vol(105.0)
# --- Heston Stochastic Volatility ---
heston = HestonModel(spot=100.0, var0=0.04, kappa=2.0, theta=0.04, xi=0.3, rho=-0.7, seed=42)
# Price a vanilla option
price = heston.price_option(maturity=1.0, forward=100.0, strike=100.0, option_type="call")
# --- Hull-White Interest Rate Model ---
# 1. Define a Discount Curve
curve = DiscountCurve(
times=[0.0, 1.0, 5.0, 10.0],
dfs=[1.0, 0.95, 0.80, 0.65]
)
# 2. Initialize Model
hw = HullWhiteModel(kappa=0.1, sigma=0.01)
# 3. Price a Swaption
from velesquant.instruments.rates import Swaption
swaption = Swaption(expiry=1.0, tenor=5.0, strike=0.03, pay_frequency=0.5)
price = hw.price(swaption, curve)
# 4. Simulate Short Rate (Vectorized)
times = np.array([0.25, 0.5, 0.75, 1.0])
paths = hw.simulate(times, curve)| Model | Class | Description |
|---|---|---|
| SABR | SabrModel |
Stochastic Alpha Beta Rho volatility model |
| Heston | HestonModel |
Stochastic variance model |
| Local Vol | LocalVolModel |
Local volatility from SABR slices |
| Hull-White | HullWhiteModel |
1-Factor short rate model |
| ShortRate2F | ShortRate2FPDEModel |
2-Factor G2++ short rate model |
| CMS | CMSModel |
Constant Maturity Swap pricing |
| CMS Spread | CMSSpreadModel |
CMS Spread Option pricing (Copula) |
| Basket | LogNormalBasketModel |
Multi-asset Log-Normal Basket |
| Quantoed CMS | QuantoedCMSModel |
Quantoed Constant Maturity Swap |
| Quantoed Spread | QuantoedCMSSpreadModel |
Quantoed CMS Spread Option |
| Heston Hull-White | HybridHWModel |
Hybrid Equity-Interest Rate Model |
For a comprehensive list of supported financial instruments and their pricing methods, please refer to Supported Instruments.
VelesQuant is built for extreme performance:
- C++20 Core: Leveraging modern language features for safety and speed.
- SIMD Optimized: Critical numerical paths are designed for vectorization.
- Multi-threaded: Parallel PDE solvers and Monte Carlo simulations utilizing OpenMP.
- QuantLib Integration: Built on top of the industry-standard QuantLib library.
The recommended way to develop is using uv for lightning-fast environment management:
uv sync --all-extras
uv run pytestAlternatively, using standard pip:
pip install ".[dev]"
pytestIf using poetry:
poetry run pytest./build/tests_cpp/velesquant_testsWe welcome contributions! Please follow these steps:
- Bug Reports: Open an issue describing the bug and providing a reproducible example.
- Feature Requests: Use the issue tracker to propose new features.
- Pull Requests:
- Fork the repository.
- Create a feature branch.
- Ensure all C++ and Python tests pass.
- Submit a PR with a clear description of changes.