rustyfinance 1.1.0

Download market data from Yahoo! Finance's API
Documentation

rustyfinance

rustyfinance is a Rust implementation inspired by and transformed from the Python project ranaroussi/yfinance.

Origin

  • Source project: https://github.com/ranaroussi/yfinance.git
  • This repository ports core Yahoo Finance data access ideas/APIs to Rust.
  • The Python source snapshot is kept under python-yfinance/ for migration reference.

Install

cargo add rustyfinance

Usage

Get historical price data

use rustyfinance::ticker::HistoryParams;
use rustyfinance::Ticker;

fn main() -> Result<(), Box<dyn std::error::Error>> {
	let ticker = Ticker::new("AAPL");
	let bars = ticker.history(HistoryParams::default())?;
	println!("bars: {}", bars.len());
	Ok(())
}

Search symbols/news

use rustyfinance::Search;

fn main() -> Result<(), Box<dyn std::error::Error>> {
	let mut search = Search::new("apple");
	search.fetch()?;
	println!("quotes: {}", search.quotes().len());
	println!("news: {}", search.news().len());
	Ok(())
}

Batch download

use rustyfinance::ticker::HistoryParams;
use rustyfinance::download;

fn main() -> Result<(), Box<dyn std::error::Error>> {
	let out = download(&["AAPL", "MSFT"], HistoryParams::default(), true)?;
	println!("symbols: {}", out.len());
	Ok(())
}

Notes

  • Yahoo Finance endpoints are unofficial and can change.
  • Some behavior may differ from Python yfinance while migration is ongoing.