20 releases (5 breaking)

new 0.7.0 Jan 9, 2025
0.6.0 Aug 11, 2024
0.5.3 Jul 6, 2024
0.3.6 Jan 15, 2024
0.2.9 Nov 26, 2023

#26 in Finance

Download history 30/week @ 2024-09-23 3/week @ 2024-09-30 2/week @ 2024-11-04 112/week @ 2024-12-02 538/week @ 2024-12-09 18/week @ 2024-12-23 121/week @ 2025-01-06

179 downloads per month

MIT license

260KB
4.5K SLoC

Finalytics

Crates.io Docs.rs License Homepage CodeFactor Crates.io

Finalytics is a Rust library designed for retrieving financial data and performing security analysis and portfolio optimization.

Installation

Add the following to your Cargo.toml file:

[dependencies]
finalytics = "*"

Or run the following command:

cargo install finalytics

Example

View the documentation for more information.

use std::error::Error;
use finalytics::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {

    // Instantiate a Multiple Ticker Object
    let ticker_symbols = vec!["NVDA", "GOOG", "AAPL", "MSFT", "BTC-USD"];

    let tickers = TickersBuilder::new()
        .tickers(ticker_symbols.clone())
        .start_date("2023-01-01")
        .end_date("2024-12-31")
        .interval(Interval::OneDay)
        .benchmark_symbol("^GSPC")
        .confidence_level(0.95)
        .risk_free_rate(0.02)
        .build();

    // Generate a Single Ticker Report
    let ticker = tickers.clone().get_ticker("AAPL").await?;
    ticker.report(Some(ReportType::Performance)).await?.show()?;
    ticker.report(Some(ReportType::Financials)).await?.show()?;
    ticker.report(Some(ReportType::Options)).await?.show()?;
    ticker.report(Some(ReportType::News)).await?.show()?;

    // Generate a Multiple Ticker Report
    tickers.report(Some(ReportType::Performance)).await?.show()?;

    // Perform a Portfolio Optimization
    let portfolio = tickers.optimize(Some(ObjectiveFunction::MaxSharpe), None).await?;

    // Generate a Portfolio Report
    portfolio.report(Some(ReportType::Performance)).await?.show()?;

    Ok(())
}

Python Binding

pypi License Homepage Documentation Status Platform Python Version PePy

Installation

pip install finalytics

Example

View the documentation for more information.

from finalytics import Tickers

# Instantiate a Multiple Ticker Object
tickers = Tickers(symbols=["NVDA", "GOOG", "AAPL", "MSFT", "BTC-USD"],
                  start_date="2023-01-01",
                  end_date="2024-12-31",
                  interval="1d",
                  confidence_level=0.95,
                  risk_free_rate=0.02)

# Generate a Single Ticker Report
ticker = tickers.get_ticker("AAPL")
ticker.report("performance")
ticker.report("financials")
ticker.report("options")
ticker.report("news")

# Generate a Multiple Ticker Report
tickers.report("performance")

# Perform a Portfolio Optimization
portfolio = tickers.optimize(objective_function="max_sharpe")

# Generate a Portfolio Report
portfolio.report("performance")

Sample Applications

Ticker Dashboard

This sample application allows you to perform security analysis based on the Finalytics Library.

Portfolio Dashboard

This sample application enables you to perform portfolio optimization based on the Finalytics Library.

Dependencies

~51–70MB
~1M SLoC