Crate quantrs

Source
Expand description

This crate is designed to be simple and easy to use library for options pricing, portfolio optimization, and risk analysis. It is not intended to be a full-fledged quantitative finance library. The goal is to provide library for pricing options, calculating greeks, and performing basic risk analysis without the need to write complex code or have a PhD in reading quantlib documentation. The library is still in the early stages of development, and many features are not yet implemented.

Compared to other popular options pricing libraries, quantrs is significantly faster:

  • 29x faster than QuantLib (python bindings)
  • 113x faster than py_vollib
  • 15x faster than RustQuant
  • 2.7x faster than Q-Fin

You can find the benchmarks at quantrs.pages.dev/report.

§Options Pricing

For now quantrs only supports options pricing. The following features are available:

  • Option types: European, American, Asian, Rainbow, Binary Cash-or-Nothing, Binary Asset-or-Nothing
  • Option pricing: Black-Scholes, Binomial Tree, Monte Carlo Simulation
  • Greeks: Delta, Gamma, Theta, Vega, Rho
  • Implied volatility
use quantrs::options::*;

let option = BinaryOption::cash_or_nothing(Instrument::new().with_spot(100.0), 85.0, 0.78, OptionType::Call);
let model = BlackScholesModel::new(0.05, 0.2);
let price = model.price(&option);
let greeks = Greeks::calculate(&model, &option);

Modules§

options
Module for calculating the price and Greeks of various types of options.

Macros§

check_is_call
Check if the option is a call.
check_is_put
Check if the option is a put.
check_same_expiration_date
Check if the options have the same expiration date.
log_debug
Log a debug message.
log_error
Log an error message.
log_info
Log an info message.
log_trace
Log a trace message.
log_warn
Log a warning message.
range
Return a range with a given step.
square
Calculate the square of a number.