finalytics

Crates.iofinalytics
lib.rsfinalytics
version0.6.0
sourcesrc
created_at2023-10-09 20:16:19.336975
updated_at2024-08-11 16:30:25.448701
descriptionA rust library for financial data analysis
homepagehttps://finalytics.rs/
repositoryhttps://github.com/Nnamdi-sys/finalytics
max_upload_size
id998433
size235,940
Nnamdi Olisaeloka (Nnamdi-sys)

documentation

README

Finalytics

Crates.io Docs.rs License Homepage CodeFactor

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::from(["NVDA", "GOOG", "AAPL", "MSFT", "BTC-USD"]);

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

    // Calculate the Performance Statistics of all the Tickers
    let performance_stats = tickers.performance_stats().await?;
    println!("{:?}", performance_stats);

    // Display the Security Analysis Charts
    tickers.returns_chart(None, None).await?.show();
    tickers.returns_matrix(None, None).await?.show();
    
    // Perform a Portfolio Optimization
    let portfolio = tickers.optimize_portfolio(ObjectiveFunction::MaxSharpe).await?;
    println!("{:?}", portfolio.performance_stats);

    // Display the Portfolio Optimization Charts
    portfolio.performance_stats_table(None, None)?.show();
    portfolio.optimization_chart(None, None)?.show();
    portfolio.performance_chart(None, None)?.show();
    portfolio.asset_returns_chart(None, None)?.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="2020-01-01",
                  end_date="2024-01-01",
                  interval="1d",
                  confidence_level=0.95,
                  risk_free_rate=0.02)

# Calculate the Performance Statistics of all the Tickers
print(tickers.performance_stats())

# Display the Security Analysis Charts
tickers.returns_chart().show()
tickers.returns_matrix().show()

# Perform Portfolio Optimization
portfolio = tickers.optimize()
print(portfolio.optimization_results())

# Display the Portfolio Optimization Charts
portfolio.optimization_chart().show()
portfolio.performance_chart().show()
portfolio.asset_returns_chart().show()
portfolio.performance_stats_table().show()

Sample Applications

Ticker Charts Viewer

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

Portfolio Charts Viewer

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

Commit count: 81

cargo fmt