RustQuant
Rust library for quantitative finance tools.
Contact: rustquantcontact@gmail.com
Disclaimer: This is currently a free-time project and not a professional financial software library. Nothing in this library should be taken as financial advice, and I do not recommend you to use it for trading or making financial decisions.
Some references used:
- Options, Futures, and Other Derivatives - John C. Hull
- Interest Rate Models - Theory and Practice (With Smile, Inflation and Credit) - Damiano Brigo & Fabio Mercurio
- Monte Carlo Methods in Financial Engineering - Paul Glasserman
- Evaluating Derivatives - Principles and Techniques of Algorithmic Differentiation - Andreas Griewank & Andrea Walther
- Stochastic Calculus for Finance II: Continuous-Time Models - Steven E. Shreve
- Option Pricing Formulas - Espen Gaarder Haug
- Modern Computational Finance: AAD and Parallel Simulations - Antoine Savine
Table of Contents
- Automatic Differentiation
- Option Pricers
- Stochastic Processes and Short Rate Models
- Bonds
- Mathematics and Statistics
- Helper Functions and Macros
- How-tos
Automatic Differentiation
Currently only gradients can be computed. Suggestions on how to extend the functionality to Hessian matrices are definitely welcome.
- Forward (Tangent) Mode
- Implementation via Dual Numbers.
- Useful when number of outputs is larger than number of inputs.
- i.e. for functions $f:\mathbb{R}^n \rightarrow \mathbb{R}^m$, where $m \gg n$
- Reverse (Adjoint) Mode
- Implementation via Operator and Function Overloading.
- Useful when number of outputs is smaller than number of inputs.
- i.e for functions $f:\mathbb{R}^n \rightarrow \mathbb{R}^m$, where $m \ll n$
Option Pricers
-
Closed-form price solutions:
- Barrier
- European Options
- Greeks/Sensitivities
- Lookback
- Heston Model
- Basket
- Rainbow
- American
- Heston Model
-
Lattice models:
- Binomial Tree (Cox-Ross-Rubinstein)
The stochastic process generators can be used to price path-dependent options via Monte-Carlo.
- Monte Carlo pricing:
- Lookback
- Asian
- Chooser
- Barrier
Stochastic Processes and Short Rate Models
The following is a list of stochastic processes that can be generated.
- Brownian Motion
- Geometric Brownian Motion
- $dX_t = \mu X_t dt + \sigma X_t dW_t$
- Models: Black-Scholes (1973), Rendleman-Bartter (1980)
- Cox-Ingersoll-Ross (1985)
- $dX_t = (\theta - \alpha X_t)dt + \sqrt{r_t} \sigma dW_t$
- Ornstein-Uhlenbeck process
- $dX_t = \theta(\mu - X_t)dt + \sigma dW_t$
- Models: Vasicek (1977)
- Ho-Lee (1986)
- $dX_t = \theta_t dt + \sigma dW_t$
- Hull-White (1990)
- $dX_t = (\theta - \alpha X_t)dt + \sigma_t dW_t$
- Black-Derman-Toy (1990)
- $d\ln(X) = \left[ \theta_t + \frac{\sigma_t'}{\sigma_t}\ln(X) \right]dt + \sigma_t dW_t$
- $d\ln(X) = \theta_t dt + \sigma dW_t$
- Merton's model (1973)
- $X_t = X_0 + at + \sigma W_t^*$
- $dX_t = adt + \sigma dW_t^*$
Bonds
Most will follow the notation and formulas in John C. Hull's Options, Futures, and Other Derivatives.
- Prices:
- The Vasicek Model
- The Cox, Ingersoll, and Ross Model
- The Rendleman and Bartter Model
- The Ho–Lee Model
- The Hull–White (One-Factor) Model
- The Black–Derman–Toy Model
- The Black–Karasinski Model
- Duration
- Convexity
Mathematics and Statistics
- Risk-Reward Measures (Sharpe, Treynor, Sortino, etc)
- Standard Normal Distribution (Distribution/Density functions, and generation of variates)
- Characteristic functions:
- Gaussian
- Bernoulli
- Binomial
- Poisson
- Uniform (discrete & continuous)
- Chi-Squared
- Gamma
- Exponential
- Numerical Integration (needed for Heston model, for example)
- Interpolation
- Newton-Raphson
Helper Functions and Macros
A collection of utility functions and macros.
- Plot a vector.
- Write vector to file.
- Cumulative sum of vector.
- Linearly spaced sequence.
-
assert_approx_equal!
How-tos
Compute gradients:
use *;
Price options:
use *;
Generate stochastic processes:
use *;