Skip to content

Latest commit

 

History

History
134 lines (92 loc) · 4.21 KB

README.md

File metadata and controls

134 lines (92 loc) · 4.21 KB

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 PyPI Downloads

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

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

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