Connectors
Ten source connectors ship with Hermes, each exposing an async fetch() that returns canonical records and sits behind the shared RawCache.
All connectors at a glance
| Source | Class | Cache TTL | Status |
|---|---|---|---|
| World Bank | hermes.connectors.World_bank | 7 days | Working |
| IMF (SDMX) | hermes.connectors.IMF | 7 days | Working |
| FRED | hermes.connectors.FRED | 30 days | Working |
| Binance | hermes.connectors.Binance | 1 day | Working |
| Finnhub | hermes.connectors.FINNHUB | 7 days | Working |
| Yfinance | hermes.connectors.Yfinance | 1 day | Working |
| SEC EDGAR | hermes.connectors.SECEDGAR | 7 days | Working |
| OpenSanctions | hermes.connectors.OpenSanction | 30 days | Working |
| Bundled datasets | hermes.connectors.PUBLIC_DATASET | — | Working |
| GDELT | hermes.connectors.GDELT | — | Stub |
Source coverage spans global macro, financial markets, corporate filings, sanctions and governance intelligence. TTLs are deliberately conservative for stable public sources and tighter for fast-moving market data.
The connector contract
A connector answers one question: how do I get this source's data? In Hermes, each connector package pairs its fetch() with a parser, a normalizer and field mappings. Connectors can provide authentication, requests, pagination, rate limiting, retries and source-specific parsing — but generic retry, caching and validation belong to Hermes infrastructure, not to the connector.
Connectors use aiohttp with exponential-backoff retries (sleeps 2**attempt seconds) and resolve keys through RawCache.get_or_fetch.
World Bank
| Item | Detail |
|---|---|
| Class | hermes.connectors.World_bank |
| Base URL | https://api.worldbank.org/v2 |
| Cache source | world_bank · TTL 7 days |
| fetch() | fetch(country_code, indicator_code, frequency=None, most_recent=None, per_page=1000, page=1, force=False) |
| Return | DataFrame with date, indicator_id, indicator_name, country, value, source |
from hermes import Hermes
hermes = Hermes(opensanction_api="x", new_data_api="x",
sec_username="x", sec_email="x")
df = hermes.world_bank.fetch(
country_code="BR",
indicator_code="SP.POP.TOTL", # total population
frequency="Y",
)IMF (SDMX)
| Item | Detail |
|---|---|
| Class | hermes.connectors.IMF |
| Base URL | https://api.imf.org/external/sdmx/3.0/data/dataflow/ |
| Cache source | imf · TTL 7 days |
| fetch() | fetch(country, agency, dataflow_id, key, version='~', force=False) |
| Return | Normalized SDMX DataFrame; empty DataFrame on 404 |
# IMF WEO government debt (% of GDP)
df = hermes.imf.fetch(
country="US",
agency="IMF.RES",
dataflow_id="WEO",
key="GGXWDG_NGDP",
)FRED
| Item | Detail |
|---|---|
| Class | hermes.connectors.FRED |
| Base URL | https://api.stlouisfed.org/fred/series/observations |
| Cache source | fred · TTL 30 days |
| fetch() | fetch(series_id, timeout=30.0, retries=3, force=False) |
23 curated macro series are defined in fred/mappings.py, including GDPC1, A191RL1Q225SBEA, INDPRO, CPIAUCSL, CPILFESL, PCEPI, UNRATE, PAYEMS, CIVPART, FEDFUNDS, DGS10, DGS2, DGS3MO, T10Y2Y, T10Y3M, M2SL, TOTBKCR, HOUST, EXHOSLUSM495S, SP500, VIXCLS, DTWEXBGS.
fd = hermes.fred.fetch(series_id="CPIAUCSL") # CPIBinance
| Item | Detail |
|---|---|
| Class | hermes.connectors.Binance |
| Base URL | api.binance.com (spot) / fapi.binance.com (future) |
| Cache source | binance · TTL 1 day |
| fetch() | fetch(mode, endpoint, symbol, interval=None, limit=None, period=None, retries=3, timeout=30.0, force=False) |
| fetch_history() | fetch_history(symbol, interval='1d', market='future', years=2, max_concurrent=10) |
Endpoints (per binance/mappings.py): ohlcv, trades, aggregated_trades, order_book, best_bid_ask, 24hr, exchangeInfo; plus future-only fundingRate, openInterest, premiumIndex, openInterestHist, longShortRatio, topLongShortAccountRatio, topLongShortPositionRatio. fetch_history splits the range into 1000-bar windows fetched concurrently (semaphore = 10).
# 2 years of daily BTCUSDT futures candles
df = hermes.binance.fetch_history(
symbol="BTCUSDT", interval="1d",
market="future", years=2,
)Finnhub
| Item | Detail |
|---|---|
| Class | hermes.connectors.FINNHUB |
| Base URL | https://finnhub.io/api/v1 |
| Cache source | finnhub · TTL 7 days |
| fetch() | fetch(endpoint, symbol, resolution=None, _from=None, _to=None, force=False) |
| fetch_candles_history() | fetch_candles_history(symbol, resolution='D', years=2) |
Endpoints: candles, quote, profile, metric, peers, earnings, insider, eps, ebitda, revenue, news, symbol. Lookback is capped by FINNHUB_MAX_DAYS per resolution (e.g. 1m/5m → 7d, 15m–1h → 30d, D/W/M → 365d).
Yfinance
| Item | Detail |
|---|---|
| Class | hermes.connectors.Yfinance |
| Cache source | yfinance · TTL 1 day |
| fetch() | fetch(endpoint, symbol, force=False) — endpoints: quote, eps_estimate, revenue_estimate, earnings_history |
| fetch_history() | fetch_history(symbol, interval='1d', years=2) |
Raised restricted intervals (raises ValueError for unsupported ones). The interval map: 1m/5m/15m/30m/1h/1d map to themselves, 1w → 1wk, 1M → 1mo.
SEC EDGAR
| Item | Detail |
|---|---|
| Class | hermes.connectors.SECEDGAR |
| Base URL | https://data.sec.gov/api/xbrl/companyfacts |
| Cache source | sec_edgar · TTL 7 days |
| fetch() | fetch(symbol, timeout=30.0, retries=3, force=False) |
Resolves a ticker to its CIK via sec-cik-mapper and requests <user-agent> <email> as required by the SEC. The SEC_TAG_MAP (sec/tags.py) maps canonical fields to XBRL GAAP tags — e.g. revenue, net_income, operating_cash_flow, long_term_debt, shares_outstanding, dividends, buybacks, etc.
OpenSanctions
| Item | Detail |
|---|---|
| Class | hermes.connectors.OpenSanction |
| Base URL | https://api.opensanctions.org |
| Auth | Authorization: ApiKey <key> |
| Cache source | OpenSanction · TTL 30 days |
| fetch() | fetch(country, dataset, limit=50, changed_since=None, topic=None, facets=None, force=False) |
Supports datasets such as us_ofac_sdn, eu_fsf, uk_fcdos and un_sc. Country ISO3 is converted to ISO2 internally before filtering.
GDELT
| Item | Detail |
|---|---|
| Class | hermes.connectors.GDELT |
| Status | Stub (empty class) |
The GDELT connector is scaffolded but not yet implemented — global news/event data powers the geopolitical features, which are similarly stubbed.
Bundled public datasets
| Item | Detail |
|---|---|
| Class | hermes.connectors.PUBLIC_DATASET |
| Location | hermes/connectors/lib/datasets/ |
Reads bundled local CSVs, country-filtered with years converted to datetime:
fetch_hrs(country)fetch_hdi(country)fetch_cpi(country)fetch_fsi(country)fetch_nato(country)fetch_crs(country)fetch_cvs(country)fetch_sipri(country)Retries & timeouts
retries=3 and timeout=30.0, retrying with exponential backoff. Pass force=True to bypass the cache.Backoff sleeps 2**attempt seconds so transient failures settle quickly without hammering the source. Because retry, caching and validation are handled by Hermes infrastructure rather than each connector, adding a new source never means re-implementing that plumbing.