{"id":26685199,"url":"https://github.com/carlobortolan/quantrs","last_synced_at":"2026-02-22T15:02:03.380Z","repository":{"id":282731483,"uuid":"834146358","full_name":"carlobortolan/quantrs","owner":"carlobortolan","description":"A (very) fast Rust library for quantitative finance.","archived":false,"fork":false,"pushed_at":"2026-01-28T09:32:23.000Z","size":4952,"stargazers_count":14,"open_issues_count":18,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-28T23:36:00.841Z","etag":null,"topics":["binomial-model","black-76","black-scholes","bonds","derivatives","finite-difference","fixed-income","lattice","option-pricing","options-strategies","quant","quantitative-finance","rust-crate"],"latest_commit_sha":null,"homepage":"https://docs.rs/quantrs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carlobortolan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-26T14:14:43.000Z","updated_at":"2026-01-28T17:36:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"179a92ae-d0ed-45c4-8fd7-a6c67e3071c7","html_url":"https://github.com/carlobortolan/quantrs","commit_stats":null,"previous_names":["carlobortolan/quantrs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/carlobortolan/quantrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlobortolan%2Fquantrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlobortolan%2Fquantrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlobortolan%2Fquantrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlobortolan%2Fquantrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlobortolan","download_url":"https://codeload.github.com/carlobortolan/quantrs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlobortolan%2Fquantrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29716528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T13:30:57.152Z","status":"ssl_error","status_checked_at":"2026-02-22T13:30:28.561Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binomial-model","black-76","black-scholes","bonds","derivatives","finite-difference","fixed-income","lattice","option-pricing","options-strategies","quant","quantitative-finance","rust-crate"],"created_at":"2025-03-26T10:14:53.738Z","updated_at":"2026-02-22T15:02:03.351Z","avatar_url":"https://github.com/carlobortolan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quantrs\n\n![tests][actions-test-badge]\n[![MIT/Apache 2.0 licensed][license-badge]](./LICENSE.md)\n[![Crate][crates-badge]][crates-url]\n[![docs.rs][docsrs-badge]][docs-url]\n[![codecov-quantrs][codecov-badge]][codecov-url]\n![Crates.io MSRV][crates-msrv-badge]\n![Crates.io downloads][crates-download-badge]\n[![PyPI version][pypi-version]][pypi-url]\n\n[actions-test-badge]: https://github.com/carlobortolan/quantrs/actions/workflows/ci.yml/badge.svg\n[crates-badge]: https://img.shields.io/crates/v/quantrs.svg\n[crates-url]: https://crates.io/crates/quantrs\n[license-badge]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg\n[docsrs-badge]: https://img.shields.io/docsrs/quantrs\n[docs-url]: https://docs.rs/quantrs/*/quantrs\n[codecov-badge]: https://codecov.io/gh/carlobortolan/quantrs/graph/badge.svg?token=NJ4HW3OQFY\n[codecov-url]: https://codecov.io/gh/carlobortolan/quantrs\n[crates-msrv-badge]: https://img.shields.io/crates/msrv/quantrs\n[crates-download-badge]: https://img.shields.io/crates/d/quantrs\n[pypi-version]: https://img.shields.io/pypi/v/quantrs.svg\n[pypi-url]: https://pypi.org/project/quantrs\n\u003c!-- [![Python versions](https://img.shields.io/pypi/pyversions/quantrs.svg)](https://pypi.org/project/quantrs/) --\u003e\n\u003c!-- [![PyPI downloads](https://img.shields.io/pypi/dm/quantrs.svg)](https://pypi.org/project/quantrs/) --\u003e\n\nQuantrs is a tiny quantitative finance library for Rust.\nIt is designed to be as intuitive and easy to use as possible so that you can work with derivatives without the need to write complex code or have a PhD in reading QuantLib documentation.\nThe library is still in the early stages of development and many features are not yet implemented.\n\nPlease check out the documentation [here][docs-url].\n\nPython bindings are also available; see the [Python README](bindings/python#README.md) or the [PyPI page][pypi-url].\n\n## Features\n\n### Options Pricing\n\nQuantrs supports options pricing with various models for both vanilla and exotic options as well as options trading strategies for both basic options spreads and non-directional strategies.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003eClick to see supported models\u003c/i\u003e\u003c/summary\u003e\n\n|                             | Black-Scholes   | Black-76 | Lattice      | ³Monte-Carlo | Finite Diff   | Heston |\n| --------------------------- | --------------- | -------- | ------------ | ------------ | ------------- | ------ |\n| European                    | ✅              | ✅       | ✅           | ✅           | ⏳            | ⏳     |\n| American                    | ❌              | ❌       | ✅           | ❌ (L. Sq.)  | ⏳            | ❌     |\n| Bermudan                    | ❌              | ❌       | ✅           | ❌ (L. Sq.)  | ❌ (complex)  | ❌     |\n| ¹Basket                     | ⏳ (∀component) | ❌       | ⏳ (approx.) | ⏳           | ❌            | ❌     |\n| ¹Rainbow                    | ✅ (∀component) | ❌       | ✅           | ✅           | ❌            | ❌     |\n| ²Barrier                    | ❌ (mod. BSM)   | ❌       | ⏳           | ⏳           | ⏳            | ⏳     |\n| ²Double Barrier             | ❌ (mod. BSM)   | ❌       | ⏳           | ⏳           | ❌ (complex)  | ⏳     |\n| ²Asian (fixed strike)       | ❌ (mod. BSM)   | ❌       | ❌           | ✅           | ⏳            | ⏳     |\n| ²Asian (floating strike)    | ❌ (mod. BSM)   | ❌       | ❌           | ✅           | ⏳            | ⏳     |\n| ²Lookback (fixed strike)    | ❌              | ❌       | ❌           | ✅           | ⏳            | ⏳     |\n| ²Lookback (floating strike) | ✅              | ❌       | ❌           | ✅           | ⏳            | ⏳     |\n| ²Binary Cash-or-Nothing     | ✅              | ❌       | ✅           | ✅           | ❌ (mod. PDE) | ⏳     |\n| ²Binary Asset-or-Nothing    | ✅              | ❌       | ✅           | ✅           | ❌ (mod. PDE) | ⏳     |\n| Greeks (Δ,ν,Θ,ρ,Γ)          | ✅              | ✅       | ⏳           | ❌           | ❌            | ❌     |\n| Implied Volatility          | ✅              | ⏳       | ⏳           | ❌           | ❌            | ❌     |\n\n\u003e ¹ _\"Exotic\" options with standard exercise style; only differ in their payoff value_\\\n\u003e ² _Non-vanilla path-dependent \"exotic\" options_\\\n\u003e ³ _MC simulates underlying price paths based on geometric Brownian motion for Black-Scholes models and both arithmetic or geometric average price paths for Asian and Lookback options_\\\n\u003e ✅ = Supported, ⏳ = Planned / In progress, ❌ = Not supported / Not applicable\n\n\u003c!--Bachelier and Modified Bachelier--\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003eClick to see supported strategies\u003c/i\u003e\u003c/summary\u003e\n\n| Strategy Name            | Type         | Description                                                                                       |\n| ------------------------ | ------------ | ------------------------------------------------------------------------------------------------- |\n| Covered Call             | Income       | Long stock + short call                                                                           |\n| Protective Put           | Hedging      | Long stock + long put                                                                             |\n| Guts                     | Volatility   | Long ITM call + long ITM put                                                                      |\n| Straddle                 | Volatility   | Long ATM call + long ATM put                                                                      |\n| Strangle                 | Volatility   | Long OTM call + long OTM put                                                                      |\n| Butterfly Spread         | ¹Spread      | Long ITM call, short two ATM calls, long OTM call (or all puts)                                   |\n| Iron Butterfly           | ¹Spread      | Short straddle + long wings                                                                       |\n| Christmas Tree Butterfly | ¹Spread      | Long 1 ATM call, short 3 OTM calls, long 2 high-strike OTM calls (or all puts)                    |\n| Condor Spread            | ¹Spread      | Long low-strike ITM call, short ITM call, short OTM call, long high-strike OTM call (or all puts) |\n| Iron Condor              | ¹Spread      | Short strangle + long wings                                                                       |\n| Calendar Spread          | ²Time Spread | Long far-expiry ATM call + short near-expiry ATM call (or all puts)                               |\n| Diagonal Spread          | ³Time Spread | Short near-expiry OTM call + long far-expiry further OTM call (or all puts)                       |\n| Back Spread              | Directional  | Long 2 OTM calls + short 1 ATM call (or all puts)                                                 |\n\n\u003e ¹ _Also referred to as 'vertical'_\\\n\u003e ² _Also referred to as 'horizontal'_\\\n\u003e ³ _Also referred to as 'diagonal'_\n\n\u003c/details\u003e\n\n### Fixed Income\n\n- Bond Types\n  - [x] _Zero-Coupon Bonds_\n  - [ ] _Treasury Bonds_ (fixed-rate coupon)\n  - [ ] _Corporate Bonds_ (fixed-rate coupon with credit spreads)\n  - [ ] _Floating-Rate Bonds_ (variable coupon with caps/floors)\n- [ ] Duration (_Macaulay_, _Modified_, _Effective_)\n- [ ] Convexity\n- [ ] Yield Measures (_YTM_, _YTC_, _YTW_)\n- [x] Day Count Conventions (_ACT/365F_, _ACT/365_, _ACT/360_, _30/360 US_, _30/360 Eurobond_, _ACT/ACT ISDA_, _ACT/ACT ICMA_)\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nquantrs = \"0.1.8\"\n```\n\nNow if you want to e.g., calculate the arbitrage-free price of a binary cash-or-nothing call using the Black-Scholes model, you can:\n\n```rust\nuse quantrs::options::*;\n\n// Create a new instrument with a spot price of 100 and a dividend yield of 2%\nlet instrument = Instrument::new().with_spot(100.0).with_cont_yield(0.02);\n\n// Create a new Cash-or-Nothing binary call option with:\n// - Strike price (K) = 85\n// - Time to maturity (T) = 0.78 years\nlet option = BinaryOption::cash_or_nothing(instrument, 85.0, 0.78, Call);\n\n// Create a new Black-Scholes model with:\n// - Risk-free interest rate (r) = 5%\n// - Volatility (σ) = 20%\nlet model = BlackScholesModel::new(0.05, 0.2);\n\n// Calculate the price of the binary call option using the Black-Scholes model\nprintln!(\"Price: {}\", model.price(\u0026option));\n\n// Calculate first order greeks for the option\nprintln!(\"{:?}\", Greeks::calculate(\u0026model, \u0026option));\n```\n\nThis will output:\n\n```text\nPrice: 0.8006934914644723\nGreeks { delta: 0.013645840354947947, gamma: -0.0008813766475726433, theta: 0.17537248302290848, vega: -1.3749475702133236, rho: 0.4398346243436515 }\n```\n\n### Plotting\n\nQuantrs also supports plotting option prices and strategies using the `plotters` backend.\n\nE.g., Plot the P/L of a slightly skewed Condor spread consisting of fixed-strike Asian calls using the Monte-Carlo model with the geometric average price path:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003eClick to see example code\u003c/i\u003e\u003c/summary\u003e\n\n```rust\nuse quantrs::options::*;\n\n// Create a new instrument with a spot price of 100 and a dividend yield of 2%\nlet instrument = Instrument::new().with_spot(100.0).with_cont_yield(0.02);\n\n// Create a vector of fixed-strike Asian calls options with different strike prices\nlet options = [\n    AsianOption::fixed(instrument.clone(), 85.0, 1.0, Call),\n    AsianOption::fixed(instrument.clone(), 95.0, 1.0, Call),\n    AsianOption::fixed(instrument.clone(), 102.0, 1.0, Call),\n    AsianOption::fixed(instrument.clone(), 115.0, 1.0, Call),\n];\n\n// Create a new Monte-Carlo model with:\n// - Risk-free interest rate (r) = 5%\n// - Volatility (σ) = 20%\n// - Number of simulations = 10,000\n// - Number of time steps = 252\nlet model = MonteCarloModel::geometric(0.05, 0.2, 10_000, 252);\n\n// Plot a breakdown of the Condor spread with a spot price range of [80,120]\nmodel.plot_strategy_breakdown(\n    \"Condor Example\",\n    model.condor(\u0026options[0], \u0026options[1], \u0026options[2], \u0026options[3]),\n    80.0..120.0,\n    \"examples/images/strategy.png\",\n    \u0026options,\n);\n```\n\n\u003c/details\u003e\n\n![condor_strategy](./examples/images/strategy.png)\n\n\u003c!--\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/0298807f-43ed-4458-9c7d-43b0f70defea\" alt=\"condor_strategy\" width=\"600\"/\u003e\n\u003c/div\u003e--\u003e\n\nSee the [documentation][docs-url] for more information and examples.\n\n## Benchmarks\n\nCompared to other popular and well-maintained (i.e., actively developed, well-documented, and feature-rich) options pricing libraries, quantrs competes well in terms of performance:\nE.g., for pricing a European call with the Merton Black-Scholes model, quantrs is:\n\n- **87x faster** than `py_vollib`\n- **29x faster** than `QuantLib` (python bindings)\n- **15x faster** than `RustQuant`\n- **3x faster** than `Q-Fin`\n- **1.7x slower** than `QuantLib` (cpp)\n\n| Library                                                | Mean Execution Time (μs) | Median Execution Time (μs) | Standard Deviation (μs) | Operations / Second (OPS) |\n| ------------------------------------------------------ | ------------------------ | -------------------------- | ----------------------- | ------------------------- |\n| quantrs                                                | 0.0971                   | 0.0970                     | 0.0007                  | 10,142,000                |\n| [py_vollib](https://github.com/vollib/py_vollib)       | 8.5341                   | 8.5210                     | 0.8129                  | 117,176                   |\n| [QuantLib](https://pypi.org/project/QuantLib) (py)     | 2.8551                   | 2.8630                     | 0.9391                  | 350,250                   |\n| [RustQuant](https://github.com/avhz/RustQuant)         | 1.4777                   | 1.4750                     | 0.0237                  | 676,727                   |\n| [Q-Fin](https://github.com/romanmichaelpaolucci/Q-Fin) | 0.2900                   | 0.2906                     | 0.0448                  | 3,447,870                 |\n| [QuantLib](https://www.quantlib.org) (cpp)             | 0.0556                   | n.a.                       | n.a.                    | 17,958,600                |\n\nYou can find the benchmarks at [quantrs.pages.dev/report](https://quantrs.pages.dev/report/).\n\n_Published benchmarks have been measured on a selfhosted VM with 32 GB RAM, AMD Ryzen 7 PRO 6850U @ 2.70GHz, and Manjaro Linux x86_64_\n\n## Minimum supported Rust version (MSRV)\n\nThis crate requires a Rust version of 1.83.0 or higher. Increases in MSRV will be considered a semver non-breaking API change and require a version increase (PATCH until 1.0.0, MINOR after 1.0.0).\n\n## Contributing\n\nIf you find any bugs or have suggestions for improvement, please open a new issue or PR. See [OUTLOOK.md](OUTLOOK.md) for a list of planned features and improvements.\n\n## Disclaimer\n\nThis library is not intended for professional use. It is a hobby project and should be treated as such.\n\n## License\n\nThis project is licensed under either of:\n\n- [MIT license](LICENSE-MIT.md) or\n- [Apache License, Version 2.0](LICENSE-APACHE.md)\n\nat your option.\n\n---\n\n© Carlo Bortolan\n\n\u003e Carlo Bortolan \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [carlobortolan](https://github.com/carlobortolan) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e contact via [carlobortolan@gmail.com](mailto:carlobortolan@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlobortolan%2Fquantrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlobortolan%2Fquantrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlobortolan%2Fquantrs/lists"}