RustAtlas is a high-performance quantitative finance library written in Rust, designed for precision and speed in fixed-income pricing, FX derivatives, and ALM simulation. Built on a visitor pattern architecture with type-safe cashflows and pluggable market models.
Status: Production-ready for fixed-income instruments and ALM simulation. Derivatives pricing actively maintained.
- 🚀 Type-safe: Leverages Rust's type system for instrument and cashflow safety
- ⚡ High-performance: Parallel computation via Rayon, forward-mode AD for sensitivities
- 🏗️ Extensible: Visitor pattern + trait-based design for custom analytics
- 📊 Comprehensive: 20+ pricing visitors, multi-curve bootstrapping, ALM simulation
- 🌍 Multi-currency: Automatic FX conversion, triangulation, date-window averaging
- 🔒 No panics: All fallible operations return
Result<T>via unified error type
MarketStore ──► SimpleModel ──► Visitors (NPV, Par, Duration, Z-spread, …)
│
├── IndexStore (yield curves, Ibor/Overnight indices)
└── ExchangeRateStore (spot rates, historical rates, forecasts)
- Instruments are built via fluent
Make*constructors and hold typed cashflows. - Visitors traverse cashflows without mutating instruments (
ConstVisit) or with mutation (Visit). - The
preludemodule re-exports everything needed for day-to-day use.
Add to your Cargo.toml:
[dependencies]
rustatlas = "1.0"Or for development (local path):
[dependencies]
rustatlas = { path = "../path/to/rustatlas" }Documentation: docs.rs/rustatlas | Source: github.com/Poss9368/rustatlas-finance
use rustatlas::prelude::*;
let start_date = Date::new(2020, 1, 1);
let end_date = start_date + Period::new(2, TimeUnit::Months);
let rate = InterestRate::new(
0.05,
Compounding::Compounded,
Frequency::Annual,
DayCounter::Actual360,
);
let instrument = MakeFixedRateInstrument::new()
.with_start_date(start_date)
.with_end_date(end_date)
.with_payment_frequency(Frequency::Monthly)
.with_rate(rate)
.with_notional(1_000.0)
.with_side(Side::Receive)
.with_currency(Currency::USD)
.equal_payments()
.build()?;
instrument.cashflows().for_each(|cf| println!("{}", cf));Pricing is done through visitors. The SimpleModel resolves discount factors and index fixings from a MarketStore:
use rustatlas::prelude::*;
let market_store = create_store(); // see examples/common/common.rs
let ref_date = market_store.reference_date();
let instrument = MakeFixedRateInstrument::new()
.with_start_date(ref_date)
.with_end_date(ref_date + Period::new(10, TimeUnit::Years))
.with_rate(InterestRate::new(0.05, Compounding::Simple, Frequency::Annual, DayCounter::Thirty360))
.with_payment_frequency(Frequency::Semiannual)
.with_side(Side::Receive)
.with_currency(Currency::USD)
.bullet()
.with_discount_curve_id(Some(2))
.with_notional(100_000.0)
.build()?;
let model = SimpleModel::new(&market_store);
let npv = NPVConstVisitor::new(&model, true).visit(&instrument)?;
assert_ne!(npv, 0.0);For more examples, see the examples folder.
| Example | Description |
|---|---|
fixedratepricing |
Fixed rate loan: NPV, accrual, par rate — starting today, forward-starting, and already-started |
floatingratepricing |
Floating rate loan with index fixing, NPV, and par spread |
swappricing |
Vanilla IRS (fixed vs. floating): NPV and par rate, with and without spread |
fxforward |
Vanilla FX Forward and Non-Deliverable Forward (NDF) pricing |
rolloversimulation |
ALM rollover engine: constant portfolio, growth mode, and parallel NPV by date |
cargo run --example fixedratepricing
cargo run --example floatingratepricing
cargo run --example swappricing
cargo run --example fxforward
cargo run --example rolloversimulation| Feature | Status |
|---|---|
| Ibor / Overnight indices | ✅ |
| Accrual for Ibor / Overnight (floating coupons) | ✅ |
| Flat-forward term structure | ✅ |
| Zero-rate term structure (date-based & tenor-based) | ✅ |
| Discount-factor term structure | ✅ |
| Composite term structure (spread + base, multiplicative DFs) | ✅ |
| Synthetic term structure (ratio of DF products) | ✅ |
| Tenor-based spread term structure | ✅ |
| Curve shock / parallel shift analysis | ✅ |
| Bootstrapping engine (multi-curve, multi-instrument) | ✅ |
| Fixing period adjustments | ✅ |
Advance MarketStore to T+1 |
✅ |
| Curves with parametric models (Nelson-Siegel-Svensson, Vasicek, …) | 🔜 Planned |
| Feature | Status |
|---|---|
| Simple cashflow (disbursement / redemption) | ✅ |
| Fixed-rate coupon | ✅ |
| Floating-rate / Ibor coupon | ✅ |
| Indexed FX cashflow | ✅ |
| Instrument | Structures | Status |
|---|---|---|
| Fixed-rate loan / deposit | Bullet, Amortizing, Zero-coupon, Equal installments, Irregular | ✅ |
| Floating-rate loan / deposit | Bullet, Amortizing, Zero-coupon, Irregular | ✅ |
| Mixed-rate (double-rate) instrument | — | ✅ |
| Fixed-rate bond | — | ✅ |
| Current account | — | ✅ |
| Time deposit | — | ✅ |
| Vanilla IRS (fixed vs. floating) | — | ✅ |
| Cross-currency swap | — | ✅ |
| Vanilla FX Forward | — | ✅ |
| Non-Deliverable Forward (NDF) | — | ✅ |
| Forward-starting instruments | — | ✅ |
| Options | — | 🔜 Planned |
| Visitor | Description | Status |
|---|---|---|
NPVConstVisitor |
Net present value | ✅ |
NPVByDateConstVisitor |
NPV bucketed by payment date | ✅ |
NPVByTenorConstVisitor |
NPV bucketed by tenor | ✅ |
ParValueVisitor |
Par rate / par spread | ✅ |
DurationConstVisitor |
Macaulay duration | ✅ |
DV01ConstVisitor |
Dollar value of 1 bp (analytical) | ✅ |
ZSpreadConstVisitor |
Zero spread (Z-spread) via Brent solver | ✅ |
YieldRateConstVisitor |
Yield-to-maturity | ✅ |
FixingVisitor |
Resolves forward rates into floating coupons | ✅ |
FixingFxVisitor |
Resolves FX rates into indexed cashflows | ✅ |
AccruedInterestConstVisitor |
Accrued interest | ✅ |
AccruedAmountConstVisitor |
Accrued amount | ✅ |
InterestPaymentConstVisitor |
Scheduled interest payments | ✅ |
OutstandingsConstVisitor |
Outstanding notional over time | ✅ |
RedemptionsConstVisitor |
Redemption cashflows | ✅ |
PlacementConstVisitor |
Placement (disbursement) cashflows | ✅ |
NotPayInterestConstVisitor |
Capitalised (not-yet-paid) interest | ✅ |
CashflowCompressorConstVisitor |
Compress cashflows by date | ✅ |
CashflowsAggregatorConstVisitor |
Aggregate cashflows across instruments | ✅ |
| Feature | Description | Status |
|---|---|---|
RolloverSimulationEngine |
Day-by-day portfolio rollover with configurable strategies | ✅ |
NPVEngine |
Parallel portfolio NPV (Rayon-backed, chunked) | ✅ |
| Growth modes | PaidAmount, Annual, CustomGrowth (interpolated vector) |
✅ |
| Scale factor | Rescale base redemptions before simulation | ✅ |
| Feature | Status |
|---|---|
| Spot exchange rates | ✅ |
| Historical exchange rate store | ✅ |
| Forward FX via currency forecast curves | ✅ |
| FX triangulation | ✅ |
| Date-window averaging | ✅ |
| Automatic currency conversion in cashflows | ✅ |
| Load currencies from JSON | ✅ |
| Feature | Status |
|---|---|
| Linear interpolation | ✅ |
| Log-linear interpolation | ✅ |
| Cubic interpolation | ✅ |
| Brent root-finding solver | ✅ |
| Brent optimisation solver | ✅ |
| Newton-Raphson solver | ✅ |
| Gauss-Newton solver | ✅ |
Forward-mode AD (ADReal + Tape) |
✅ |
| Compile-time automatic differentiation | 🔜 Planned (tracking rust-lang#124509) |
| Feature | Status |
|---|---|
| Date arithmetic | ✅ |
| Period (tenor) arithmetic | ✅ |
| Schedule generation | ✅ |
| IMM dates | ✅ |
| Day counters: Actual/360, Actual/365, Actual/Actual, Business/252, 30/360 | ✅ |
| Calendars: NullCalendar, WeekendsOnly, Chile, USA, Brazil, Colombia, Mexico, TARGET | ✅ |
| Business day conventions | ✅ |
| Feature | Status |
|---|---|
Unified error type (AtlasError) via thiserror |
✅ |
No panics in library code (all errors propagated via Result) |
✅ |
Thread-safe market data (Arc<RwLock<…>>) |
✅ |
| Parallel computation via Rayon | ✅ |
| Serde serialization for core types | ✅ |
| Issue | Status |
|---|---|
| Weekend fixings | ✅ Feature + unit tests |
| Grace periods in loans | ✅ Feature + unit tests |
| Automatic currency conversion | ✅ Feature + unit tests |
Requirements:
- Rust 1.82.0 or later
- Cargo (comes with Rust)
Clone and build:
git clone https://github.com/Poss9368/rustatlas-finance.git
cd rustatlas-finance
cargo build --releaseRun tests:
cargo test --all-featuresRun examples:
cargo run --release --example fixedratepricing| Crate | Purpose |
|---|---|
chrono |
Date parsing |
rayon |
Parallel iterators |
thiserror |
Error derivation |
serde / serde_json |
Serialization |
nalgebra |
Linear algebra (solvers) |
bumpalo |
Arena allocator (AD tape) |
colored |
Terminal output formatting |
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit with clear messages:
git commit -m 'Add feature X' - Run tests:
cargo test --all-features - Run formatter:
cargo fmt - Run linter:
cargo clippy -- -D warnings - Push to your fork and open a Pull Request
For major changes, please open an issue first to discuss what you'd like to change.
See CONTRIBUTING.md for more details.
- Parametric yield curve models (Nelson-Siegel-Svensson, Vasicek)
- Option pricing (Black-Scholes, Binomial)
- Enhanced benchmarking suite
- WebAssembly (WASM) build
- Monte Carlo simulation engine
- Local volatility & stochastic vol models
- Multi-threaded curve bootstrapping
- REST API service wrapper
- Compile-time automatic differentiation (tracking rust-lang#124509)
- GPU-accelerated computations
- Real-time data connectors (Bloomberg, Reuters)
RustAtlas is released under the MIT License. See LICENSE for details.
Questions? Open an issue or check the examples folder for more guidance.