Giter Site home page Giter Site logo

avhz / rustquant Goto Github PK

View Code? Open in Web Editor NEW
969.0 28.0 105.0 49.79 MB

Rust library for quantitative finance.

Home Page: https://docs.rs/RustQuant

License: Apache License 2.0

Rust 99.92% HTML 0.08%
finance math mathematics quantitative-finance rust rust-lang quantlib machine-learning option-pricing regression statistics stochastic-processes trading

rustquant's Introduction

License Crates.io Crates.io GitHub Repo stars

GitHub Workflow Status Codecov Dependencies

Discord

A Rust library for quantitative finance.

๐ŸŽฏ If you are an experienced quant developer in any language and would like to help out, feel free to contact me!

Modules

Module Description
autodiff Algorithmic adjoint differentiation (AAD) for efficiently computing gradients of scalar output functions $f: \mathbb{R}^n \rightarrow \mathbb{R}$.
data Data types that can be used for pricing and similar tasks (curves, term-structures, surfaces, etc). Methods for reading and writing data from/to various sources (CSV, JSON, Parquet). Can also download data from Yahoo! Finance.
error RustQuant error handling module.
instruments Various implementations for instruments like Bonds and Options, and the pricing of them. Others coming in the future (swaps, futures, CDSs, etc).
iso A few ISO code implementations. Currently: ISO-4217 (currency codes), ISO-3166 (country codes), ISO-10383 (market identifier codes).
math Statistical distributions and their related functions (PDF, CDF, CF, etc), Fast Fourier Transform (FFT), numerical integration (double-exponential quadrature), optimisation/root-finding (gradient descent, Newton-Raphson), and risk-reward metrics. Also some sequence methods such as linspace and cumsum.
ml Currently only linear and logistic regression, along with k-nearest neighbours classification are implemented. More to come in the future.
macros Currently only plot_vector!() and assert_approx_equal!().
models Various models commonly used in quantitative finance, such as the various forms of Brownian Motion, short rate models, curve models, etc.
money Implementations for Cashflows, Currencies, and Quotes, and similar types.
portfolio Implementation of a portfolio type, which is a collection (HashMap) of Positions.
stochastics Stochastic process generators for Brownian Motion (standard, arithmetic, fractional, and geometric) and various short-rate models (CIR, OU, Vasicek, Hull-White, etc).
time Time and date functionality, such as DayCounter, calendars, constants, conventions, schedules, etc.
trading Currently only a basic limit order book (LOB). Hopefully adding additional trading tools in the future.

Examples

See /examples for various uses of RustQuant. You can run them with:

cargo run --example <example>

Note

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.

rustquant's People

Contributors

0xjepsen avatar aatmunbaxi avatar adriley avatar autoparallel avatar avhz avatar chammika-become avatar dancixx avatar dependabot[bot] avatar eopb avatar github-actions[bot] avatar joaquinbejar avatar joshleveck avatar kinrezc avatar lucaschinnerlbain avatar lukaskiss222 avatar maacl avatar meetthepatel avatar nicolasfrantzen avatar otangee avatar potatoboiler avatar qiweiii avatar robertchristensen avatar s3bru avatar simong85 avatar uzaaft avatar y5 avatar yfnaji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustquant's Issues

Documentation: improve docs.

Just generally improve the documentation, especially when it comes to explaining mathematical aspects of the library such that it is as user-friendly as possible.

Lookback (floating strike) options Monte Carlo pricer test failing.

---- options::lookback::tests::test_lookback_floating stdout ----
thread 'options::lookback::tests::test_lookback_floating' panicked at '
Left: 18.11050747911399,
Right: 25.35335527250393,
Delta: 0.5
', src/options/lookback.rs:273:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Implement proper error handling.

I am writing my master thesis currently so I have been lazy and not made use of Rust's Result and Option enums like I should have.

Find workaround for using `#[pyclass]` on a struct with lifetimes.

In autodiff::Variable, creating Python bindings is currently not possible due to #[pyclass] not being compatible on structs that have lifetime annotations, since Rust can no longer keep track of the references.

What I have:

/// Struct to contain the initial variables.
#[derive(Clone, Copy, Debug)]
pub struct Variable<'v> {
    /// Pointer to the tape.
    pub tape: &'v Tape,
    /// Index to the node.
    pub index: usize,
    /// Value associated to the node.
    pub value: f64,
}

What I wanted:

use pyo3::prelude::*;

/// Struct to contain the initial variables.
#[derive(Clone, Copy, Debug)]
#[pyclass]                           // <- This
pub struct Variable<'v> {
    /// Pointer to the tape.
    pub tape: &'v Tape,
    /// Index to the node.
    pub index: usize,
    /// Value associated to the node.
    pub value: f64,
}

I possibly need to change the Variable implementation such that it no longer uses explicit lifetime annotations. Open to suggestions.

[Enhancement] signatures of `.drift()` and `.diffusion()`

At present, the implementations of StochasticProcess::drift() and StochasticProcess::diffusion() do not allow for implementation of models such as Ho-Lee and Hull-White which have time-varying parameters. I propose changing their signatures to accept another parameter t: f64 for the point in time to compute the drift/diffusion.

Additionally this would mean changing the implementation of the euler_murayama() function slightly. I can PR all of these changes and change the existing stochastics implementations if approved.

[Enhancement] Bond pricing ergonomics

With the current implementation of bonds, the user is required to initialize the struct with predefined maturity and price-at-time t.
From the little research I've done it seems that closed-form zero coupon bond pricing formulae allow for computation at arbitrary maturation T and times t (so long as T >= t).

So the current trait ZeroCouponBond is a little inflexible. How about computing the price via ZeroCouponBond::price(&self, t: f64, T: f64), where t is the time the user wants to compute the price at and T is the maturation?

Migrate another library

Hi @avhz

i have started to develop a stochastic library in rust too. If you approve I can migrate my code and processes into your library, because I dont want to make a totally different like this. It would be great if the community has one strong and featuredull quant and stochastic analysis library in rust.

https://github.com/dancixx/stochastic-rs

Problem testing 'stochastics' functions. Can't plot.

Example error:

---- stochastics::cox_ingersoll_ross::tests::test_cox_ingersoll_ross stdout ----
thread 'stochastics::cox_ingersoll_ross::tests::test_cox_ingersoll_ross' panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x7f9c19cec269'

Implement calibration module using `argmin` crate.

All pricing models should be able to be calibrated to market prices.

A nice Crate called argmin available here looks like it can achieve this, using Brent method or something similar.

Can also perform calibration using RustQuant::autodiff possibly ?

This requires the ability to read in price data from .csv or .json, for example. See related issue #23

Need suggestions on how to structure the Python bindings.

It seems like a tedious task to maintain two separate libraries, one for "base" RustQuant and a separate one for the Python bindings.

Is there a better way?
I don't want to litter the base library with things like #[pyclass], #[new] and #[pymethods, but keeping two separate copies seems unnecessary.

Decrease compile time.

Compile time increased quite substantially after adding Polars as a dependency.
Should look into reducing the compile time a bit if possible.

Pricers: caps and floors.

Caps/floors are a series of caplets/floorlets (basically call/put options) on something like an interest rate or inflation rate.

Pricing is discussed in detail in Interest Rate Models by Brigo and Mercurio.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.