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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
//! # 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
//!
//! ### Core Data
//! * **Historical Data**: Fetch daily, weekly, or monthly OHLCV data with automatic split/dividend adjustments.
//! * **Real-time Quotes**: Get live quote updates with detailed market information.
//! * **Fast Quotes**: Optimized quote fetching with essential data only (`fast_info`).
//! * **Multi-Symbol Downloads**: Concurrently download historical data for many symbols at once.
//! * **Batch Quotes**: Fetch quotes for multiple symbols efficiently.
//!
//! ### Corporate Actions & Dividends
//! * **Typed Corporate Actions**: Fetch dividends, splits, and capital gains through one currency-aware action stream.
//!
//! ### Financial Statements & Fundamentals
//! * **Income Statements**: Access annual and quarterly income statements.
//! * **Balance Sheets**: Get annual and quarterly balance sheet data.
//! * **Cash Flow Statements**: Fetch annual and quarterly cash flow data.
//! * **Earnings Data**: Historical earnings, revenue estimates, and EPS data.
//! * **Shares Outstanding**: Historical data on shares outstanding (annual and quarterly).
//! * **Corporate Calendar**: Earnings dates, ex-dividend dates, and dividend payment dates.
//!
//! ### Options & Derivatives
//! * **Options Chains**: Fetch expiration dates and full option chains (calls and puts).
//! * **Option Contracts**: Detailed option contract information.
//!
//! ### Analysis & Research
//! * **Analyst Ratings**: Get price targets, recommendations, and upgrade/downgrade history.
//! * **Earnings Trends**: Detailed earnings and revenue estimates from analysts.
//! * **Recommendations Summary**: Summary of current analyst recommendations.
//! * **Upgrades/Downgrades**: History of analyst rating changes.
//!
//! ### Ownership & Holders
//! * **Major Holders**: Get major, institutional, and mutual fund holder data.
//! * **Institutional Holders**: Top institutional shareholders and their holdings.
//! * **Mutual Fund Holders**: Mutual fund ownership breakdown.
//! * **Insider Transactions**: Recent insider buying and selling activity.
//! * **Insider Roster**: Company insiders and their current holdings.
//! * **Net Share Activity**: Summary of insider purchase/sale activity.
//!
//! ### ESG & Sustainability
//! * **ESG Scores**: Fetch Environmental, Social, and Governance ratings when Yahoo returns them.
//! * **ESG Involvement**: Specific ESG involvement and controversy data when Yahoo returns it.
//!
//! ### News & Information
//! * **Company News**: Retrieve the latest articles and press releases for a ticker.
//! * **Company Profiles**: Detailed information about companies, ETFs, and funds.
//! * **Search**: Find tickers by name or keyword.
//!
//! ### Real-time Streaming
//! * **WebSocket Streaming**: Get live quote updates using `WebSockets` (preferred method).
//! * **HTTP Polling**: Fallback polling method for real-time data.
//! * **Configurable Streaming**: Customize update frequency and change-only filtering.
//!
//! ### Advanced Features
//! * **Data Rounding**: Control price precision and rounding.
//! * **Malformed Data Handling**: Drops invalid OHLC rows while preserving valid sibling data.
//! * **Back Adjustment**: Alternative price adjustment methods.
//! * **Historical Metadata**: Timezone and other metadata for historical data.
//! * **ISIN Lookup**: Get International Securities Identification Numbers.
//!
//! ### Developer Experience
//! * **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.
//! * **Caching**: Configurable caching behavior for API responses.
//! * **Custom Timeouts**: Configurable request timeouts and connection settings.
//!
//! ## Cargo Features
//!
//! User-facing optional features:
//! * `stream`: enables WebSocket streaming support.
//! * `dataframe`: re-exports `paft` `DataFrame` conversion traits.
//! * `tracing`: compiles structured tracing instrumentation.
//!
//! Internal/unstable features:
//! * `test-mode`: enables repository test hooks, fixture recording, and
//! doc-hidden plumbing APIs for yfinance-rs' own integration tests.
//! * `debug-dumps`: enables maintainer diagnostics for dumping selected raw
//! Yahoo responses.
//! * `tracing-subscriber`: test/example convenience for initializing a basic
//! subscriber; applications should configure their own subscriber instead.
//!
//! Internal features are published only because Cargo has no private feature
//! namespace. They are not part of the supported user-facing API.
//!
//! ## Quick Start
//!
//! To get started, add `yfinance-rs` to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! yfinance-rs = "0.9.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");
//!
//! // Get the latest quote
//! let quote = ticker.quote().await?;
//! if let Some(price) = quote.price.as_ref() {
//! println!("Latest price for AAPL: {price}");
//! }
//!
//! // 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: {} on timestamp {}", last_bar.ohlc.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.
/// Run Yahoo Finance predefined and custom screeners.
/// 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.
// Core types that are provider-specific
pub use ;
/// `DataFrame` conversion traits re-exported from `paft`.
pub use ;
// Provider-specific builders and utilities
pub use AnalysisBuilder;
pub use ;
pub use EsgBuilder;
pub use FundamentalsBuilder;
pub use HistoryBuilder;
pub use HoldersBuilder;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Initialize a default tracing subscriber for tests/examples when the
/// `tracing-subscriber` feature is enabled. No-op otherwise.
// Explicitly re-export selected paft types exposed by this crate's public API.
pub use crate;
pub use crate;
pub use Snapshot;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use KeyStatistics;
pub use NewsArticle;
pub use ;
pub use BookLevel;
pub use QuoteUpdate;
pub use ;
pub use Ohlc;
pub use ;
pub use ;
pub use ;