rustquant


Namerustquant JSON
Version 0.0.17 PyPI version JSON
download
home_pageNone
SummaryA Rust library for quantitative finance tools.
upload_time2023-06-05 12:40:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseGPL-3.0-or-later
keywords finance quantitative option-pricing statistics quantlib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
![](./Images/logo.png)

<p align="center">
    <a href="#license" alt="license">
        <img alt="License" src="https://img.shields.io/github/license/avhz/RustQuant">
    <a href="#build" alt="build">
        <img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/avhz/RustQuant/rust.yml">
    <a href="#downloads" alt="downloads">
        <img alt="Crates.io" src="https://img.shields.io/crates/d/RustQuant">
    <a href="#stars" alt="stars">
        <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/avhz/RustQuant">
    <a href="#version" alt="version">
        <img alt="Crates.io" src="https://img.shields.io/crates/v/RustQuant">
    <a href="#codecov" alt="codecov">
        <img alt="Codecov" src="https://img.shields.io/codecov/c/gh/avhz/RustQuant">
    <a href="#deps" alt="deps">
        <img alt="Dependencies" src="https://deps.rs/repo/github/avhz/RustQuant/status.svg">
</p>

Rust library for quantitative finance tools. 

:dart: I want to hit a stable and legitimate `v1.0.0` by the end of 2023, so any and all feedback, suggestions, or contributions are strongly welcomed! 

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. 

## :newspaper: Latest features

