#finance #stocks #yahoo

yahoo-finance

An API to get financial data from Yahoo

4 releases (2 breaking)

0.3.0 Sep 9, 2020
0.2.0 Apr 4, 2020
0.1.1 Mar 28, 2020
0.1.0 Mar 28, 2020

#71 in Math

Download history 15/week @ 2020-06-06 9/week @ 2020-06-13 2/week @ 2020-06-20 13/week @ 2020-06-27 16/week @ 2020-07-04 18/week @ 2020-07-11 20/week @ 2020-07-18 21/week @ 2020-07-25 12/week @ 2020-08-01 16/week @ 2020-08-08 15/week @ 2020-08-15 6/week @ 2020-08-22 15/week @ 2020-08-29 32/week @ 2020-09-05 16/week @ 2020-09-12 18/week @ 2020-09-19

70 downloads per month
Used in stocker

MIT license

82KB
1.5K SLoC

Yahoo Finance for Rust

A Rust library for getting financial information from Yahoo!

Package Documentation Build Status

  • Historical OHLCV pricing information
use yahoo_finance::history;

fn main() {
   // retrieve 6 months worth of data for Apple
   let data = history::retrieve("AAPL").unwrap();

   // print the date and closing price for each day we have data
   for bar in &data {
      println!("On {} Apple closed at ${:.2}", bar.timestamp.format("%b %e %Y"), bar.close)
   }
}
  • Realtime pricing information
use futures::{ future, StreamExt };
use yahoo_finance::Streamer;

#[tokio::main]
async fn main() {
   let mut streamer = Streamer::new(vec!["AAPL", "^DJI", "^IXIC"]);

   streamer.stream().await
      .for_each(|quote| {
         println!("At {}, {} is trading for ${} [{}]", quote.timestamp, quote.symbol, quote.price, quote.volume);

         future::ready(())
      })
      .await;
}
  • Symbol profile information
use futures::{ future, StreamExt };
use yahoo_finance::Streamer;

#[tokio::main]
async fn main() {
   let mut streamer = Streamer::new(vec!["AAPL", "^DJI", "^IXIC"]);

   streamer.stream().await
      .for_each(|quote| {
         println!("At {}, {} is trading for ${} [{}]", quote.timestamp, quote.symbol, quote.price, quote.volume);

         future::ready(())
      })
      .await;
}

Usage

Add this to your Cargo.toml:

yahoo-finance = "0.3"

Dependencies

~9–13MB
~270K SLoC