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
//! External financial data source adapters (internal — use `Ticker` or re-export modules).
//!
//! Adapters are `pub(crate)` — users interact with data through [`Ticker`](crate::Ticker),
//! [`Tickers`](crate::Tickers), and the public re-export modules ([`edgar`](crate::edgar),
//! [`fred`](crate::fred), [`crypto`](crate::crypto)). The provider system automatically
//! dispatches to the right adapter based on configured providers.
//!
//! Each adapter follows the standard structure (mod, client, models, optional endpoints)
//! with capability-mapped subdirectories.
//!
//! # Available adapters
//!
//! | Feature | Provider | Free tier | Endpoints | Coverage |
//! |---------|----------|-----------|-----------|----------|
//! | `alphavantage` | [Alpha Vantage](https://www.alphavantage.co/) | 25 req/day | ~100 | Stocks, forex, crypto, commodities, economic indicators, 50+ technical indicators |
//! | `polygon` | [Massive](https://massive.com/) | 5 req/sec | ~100 | Stocks, options, forex, crypto, indices, futures, economy, analyst data, WebSocket streaming |
//! | `fmp` | [Financial Modeling Prep](https://financialmodelingprep.com/) | 250 req/day | ~100 | Fundamentals, DCF/ratings, insider trading, institutional holdings, screener, 60+ exchanges |
//! | `crypto` | [CoinGecko](https://www.coingecko.com/) | 30 req/min | 2 | Top coins by market cap, single coin quotes (keyless) |
//! | `fred` | [FRED](https://fred.stlouisfed.org/) | 120 req/min | 2+ | 800k+ macro time series, US Treasury yield curve |
//! | `worldbank` | [World Bank Open Data](https://data.worldbank.org/) | Keyless | 1 | ~1,600 global development/macro indicators across 200+ economies |
//! | `fiscaldata` | [US Treasury FiscalData](https://fiscaldata.treasury.gov/) | Keyless | 50+ datasets | Federal debt, average interest rates, daily Treasury statements |
//! | `bls` | [BLS Public Data](https://www.bls.gov/developers/) | Keyless (25/day) or keyed (500/day) | 1 | CPI, unemployment, payrolls, wages, PPI from the primary source |
//! | `frankfurter` | [Frankfurter](https://frankfurter.dev/) | Keyless | 1 | ECB daily reference exchange rates — the only keyless forex route |
//! | `binance` | [Binance public data](https://data-api.binance.vision/) | Keyless | 2 | Exchange-grade crypto quotes and arbitrary-interval OHLCV (geo-blocked in some regions) |
//! | `kraken` | [Kraken public data](https://api.kraken.com/) | Keyless | 2 | Crypto quotes and OHLC candles; US-accessible complement to Binance |
//! | `finra` | [FINRA Query API](https://developer.finra.org/) | Keyless (non-commercial) | 1 | Daily short-sale volume by security, from the primary source |
//! | `openfigi` | [OpenFIGI](https://www.openfigi.com/api) | Keyless (25 req/min) | 1 | CUSIP/ISIN/SEDOL/FIGI to ticker resolution |
//! | `defi` | [DefiLlama](https://defillama.com/docs/api) | Keyless | 3 | Protocol TVL (current + history), chain rankings, stablecoin supplies |
//! | `gdelt` | [GDELT DOC 2.0](https://www.gdeltproject.org/) | Keyless (~1 req/5s) | 1 | Worldwide online news search across 65 languages, updated every 15 minutes |
//! | `cftc` | [CFTC Public Reporting](https://publicreporting.cftc.gov/) | Keyless | 1 | Weekly Commitments of Traders futures positioning (disaggregated futures-only report) |
//! | `housetrades` | [House Clerk Financial Disclosure](https://disclosures-clerk.house.gov/FinancialDisclosure) | Keyless | 1 | House of Representatives Periodic Transaction Report (PTR) stock-trade disclosures |
//! | `senatetrades` | [Senate eFD](https://efdsearch.senate.gov/) | Keyless (headless-Chromium) | 1 | Senate Periodic Transaction Report (PTR) stock-trade disclosures |
//! | *(always)* | [SEC EDGAR](https://www.sec.gov/edgar) | 10 req/sec | 5+ | Filing history, XBRL financials, full-text search (keyless, requires contact email) |
//!
//! # Quick comparison
//!
//! - **Alpha Vantage**: Best free option for technical indicators (50+) and economic data. Lowest rate limits.
//! - **Massive (formerly Polygon.io)**: Tick-level trades/quotes, SEC filings, and real-time WebSocket streams. Best for market microstructure.
//! - **CoinGecko**: Best for cryptocurrency data. Keyless (public API). Rate-limited to 30 req/min.
//! - **FRED**: 800k+ US macro-economic time series (GDP, CPI, employment, interest rates). Free API key required.
//! - **SEC EDGAR**: Company filings, XBRL financials, full-text search. Always available, no feature flag needed.
//!
//! All adapters share:
//! - Singleton pattern with `init(api_key)` / `init_with_timeout(api_key, timeout)`
//! - Built-in rate limiting via shared token-bucket limiter
//! - Error mapping to [`crate::FinanceError`] variants
//! - Full mockito test coverage (no API key needed to run tests)
pub
pub
pub
/// Alpha Vantage financial data API (requires `alphavantage` feature).
pub
/// Massive financial data API (formerly Polygon.io; requires `polygon` feature).
pub
/// Financial Modeling Prep (FMP) financial data API (requires `fmp` feature).
pub
/// CoinGecko cryptocurrency data API (keyless, requires `crypto` feature).
pub
/// FRED economic data API (requires `fred` feature).
pub
/// World Bank Open Data global macro indicators (keyless, requires `worldbank` feature).
pub
/// US Treasury FiscalData federal fiscal statistics (keyless, requires `fiscaldata` feature).
pub
/// BLS labor and inflation statistics (keyless v1 / keyed v2, requires `bls` feature).
pub
/// Frankfurter ECB reference exchange rates (keyless, requires `frankfurter` feature).
pub
/// Binance public market data (keyless, requires `binance` feature).
pub
/// Kraken public market data (keyless, requires `kraken` feature).
pub
/// FINRA daily short-sale volume (keyless, requires `finra` feature).
pub
/// OpenFIGI security-identifier mapping (keyless, requires `openfigi` feature).
pub
/// DefiLlama DeFi TVL and stablecoin data (keyless, requires `defi` feature).
pub
/// GDELT DOC 2.0 global news search (keyless, requires `gdelt` feature).
pub
/// CFTC Commitments of Traders futures positioning (keyless, requires `cftc` feature).
pub
/// Nasdaq market-wide earnings/IPO/dividend/split calendars (keyless, requires `nasdaq` feature).
pub
/// Wikipedia S&P 500 index-constituent table scraping (keyless, requires `wikipedia` feature).
pub
/// House of Representatives PTR stock-trade disclosures (keyless, requires `housetrades` feature).
pub
/// Senate PTR stock-trade disclosures (keyless, browser-driven, requires `senatetrades` feature).
pub
/// SEC EDGAR API client (always available, requires init with contact email).
pub
/// Yahoo Finance API endpoints (always available — the canonical data source).
pub