+ Download time series data from [Yahoo! Finance](https://finance.yahoo.com/).
+ Read (write) from (to) `.csv`, `.json`, and `.parquet` files, using [Polars `DataFrames`](https://pola-rs.github.io/polars-book/).
+ Arithmetic Brownian Motion generator. 
+ Gamma, exponential, and chi-squared distributions.
+ Forward start option pricer (Rubinstein 1990 formula).
+ Gap option and cash-or-nothing option pricers (currently adding more binary options).
+ Asian option pricer (closed-form solution for continuous geometric average).
+ Heston Model option pricer (uses the tanh-sinh quadrature numerical integrator).
+ Tanh-sinh (double exponential) quadrature for evaluating integrals.
    + Plus other basic numerical integrators (midpoint, trapezoid, Simpson's 3/8).
+ Characteristic functions and density functions for common distributions:
    + Gaussian, Bernoulli, Binomial, Poisson, Uniform, Chi-Squared, Gamma, and Exponential.

# Table of Contents

1. [Automatic Differentiation](#autodiff)
2. [Option Pricers](#options)
3. [Stochastic Processes and Short Rate Models](#stochastics)
4. [Bonds](#bonds)
5. [Distributions](#distributions)
5. [Mathematics](#maths)
6. [Helper Functions and Macros](#helpers)
7. [How-tos](#howto)
8. [References](#references)


## :link: Automatic Differentiation <a name="autodiff"></a>

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

+ [x] 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$
+ [ ] 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$

## :money_with_wings: Option Pricers <a name="options"></a>

+ Closed-form price solutions:
    + [x] Heston Model
    + [x] Barrier
    + [x] European
    + [x] Greeks/Sensitivities
    + [x] Lookback
    + [x] Asian: Continuous Geometric Average 
    + [x] Forward Start 
    + [ ] Basket
    + [ ] Rainbow
    + [ ] American

+ Lattice models:
    + [x] Binomial Tree (Cox-Ross-Rubinstein)

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

+ Monte Carlo pricing:
    + [x] Lookback
    + [ ] Asian
    + [ ] Chooser
    + [ ] Barrier

## :chart_with_upwards_trend: Stochastic Processes and Short Rate Models <a name="stochastics"></a>

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

+ [x] Brownian Motion
+ [x] Arithmetic Brownian Motion
    + $dX_t = \mu dt + \sigma dW_t$
+ [x] Geometric Brownian Motion
    + $dX_t = \mu X_t dt + \sigma X_t dW_t$
    + Models: Black-Scholes (1973), Rendleman-Bartter (1980)
+ [x] Cox-Ingersoll-Ross (1985)
    + $dX_t = (\theta - \alpha X_t)dt + \sqrt{r_t} \sigma dW_t$
+ [x] 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^*$

## :chart_with_downwards_trend: Bonds <a name="bonds"></a>

+ Prices:
    + [X] The Vasicek Model
    + [x] 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

## :bar_chart: Distributions <a name="distributions"></a>

Probability density/mass functions, distribution functions, characteristic functions, etc. 

+ [x] Gaussian
+ [x] Bernoulli
+ [x] Binomial
+ [x] Poisson
+ [x] Uniform (discrete & continuous)
+ [x] Chi-Squared
+ [x] Gamma
+ [x] Exponential

## :triangular_ruler: Mathematics <a name="maths"></a>

+ Numerical Integration (needed for Heston model, for example):
    + [x] Tanh-Sinh (double exponential) quadrature 
    + [x] Composite Midpoint Rule
    + [x] Composite Trapezoidal Rule
    + [x] Composite Simpson's 3/8 Rule
+ [x] Risk-Reward Measures (Sharpe, Treynor, Sortino, etc)
+ [x] Newton-Raphson
+ [x] Standard Normal Distribution (Distribution/Density functions, and generation of variates)
+ [ ] Interpolation

## :handshake: Helper Functions and Macros <a name="helpers"></a>

A collection of utility functions and macros. 

+ [x] Plot a vector.
+ [x] Write vector to file.
+ [x] Cumulative sum of vector.
+ [x] Linearly spaced sequence.
+ [x] `assert_approx_equal!`

## :heavy_check_mark: How-tos <a name="howto"></a>

I would not recommend using RustQuant within any other libraries for some time, as it will most likely go through many breaking changes as I learn more Rust and settle on a decent structure for the library. 

:pray: I would greatly appreciate contributions so it can get to the `v1.0.0` mark ASAP.

### Download data from Yahoo! Finance:

You can download data from Yahoo! Finance into a Polars `DataFrame`.

```rust
use RustQuant::data::*;
use time::macros::date;

fn main() {
    // New YahooFinanceData instance. 
    // By default, date range is: 1970-01-01 to present. 
    let mut yfd = YahooFinanceData::new("AAPL".to_string());

    // Can specify custom dates (optional). 
    yfd.set_start_date(time::macros::datetime!(2019 - 01 - 01 0:00 UTC));
    yfd.set_end_date(time::macros::datetime!(2020 - 01 - 01 0:00 UTC));

    // Download the historical data. 
    yfd.get_price_history();

    println!("Apple's quotes: {:?}", yfd.price_history)
}
```

```bash
Apple's quotes: Some(shape: (252, 7)
┌────────────┬───────────┬───────────┬───────────┬───────────┬────────────┬───────────┐
│ date       ┆ open      ┆ high      ┆ low       ┆ close     ┆ volume     ┆ adjusted  │
│ ---        ┆ ---       ┆ ---       ┆ ---       ┆ ---       ┆ ---        ┆ ---       │
│ date       ┆ f64       ┆ f64       ┆ f64       ┆ f64       ┆ f64        ┆ f64       │
╞════════════╪═══════════╪═══════════╪═══════════╪═══════════╪════════════╪═══════════╡
│ 2019-01-02 ┆ 38.7225   ┆ 39.712502 ┆ 38.557499 ┆ 39.48     ┆ 1.481588e8 ┆ 37.994499 │
│ 2019-01-03 ┆ 35.994999 ┆ 36.43     ┆ 35.5      ┆ 35.547501 ┆ 3.652488e8 ┆ 34.209969 │
│ 2019-01-04 ┆ 36.1325   ┆ 37.137501 ┆ 35.950001 ┆ 37.064999 ┆ 2.344284e8 ┆ 35.670372 │
│ 2019-01-07 ┆ 37.174999 ┆ 37.2075   ┆ 36.474998 ┆ 36.982498 ┆ 2.191112e8 ┆ 35.590965 │
│ …          ┆ …         ┆ …         ┆ …         ┆ …         ┆ …          ┆ …         │
│ 2019-12-26 ┆ 71.205002 ┆ 72.495003 ┆ 71.175003 ┆ 72.477501 ┆ 9.31212e7  ┆ 70.798401 │
│ 2019-12-27 ┆ 72.779999 ┆ 73.4925   ┆ 72.029999 ┆ 72.449997 ┆ 1.46266e8  ┆ 70.771545 │
│ 2019-12-30 ┆ 72.364998 ┆ 73.172501 ┆ 71.305    ┆ 72.879997 ┆ 1.441144e8 ┆ 71.191582 │
│ 2019-12-31 ┆ 72.482498 ┆ 73.419998 ┆ 72.379997 ┆ 73.412498 ┆ 1.008056e8 ┆ 71.711739 │
└────────────┴───────────┴───────────┴───────────┴───────────┴────────────┴───────────┘)
```

### Read/write data:

```rust
use RustQuant::data::*;

fn main() {
    // New `Data` instance.
    let mut data = Data::new(
        format: DataFormat::CSV, // Can also be JSON or PARQUET.
        path: String::from("./file/path/read.csv")
    )

    // Read from the given file. 
    data.read().unwrap();

    // New path to write the data to. 
    data.path = String::from("./file/path/write.csv")
    data.write().unwrap();

    println!("{:?}", data.data)
}
```

### 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]));
}
```

### Compute integrals:

```rust
use RustQuant::math::*;

fn main() {
    // Define a function to integrate: e^(sin(x))
    fn f(x: f64) -> f64 {
        (x.sin()).exp()
    }

    // Integrate from 0 to 5.
    let integral = integrate(f, 0.0, 5.0);

    // ~ 7.18911925
    println!("Integral = {}", integral); 
}
```

### Price options:

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

fn main() {
    let VanillaOption = EuropeanOption {
        initial_price: 100.0,
        strike_price: 110.0,
        risk_free_rate: 0.05,
        volatility: 0.2,
        dividend_rate: 0.02,
        time_to_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);
}
```

## :book: References: <a name="references"></a>

+ John C. Hull - *Options, Futures, and Other Derivatives*
+ Damiano Brigo & Fabio Mercurio - *Interest Rate Models - Theory and Practice (With Smile, Inflation and Credit)*
+ Paul Glasserman - *Monte Carlo Methods in Financial Engineering*
+ Andreas Griewank & Andrea Walther - *Evaluating Derivatives - Principles and Techniques of Algorithmic Differentiation*
+ Steven E. Shreve - *Stochastic Calculus for Finance II: Continuous-Time Models*
+ Espen Gaarder Haug - *Option Pricing Formulas*
+ Antoine Savine - *Modern Computational Finance: AAD and Parallel Simulations*


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rustquant",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "finance,quantitative,option-pricing,statistics,quantlib",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/76/b7/e64ed301cbf1c186fc4b9e6dfdaec34abdc69797cfb7cf14e447cba9be1f/RustQuant-0.0.17.tar.gz",
    "platform": null,
    "description": "\n![](./Images/logo.png)\n\n<p align=\"center\">\n    <a href=\"#license\" alt=\"license\">\n        <img alt=\"License\" src=\"https://img.shields.io/github/license/avhz/RustQuant\">\n    <a href=\"#build\" alt=\"build\">\n        <img alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/avhz/RustQuant/rust.yml\">\n    <a href=\"#downloads\" alt=\"downloads\">\n        <img alt=\"Crates.io\" src=\"https://img.shields.io/crates/d/RustQuant\">\n    <a href=\"#stars\" alt=\"stars\">\n        <img alt=\"GitHub Repo stars\" src=\"https://img.shields.io/github/stars/avhz/RustQuant\">\n    <a href=\"#version\" alt=\"version\">\n        <img alt=\"Crates.io\" src=\"https://img.shields.io/crates/v/RustQuant\">\n    <a href=\"#codecov\" alt=\"codecov\">\n        <img alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/gh/avhz/RustQuant\">\n    <a href=\"#deps\" alt=\"deps\">\n        <img alt=\"Dependencies\" src=\"https://deps.rs/repo/github/avhz/RustQuant/status.svg\">\n</p>\n\nRust library for quantitative finance tools. \n\n:dart: I want to hit a stable and legitimate `v1.0.0` by the end of 2023, so any and all feedback, suggestions, or contributions are strongly welcomed! \n\nContact: rustquantcontact@gmail.com \n\n**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. \n\n## :newspaper: Latest features\n\n+ Download time series data from [Yahoo! Finance](https://finance.yahoo.com/).\n+ Read (write) from (to) `.csv`, `.json`, and `.parquet` files, using [Polars `DataFrames`](https://pola-rs.github.io/polars-book/).\n+ Arithmetic Brownian Motion generator. \n+ Gamma, exponential, and chi-squared distributions.\n+ Forward start option pricer (Rubinstein 1990 formula).\n+ Gap option and cash-or-nothing option pricers (currently adding more binary options).\n+ Asian option pricer (closed-form solution for continuous geometric average).\n+ Heston Model option pricer (uses the tanh-sinh quadrature numerical integrator).\n+ Tanh-sinh (double exponential) quadrature for evaluating integrals.\n    + Plus other basic numerical integrators (midpoint, trapezoid, Simpson's 3/8).\n+ Characteristic functions and density functions for common distributions:\n    + Gaussian, Bernoulli, Binomial, Poisson, Uniform, Chi-Squared, Gamma, and Exponential.\n\n# Table of Contents\n\n1. [Automatic Differentiation](#autodiff)\n2. [Option Pricers](#options)\n3. [Stochastic Processes and Short Rate Models](#stochastics)\n4. [Bonds](#bonds)\n5. [Distributions](#distributions)\n5. [Mathematics](#maths)\n6. [Helper Functions and Macros](#helpers)\n7. [How-tos](#howto)\n8. [References](#references)\n\n\n## :link: Automatic Differentiation <a name=\"autodiff\"></a>\n\nCurrently only gradients can be computed. Suggestions on how to extend the functionality to Hessian matrices are definitely welcome. \n\n+ [x] Reverse (Adjoint) Mode\n    + Implementation via Operator and Function Overloading.\n    + Useful when number of outputs is *smaller* than number of inputs. \n        + i.e for functions $f:\\mathbb{R}^n \\rightarrow \\mathbb{R}^m$, where $m \\ll n$\n+ [ ] Forward (Tangent) Mode\n    + Implementation via Dual Numbers.\n    + Useful when number of outputs is *larger* than number of inputs. \n        + i.e. for functions $f:\\mathbb{R}^n \\rightarrow \\mathbb{R}^m$, where $m \\gg n$\n\n## :money_with_wings: Option Pricers <a name=\"options\"></a>\n\n+ Closed-form price solutions:\n    + [x] Heston Model\n    + [x] Barrier\n    + [x] European\n    + [x] Greeks/Sensitivities\n    + [x] Lookback\n    + [x] Asian: Continuous Geometric Average \n    + [x] Forward Start \n    + [ ] Basket\n    + [ ] Rainbow\n    + [ ] American\n\n+ Lattice models:\n    + [x] Binomial Tree (Cox-Ross-Rubinstein)\n\nThe stochastic process generators can be used to price path-dependent options via Monte-Carlo.\n\n+ Monte Carlo pricing:\n    + [x] Lookback\n    + [ ] Asian\n    + [ ] Chooser\n    + [ ] Barrier\n\n## :chart_with_upwards_trend: Stochastic Processes and Short Rate Models <a name=\"stochastics\"></a>\n\nThe following is a list of stochastic processes that can be generated.\n\n+ [x] Brownian Motion\n+ [x] Arithmetic Brownian Motion\n    + $dX_t = \\mu dt + \\sigma dW_t$\n+ [x] Geometric Brownian Motion\n    + $dX_t = \\mu X_t dt + \\sigma X_t dW_t$\n    + Models: Black-Scholes (1973), Rendleman-Bartter (1980)\n+ [x] Cox-Ingersoll-Ross (1985)\n    + $dX_t = (\\theta - \\alpha X_t)dt + \\sqrt{r_t} \\sigma dW_t$\n+ [x] Ornstein-Uhlenbeck process\n    + $dX_t = \\theta(\\mu - X_t)dt + \\sigma dW_t$\n    + Models: Vasicek (1977)\n+ [ ] Ho-Lee (1986)\n    + $dX_t = \\theta_t dt + \\sigma dW_t$\n+ [ ] Hull-White (1990)\n    + $dX_t = (\\theta - \\alpha X_t)dt + \\sigma_t dW_t$\n+ [ ] Black-Derman-Toy (1990)\n    + $d\\ln(X) = \\left[ \\theta_t + \\frac{\\sigma_t'}{\\sigma_t}\\ln(X) \\right]dt + \\sigma_t dW_t$\n    + $d\\ln(X) = \\theta_t dt + \\sigma dW_t$\n+ [ ] Merton's model (1973)\n    + $X_t = X_0 + at + \\sigma W_t^*$\n    + $dX_t = adt + \\sigma dW_t^*$\n\n## :chart_with_downwards_trend: Bonds <a name=\"bonds\"></a>\n\n+ Prices:\n    + [X] The Vasicek Model\n    + [x] The Cox, Ingersoll, and Ross Model\n    + [ ] The Rendleman and Bartter Model\n    + [ ] The Ho\u2013Lee Model\n    + [ ] The Hull\u2013White (One-Factor) Model\n    + [ ] The Black\u2013Derman\u2013Toy Model\n    + [ ] The Black\u2013Karasinski Model\n+ [ ] Duration\n+ [ ] Convexity\n\n## :bar_chart: Distributions <a name=\"distributions\"></a>\n\nProbability density/mass functions, distribution functions, characteristic functions, etc. \n\n+ [x] Gaussian\n+ [x] Bernoulli\n+ [x] Binomial\n+ [x] Poisson\n+ [x] Uniform (discrete & continuous)\n+ [x] Chi-Squared\n+ [x] Gamma\n+ [x] Exponential\n\n## :triangular_ruler: Mathematics <a name=\"maths\"></a>\n\n+ Numerical Integration (needed for Heston model, for example):\n    + [x] Tanh-Sinh (double exponential) quadrature \n    + [x] Composite Midpoint Rule\n    + [x] Composite Trapezoidal Rule\n    + [x] Composite Simpson's 3/8 Rule\n+ [x] Risk-Reward Measures (Sharpe, Treynor, Sortino, etc)\n+ [x] Newton-Raphson\n+ [x] Standard Normal Distribution (Distribution/Density functions, and generation of variates)\n+ [ ] Interpolation\n\n## :handshake: Helper Functions and Macros <a name=\"helpers\"></a>\n\nA collection of utility functions and macros. \n\n+ [x] Plot a vector.\n+ [x] Write vector to file.\n+ [x] Cumulative sum of vector.\n+ [x] Linearly spaced sequence.\n+ [x] `assert_approx_equal!`\n\n## :heavy_check_mark: How-tos <a name=\"howto\"></a>\n\nI would not recommend using RustQuant within any other libraries for some time, as it will most likely go through many breaking changes as I learn more Rust and settle on a decent structure for the library. \n\n:pray: I would greatly appreciate contributions so it can get to the `v1.0.0` mark ASAP.\n\n### Download data from Yahoo! Finance:\n\nYou can download data from Yahoo! Finance into a Polars `DataFrame`.\n\n```rust\nuse RustQuant::data::*;\nuse time::macros::date;\n\nfn main() {\n    // New YahooFinanceData instance. \n    // By default, date range is: 1970-01-01 to present. \n    let mut yfd = YahooFinanceData::new(\"AAPL\".to_string());\n\n    // Can specify custom dates (optional). \n    yfd.set_start_date(time::macros::datetime!(2019 - 01 - 01 0:00 UTC));\n    yfd.set_end_date(time::macros::datetime!(2020 - 01 - 01 0:00 UTC));\n\n    // Download the historical data. \n    yfd.get_price_history();\n\n    println!(\"Apple's quotes: {:?}\", yfd.price_history)\n}\n```\n\n```bash\nApple's quotes: Some(shape: (252, 7)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 date       \u2506 open      \u2506 high      \u2506 low       \u2506 close     \u2506 volume     \u2506 adjusted  \u2502\n\u2502 ---        \u2506 ---       \u2506 ---       \u2506 ---       \u2506 ---       \u2506 ---        \u2506 ---       \u2502\n\u2502 date       \u2506 f64       \u2506 f64       \u2506 f64       \u2506 f64       \u2506 f64        \u2506 f64       \u2502\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n\u2502 2019-01-02 \u2506 38.7225   \u2506 39.712502 \u2506 38.557499 \u2506 39.48     \u2506 1.481588e8 \u2506 37.994499 \u2502\n\u2502 2019-01-03 \u2506 35.994999 \u2506 36.43     \u2506 35.5      \u2506 35.547501 \u2506 3.652488e8 \u2506 34.209969 \u2502\n\u2502 2019-01-04 \u2506 36.1325   \u2506 37.137501 \u2506 35.950001 \u2506 37.064999 \u2506 2.344284e8 \u2506 35.670372 \u2502\n\u2502 2019-01-07 \u2506 37.174999 \u2506 37.2075   \u2506 36.474998 \u2506 36.982498 \u2506 2.191112e8 \u2506 35.590965 \u2502\n\u2502 \u2026          \u2506 \u2026         \u2506 \u2026         \u2506 \u2026         \u2506 \u2026         \u2506 \u2026          \u2506 \u2026         \u2502\n\u2502 2019-12-26 \u2506 71.205002 \u2506 72.495003 \u2506 71.175003 \u2506 72.477501 \u2506 9.31212e7  \u2506 70.798401 \u2502\n\u2502 2019-12-27 \u2506 72.779999 \u2506 73.4925   \u2506 72.029999 \u2506 72.449997 \u2506 1.46266e8  \u2506 70.771545 \u2502\n\u2502 2019-12-30 \u2506 72.364998 \u2506 73.172501 \u2506 71.305    \u2506 72.879997 \u2506 1.441144e8 \u2506 71.191582 \u2502\n\u2502 2019-12-31 \u2506 72.482498 \u2506 73.419998 \u2506 72.379997 \u2506 73.412498 \u2506 1.008056e8 \u2506 71.711739 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518)\n```\n\n### Read/write data:\n\n```rust\nuse RustQuant::data::*;\n\nfn main() {\n    // New `Data` instance.\n    let mut data = Data::new(\n        format: DataFormat::CSV, // Can also be JSON or PARQUET.\n        path: String::from(\"./file/path/read.csv\")\n    )\n\n    // Read from the given file. \n    data.read().unwrap();\n\n    // New path to write the data to. \n    data.path = String::from(\"./file/path/write.csv\")\n    data.write().unwrap();\n\n    println!(\"{:?}\", data.data)\n}\n```\n\n### Compute gradients:\n\n```rust\nuse RustQuant::autodiff::*;\n\nfn main() {\n    // Create a new Tape.\n    let t = Tape::new();\n\n    // Assign variables.\n    let x = t.var(0.5);\n    let y = t.var(4.2);\n\n    // Define a function.\n    let z = x * y + x.sin();\n\n    // Accumulate the gradient.\n    let grad = z.accumulate();\n\n    println!(\"Function = {}\", z);\n    println!(\"Gradient = {:?}\", grad.wrt([x, y]));\n}\n```\n\n### Compute integrals:\n\n```rust\nuse RustQuant::math::*;\n\nfn main() {\n    // Define a function to integrate: e^(sin(x))\n    fn f(x: f64) -> f64 {\n        (x.sin()).exp()\n    }\n\n    // Integrate from 0 to 5.\n    let integral = integrate(f, 0.0, 5.0);\n\n    // ~ 7.18911925\n    println!(\"Integral = {}\", integral); \n}\n```\n\n### Price options:\n\n```rust\nuse RustQuant::options::*;\n\nfn main() {\n    let VanillaOption = EuropeanOption {\n        initial_price: 100.0,\n        strike_price: 110.0,\n        risk_free_rate: 0.05,\n        volatility: 0.2,\n        dividend_rate: 0.02,\n        time_to_maturity: 0.5,\n    };\n\n    let prices = VanillaOption.price();\n\n    println!(\"Call price = {}\", prices.0);\n    println!(\"Put price = {}\", prices.1);\n}\n```\n\n### Generate stochastic processes:\n\n```rust\nuse RustQuant::stochastics::*;\n\nfn main() {\n    // Create new GBM with mu and sigma.\n    let gbm = GeometricBrownianMotion::new(0.05, 0.9);\n\n    // Generate path using Euler-Maruyama scheme.\n    // Parameters: x_0, t_0, t_n, n, sims, parallel.\n    let output = (&gbm).euler_maruyama(10.0, 0.0, 0.5, 10, 1, false);\n\n    println!(\"GBM = {:?}\", output.trajectories);\n}\n```\n\n## :book: References: <a name=\"references\"></a>\n\n+ John C. Hull - *Options, Futures, and Other Derivatives*\n+ Damiano Brigo & Fabio Mercurio - *Interest Rate Models - Theory and Practice (With Smile, Inflation and Credit)*\n+ Paul Glasserman - *Monte Carlo Methods in Financial Engineering*\n+ Andreas Griewank & Andrea Walther - *Evaluating Derivatives - Principles and Techniques of Algorithmic Differentiation*\n+ Steven E. Shreve - *Stochastic Calculus for Finance II: Continuous-Time Models*\n+ Espen Gaarder Haug - *Option Pricing Formulas*\n+ Antoine Savine - *Modern Computational Finance: AAD and Parallel Simulations*\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A Rust library for quantitative finance tools.",
    "version": "0.0.17",
    "project_urls": {
        "Source Code": "https://github.com/avhz/RustQuant"
    },
    "split_keywords": [
        "finance",
        "quantitative",
        "option-pricing",
        "statistics",
        "quantlib"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "85f5e50aa702018a7c4c62b0efc16397ddfead28d6b8307606972562113bec73",
                "md5": "e47ca5dfcc806d449481a816996d6bda",
                "sha256": "09af85d0602096e3a6d2edb50ab6a58d20f1b1f12fcabdc50590b713dbe777bf"
            },
            "downloads": -1,
            "filename": "RustQuant-0.0.17-cp37-abi3-manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "e47ca5dfcc806d449481a816996d6bda",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 917601,
            "upload_time": "2023-06-05T12:39:53",
            "upload_time_iso_8601": "2023-06-05T12:39:53.996375Z",
            "url": "https://files.pythonhosted.org/packages/85/f5/e50aa702018a7c4c62b0efc16397ddfead28d6b8307606972562113bec73/RustQuant-0.0.17-cp37-abi3-manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "76b7e64ed301cbf1c186fc4b9e6dfdaec34abdc69797cfb7cf14e447cba9be1f",
                "md5": "d9b4c2ac5414d660a27a91e90455ae95",
                "sha256": "2264900b4c14e64c58eaf2d035860e87ae2dc254e57ae0f674f33e997f04998d"
            },
            "downloads": -1,
            "filename": "RustQuant-0.0.17.tar.gz",
            "has_sig": false,
            "md5_digest": "d9b4c2ac5414d660a27a91e90455ae95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 24752823,
            "upload_time": "2023-06-05T12:40:01",
            "upload_time_iso_8601": "2023-06-05T12:40:01.424478Z",
            "url": "https://files.pythonhosted.org/packages/76/b7/e64ed301cbf1c186fc4b9e6dfdaec34abdc69797cfb7cf14e447cba9be1f/RustQuant-0.0.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-05 12:40:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "avhz",
    "github_project": "RustQuant",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rustquant"
}
        
Elapsed time: 0.08811s