
Finalytics Rust Library
Finalytics is a modular, high-performance Rust library for retrieving financial data, performing security analysis, and optimizing portfolios. It is designed for extensibility and speed, and powers bindings for Python, Node.js, Go, and a web application built with Dioxus.
🚀 Installation
Add the following to your Cargo.toml file:
[]
= "*"
Or run:
🦀 Main Modules
Finalytics is organized around five core modules, each designed for a specific aspect of financial analytics:
1. Screener
Efficiently filter and rank securities using advanced metrics and custom filters.
Usage Example:
use *;
let screener = builder
.quote_type
.add_filter
.add_filter
.add_filter
.add_filter
.sort_by
.size
.build
.await?;
screener.overview.show?;
screener.metrics.await?.show?;
2. Ticker
Analyze a single security in depth: performance, financials, options, news, and more.
Usage Example:
let ticker = builder
.ticker
.start_date
.end_date
.interval
.benchmark_symbol
.confidence_level
.risk_free_rate
.build;
ticker.report.await?.show?;
ticker.report.await?.show?;
ticker.report.await?.show?;
ticker.report.await?.show?;
3. Tickers
Work with multiple securities at once—aggregate reports, batch analytics, and portfolio construction.
Usage Example:
let tickers = builder
.tickers
.start_date
.end_date
.interval
.benchmark_symbol
.confidence_level
.risk_free_rate
.build;
tickers.report.await?.show?;
4. Portfolio
Optimize and analyze portfolios using advanced objective functions and constraints. Supports rebalancing strategies, scheduled cash flows (DCA), ad-hoc transactions, and out-of-sample evaluation.
Objective Functions:
MaxSharpe, MaxSortino, MaxReturn, MinVol, MinVar, MinCVaR, MinDrawdown,
RiskParity, MaxDiversification, HierarchicalRiskParity
Usage Example: Optimization with Out-of-Sample Evaluation
// Optimize on 2023 - 2024 data (in-sample)
let mut portfolio = builder
.ticker_symbols
.benchmark_symbol
.start_date
.end_date
.interval
.confidence_level
.risk_free_rate
.objective_function
.build.await?;
portfolio.optimize?;
portfolio.report.await?.show?;
// Update to 2025 data for out-of-sample evaluation
portfolio.update_dates.await?;
portfolio.performance_stats?;
portfolio.report.await?.show?;
Usage Example: Explicit Allocation with Rebalancing and DCA
let mut portfolio = builder
.ticker_symbols
.benchmark_symbol
.start_date
.end_date
.interval
.confidence_level
.risk_free_rate
.weights
.rebalance_strategy
.scheduled_cash_flows
.build.await?;
portfolio.performance_stats?;
portfolio.report.await?.show?;
Usage Example: Optimization with Weight & Categorical Constraints
use *;
let constraints = Constraints ;
let mut portfolio = builder
.ticker_symbols
.benchmark_symbol
.start_date
.end_date
.interval
.confidence_level
.risk_free_rate
.objective_function
.constraints
.build.await?;
portfolio.optimize?;
portfolio.report.await?.show?;
5. Custom Data (KLINE)
Load your own price data from CSV, JSON, or DataFrames and use it with any Finalytics module.
The KLINE struct expects columns: timestamp (unix epoch i64), open, high, low, close, volume, adjclose.
Usage Example:
// Load data from CSV files
let aapl = KLINEfrom_csv?;
let msft = KLINEfrom_csv?;
let nvda = KLINEfrom_csv?;
let goog = KLINEfrom_csv?;
let btcusd = KLINEfrom_csv?;
let gspc = KLINEfrom_csv?;
// Also available: KLINE::from_json("AAPL", "aapl.json")?
// Also available: KLINE::from_dataframe("AAPL", &polars_df)?
// Single Ticker from custom data
let ticker = builder
.ticker
.benchmark_symbol
.confidence_level
.risk_free_rate
.ticker_data
.benchmark_data
.build;
ticker.report.await?.show?;
// Multiple Tickers from custom data
let tickers = builder
.tickers
.benchmark_symbol
.confidence_level
.risk_free_rate
.tickers_data
.benchmark_data
.build;
tickers.report.await?.show?;
// Portfolio optimization from custom data
let mut portfolio = builder
.ticker_symbols
.benchmark_symbol
.confidence_level
.risk_free_rate
.objective_function
.tickers_data
.benchmark_data
.build.await?;
portfolio.optimize?;
portfolio.report.await?.show?;
📚 Documentation
- See the API documentation for full details.
🗂️ Multi-language Bindings
Finalytics is also available in:
Finalytics — Modular, high-performance financial analytics in Rust.