Finalytics is a Rust library designed for retrieving financial data and performing security analysis and portfolio optimization.
Add the following to your Cargo.toml
file:
[dependencies]
finalytics = "*"
Or run the following command:
cargo install finalytics
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(())
}
pip install finalytics
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")
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.