Skip to content

Nnamdi-sys/finalytics

Repository files navigation

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

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.

About

A rust library for financial data analysis

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages