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.

Features

Below is a checklist of features that are: + [x] currently implemented, or + [ ] I would like to implement in the future.

Automatic Differentiation

Currently only gradients can be computed. Suggestions on how to extend the functionality to Hessian matrices are definitely welcome.

Option Pricers

The stochastic process generators can be used to price path-dependent options via Monte-Carlo.

Stochastic Processes and Short Rate Models

The following is a list of stochastic processes that can be generated.

Bonds

Mathematics & Statistics

Helper Functions/Macros

A collection of utility functions and macros.

How-tos:

Compute gradients:

```rust use RustQuant::autodiff::*;

fn main() { // Create a new Tape. let t = Tape::new();

// Assign variables.
let x = t.var(0.5);
let y = t.var(4.2);

// Define a function.
let z = x * y + x.sin();

// Accumulate the gradient.
let grad = z.accumulate();

println!("Function = {}", z);
println!("Gradient = {:?}", grad.wrt([x, y]));

} ```

Price options:

```rust use RustQuant::options::*;

fn main() { let VanillaOption = EuropeanOption { initialprice: 100.0, strikeprice: 110.0, riskfreerate: 0.05, volatility: 0.2, dividendrate: 0.02, timeto_maturity: 0.5, };

let prices = VanillaOption.price();

println!("Call price = {}", prices.0);
println!("Put price = {}", prices.1);

} ```

Generate stochastic processes:

```rust use RustQuant::stochastics::*;

fn main() { // Create new GBM with mu and sigma. let gbm = GeometricBrownianMotion::new(0.05, 0.9);

// Generate path using Euler-Maruyama scheme.
// Parameters: x_0, t_0, t_n, n, sims, parallel.
let output = (&gbm).euler_maruyama(10.0, 0.0, 0.5, 10, 1, false);

println!("GBM = {:?}", output.trajectories);

} ```