1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! # yfinance-rs
//!
//! An ergonomic, async-first Rust client for the unofficial Yahoo Finance API.
//!
//! This crate provides a simple and efficient way to fetch financial data from Yahoo Finance.
//! It is designed to feel familiar to users of the popular Python `yfinance` library, but
//! leverages Rust's powerful type system and async capabilities for performance and safety.
//!
//! ## Features
//!
//! * **Historical Data**: Fetch daily, weekly, or monthly OHLCV data.
//! * **Multi-Symbol Downloads**: Concurrently download historical data for many symbols at once.
//! * **Real-time Streaming**: Get live quote updates using WebSockets (with an HTTP polling fallback).
//! * **Company Profiles**: Retrieve detailed information about companies, ETFs, and funds.
//! * **Options Chains**: Fetch expiration dates and full option chains (calls and puts).
//! * **Financials**: Access income statements, balance sheets, and cash flow statements (annual & quarterly).
//! * **Analyst Ratings**: Get price targets, recommendations, and upgrade/downgrade history.
//! * **Holder Information**: Get major, institutional, and mutual fund holder data.
//! * **ESG Scores**: Fetch detailed Environmental, Social, and Governance ratings.
//! * **News**: Retrieve the latest articles and press releases for a ticker.
//! * **Search**: Find tickers by name or keyword.
//! * **Async API**: Built on `tokio` and `reqwest` for non-blocking I/O.
//! * **High-Level `Ticker` Interface**: A convenient, yfinance-like struct for accessing all data for a single symbol.
//! * **Builder Pattern**: Fluent builders for constructing complex queries.
//! * **Configurable Retries**: Automatic retries with exponential backoff for transient network errors.
//!
//! ## Quick Start
//!
//! To get started, add `yfinance-rs` to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! yfinance-rs = "0.1.1"
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! Then, create a `YfClient` and use a `Ticker` to fetch data.
//!
//! ```no_run
//! use yfinance_rs::{Interval, Range, Ticker, YfClient};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = YfClient::default();
//! let ticker = Ticker::new(client, "AAPL".to_string());
//!
//! // Get the latest quote
//! let quote = ticker.quote().await?;
//! println!("Latest price for AAPL: ${:.2}", quote.regular_market_price.unwrap_or(0.0));
//!
//! // Get historical data for the last 6 months
//! let history = ticker.history(Some(Range::M6), Some(Interval::D1), false).await?;
//! if let Some(last_bar) = history.last() {
//! println!("Last closing price: ${:.2} on timestamp {}", last_bar.close, last_bar.ts);
//! }
//!
//! // Get analyst recommendations
//! let recs = ticker.recommendations().await?;
//! if let Some(latest_rec) = recs.first() {
//! println!("Latest recommendation period: {}", latest_rec.period);
//! }
//!
//! Ok(())
//! }
//! ```
/// Core components, including the `YfClient` and `YfError`.
// --- feature modules ---
/// Fetch analyst ratings, price targets, and upgrade/downgrade history.
/// Download historical data for multiple symbols concurrently.
/// Fetch ESG (Environmental, Social, Governance) scores and involvement data.
/// Fetch financial statements (income, balance sheet, cash flow) and earnings data.
/// Fetch historical OHLCV data for a single symbol.
/// Fetch holder information, including major, institutional, and insider holders.
/// Fetch news articles for a ticker.
/// Retrieve company or fund profile information.
/// Fetch quotes for multiple symbols.
/// Search for tickers by name or keyword.
/// Stream real-time quote updates via WebSockets or polling.
/// A high-level interface for a single ticker, providing access to all data types.
// --- re-exports (public API remains the same names as before) ---
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use HistoryBuilder;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ApiPreference;