Skip to main content

pomelo_fmp/
lib.rs

1//! Bring-your-own-key FMP ([Financial Modeling Prep](https://site.financialmodelingprep.com/))
2//! data sync + snapshot-factor formulas (issue #52 / #132).
3//!
4//! Direct HTTP, **no third-party FMP SDK**. Given the user's own API key, fetch
5//! adjusted daily bars (and optionally annual fundamentals, a `symbol → sector`
6//! industry map, and snapshot-factor panels) and write a [`docs/data-layout.md`](../../../docs/data-layout.md)
7//! tree:
8//!
9//! ```text
10//! <out>/prices/{SYM}.csv.gz        adjusted OHLCV                 (always)
11//! <out>/fundamentals/{SYM}.csv.gz  dense forward-filled factors   (--include-fundamentals)
12//! <out>/tracked/universe.csv.gz    symbol,sector,market_cap       (--include-industry)
13//! <out>/panels/{name}.csv.gz       snapshot-factor panels         (--include-snapshot-factors)
14//! ```
15//!
16//! ## Reuse across CLI and service
17//!
18//! [`sync`] writes to a local path; [`sync_into`] is the storage-agnostic core
19//! over any `ObjectSink` + `ObjectSource`, so the CLI and a backend service
20//! produce **byte-identical** trees whether the destination is local disk or an
21//! S3/R2 bucket (`pomelo-s3`'s `S3Source`). The pure [`factors`] formulas
22//! are the single source of truth a Rust service links directly (and wasm/PyO3
23//! bindings can expose later).
24//!
25//! The key never leaves the machine; we neither host nor redistribute FMP data.
26//! FMP stays **out** of `yuzu-core` / `pomelo-data` / WASM — the [`HttpClient`]
27//! indirection keeps networking optional (build with `--no-default-features`)
28//! and testable.
29//!
30//! ## MVP scope
31//!
32//! Enough to backtest **price-based** strategies over a short US window: close /
33//! OHLC TA and cross-section ops on a modest symbol list. Fundamentals are
34//! best-effort from the annual ratios/key-metrics/growth endpoints (plus
35//! `income-statement` for filing-date visibility, #131); richer
36//! fundamentals, full-universe, and point-in-time index membership are out of
37//! scope (see #53 / #125). Delisted names can be unioned into the universe with
38//! `--include-delisted` for survivorship-honest backtests (#124 / #26) — see
39//! [`delisted`]. Which library features an FMP Starter key can *honestly*
40//! support — and which panels are missing — is documented in
41//! [`docs/fmp-data-source.md`](../../../docs/fmp-data-source.md) (#51).
42
43mod config;
44mod delisted;
45/// Pure, I/O-free snapshot-factor formulas — the canonical implementation the
46/// CLI, a Rust service, and (later) wasm/PyO3 bindings all share.
47mod factors;
48mod fundamentals;
49mod http;
50mod index;
51mod industry;
52mod price;
53mod snapshot;
54mod sync;
55mod universe;
56mod util;
57
58#[cfg(test)]
59mod tests;
60
61/// FMP API root. The stable endpoints (`/stable/...`) are the current surface.
62pub(crate) const FMP_BASE: &str = "https://financialmodelingprep.com";
63
64/// Object key the industry snapshot is written under (`tracked/{name}`).
65pub(crate) const INDUSTRY_KEY: &str = "tracked/universe.csv.gz";
66
67pub use config::{SyncConfig, SyncSummary, WriteMode};
68pub use delisted::{fetch_delisted, DelistedSymbol};
69/// The real ureq-backed client — only with the `fmp-sync` feature. A dependent
70/// that supplies its own [`HttpClient`] can build with the feature off.
71#[cfg(feature = "fmp-sync")]
72pub use http::UreqClient;
73pub use http::{HttpClient, HttpError};
74pub use index::{write_index_membership, Index, IndexMembership, MEMBERSHIP_SERIES};
75pub use sync::{sync, sync_into};
76pub use universe::{
77    build_symbol_list, parse_market_cap, parse_symbols_list, SymbolFilter, US_EXCHANGES,
78};