Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add four missing finnhub tables (#108305)

Tom Owers9c5473f6e31b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 06413e92bcb7..7167f0228c39 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -3108,7 +3108,7 @@ Note: The stable docs page lists ~230 endpoints; PostHog exposes 21. None of the
## Finnhub — **thin**
-Today (15): `basic_financials`, `company_news`, `company_profile`, `country`, `earnings_calendar`, `earnings_surprises`, `financials_reported`, `insider_transactions`, `ipo_calendar`, `market_news`, `quote`, `recommendation_trends`, `sec_filings`, `stock_candles`, `stock_symbols`
+Today (19): `basic_financials`, `company_news`, `company_profile`, `country`, `dividends`, `earnings_calendar`, `earnings_surprises`, `economic_calendar`, `financials_reported`, `index_constituents`, `insider_transactions`, `ipo_calendar`, `market_news`, `peers`, `quote`, `recommendation_trends`, `sec_filings`, `stock_candles`, `stock_symbols`
Diffed against: <https://finnhub.io/static/swagger.json>
@@ -3116,14 +3116,14 @@ Diffed against: <https://finnhub.io/static/swagger.json>
- [x] `/stock/candle` — historical OHLCV bars, the backbone of any price time-series analysis (quote is a point-in-time snapshot only) (high)
- [x] `/stock/filings` — SEC filing index per symbol, the join key from company to disclosure documents (high)
- [x] `/stock/insider-transactions` — insider buy/sell transaction rows, a headline alt-data signal (high)
-- [ ] `/stock/dividend` — dividend history transactions; nothing in the current table set carries payouts (high)
-- [ ] `/stock/peers` — lookup table resolving each synced symbol to its comparable set for benchmarking (high)
+- [x] `/stock/dividend` — dividend history transactions; nothing in the current table set carries payouts (high) — added as `dividends`, one row per payout, incremental on the ex-dividend date
+- [x] `/stock/peers` — lookup table resolving each synced symbol to its comparable set for benchmarking (high) — added as `peers`, one row per (symbol, peer)
- [ ] `/stock/price-target` — analyst price targets, a natural companion to recommendation_trends which is already synced (medium)
- [ ] `/stock/upgrade-downgrade` — individual analyst rating change events behind the aggregated recommendation trends (medium)
- [ ] `/stock/eps-estimate (plus revenue-estimate, ebitda-estimate, ebit-estimate)` — forward consensus estimates to pair with the already-synced earnings surprises (medium)
- [ ] `/stock/split` — split events needed to adjust any price or per-share series (medium)
-- [ ] `/index/constituents` — lookup table mapping indices to member symbols, enabling index-level roll-ups of synced symbols (medium)
-- [ ] `/calendar/economic` — macro event calendar; earnings and IPO calendars are already synced but the economic one is not (medium)
+- [x] `/index/constituents` — lookup table mapping indices to member symbols, enabling index-level roll-ups of synced symbols (medium) — added as `index_constituents`, fanned out over a new indices field
+- [x] `/calendar/economic` — macro event calendar; earnings and IPO calendars are already synced but the economic one is not (medium) — added as `economic_calendar`, full refresh over a rolling past+future window
Note: Finnhub's public swagger exposes ~115 GET resources; PostHog syncs 11. Ownership (/stock/ownership, /stock/fund-ownership, /institutional/ownership), transcripts (/stock/transcripts/list), ETF/mutual-fund holdings, historical market cap and revenue breakdowns are also absent but ranked below the 12 above.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/canonical_descriptions.py
index d9939ba1c5be..4900dfb8a1f6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/canonical_descriptions.py
@@ -219,4 +219,54 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"transactionCode": "SEC Form 4 transaction code (e.g. P for purchase, S for sale).",
},
},
+ "dividends": {
+ "description": "Dividend payouts declared by a company, one row per payout.",
+ "docs_url": "https://finnhub.io/docs/api/dividends",
+ "columns": {
+ "symbol": "Company ticker.",
+ "date": "Ex-dividend date.",
+ "amount": "Dividend amount in the local currency.",
+ "adjustedAmount": "Dividend amount adjusted for later splits.",
+ "payDate": "Date the dividend is paid to holders.",
+ "recordDate": "Date a holder must be on the register to receive the dividend.",
+ "declarationDate": "Date the dividend was declared.",
+ "currency": "Currency the dividend is paid in.",
+ "freq": "Dividend frequency code (0 annually, 1 monthly, 2 quarterly, 3 semi-annually, 4 other, 5 bimonthly, 6 trimesterly, 7 weekly).",
+ },
+ },
+ "peers": {
+ "description": "Comparable companies for a symbol, one row per peer. Finnhub picks peers operating in the same country and sector or industry.",
+ "docs_url": "https://finnhub.io/docs/api/company-peers",
+ "columns": {
+ "symbol": "Requested ticker the peer set was fetched for.",
+ "peer": "Ticker of one comparable company.",
+ },
+ },
+ "index_constituents": {
+ "description": "Member symbols of a stock index, one row per constituent.",
+ "docs_url": "https://finnhub.io/docs/api/indices-constituents",
+ "columns": {
+ "index_symbol": "Requested index symbol the constituents were fetched for.",
+ "symbol": "Ticker of the constituent company.",
+ "name": "Name of the constituent company.",
+ "weight": "Weight of the constituent in the index.",
+ "isin": "ISIN identifier of the constituent.",
+ "cusip": "CUSIP identifier of the constituent.",
+ "shareClassFIGI": "Global share class FIGI of the constituent.",
+ },
+ },
+ "economic_calendar": {
+ "description": "Recent and upcoming macroeconomic releases, one row per scheduled event.",
+ "docs_url": "https://finnhub.io/docs/api/economic-calendar",
+ "columns": {
+ "country": "Country the release covers.",
+ "event": "Name of the economic release.",
+ "time": "Release time.",
+ "actual": "Released figure. Empty until the release lands.",
+ "estimate": "Consensus estimate for the release.",
+ "prev": "Figure from the previous release.",
+ "impact": "Expected market impact of the release (low, medium, high).",
+ "unit": "Unit the figures are expressed in.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/finnhub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/finnhub.py
index 36e55e1b722a..a4855e114b12 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/finnhub.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/finnhub.py
@@ -128,6 +128,13 @@ def _expand_columnar(data: Any) -> list[dict[str, Any]]:
return [{key: values[index] for key, values in columns.items()} for index in range(length)]
+def _expand_string_list(values: Any, field: str) -> list[dict[str, Any]]:
+ """Turn a bare array of strings (peers, index constituents) into one row per string."""
+ if not isinstance(values, list):
+ return []
+ return [{field: value} for value in values if isinstance(value, str) and value]
+
+
def _extract_rows(data: Any, config: FinnhubEndpointConfig) -> list[dict[str, Any]]:
"""Normalize a Finnhub response into a list of row dicts per the endpoint's shape."""
if config.columnar:
@@ -138,7 +145,12 @@ def _extract_rows(data: Any, config: FinnhubEndpointConfig) -> list[dict[str, An
return [data] if isinstance(data, dict) and data else []
if config.data_key:
rows = data.get(config.data_key) if isinstance(data, dict) else None
+ if not rows and config.fallback_string_list_key and config.string_list_field:
+ fallback = data.get(config.fallback_string_list_key) if isinstance(data, dict) else None
+ return _expand_string_list(fallback, config.string_list_field)
return rows or []
+ if config.string_list_field:
+ return _expand_string_list(data, config.string_list_field)
return data if isinstance(data, list) else []
@@ -191,7 +203,7 @@ def _emit(rows: list[dict[str, Any]], symbol: str | None, config: FinnhubEndpoin
# Inject the requested ticker: several per-symbol endpoints (quote, company-news) omit it,
# and it's part of those tables' primary keys.
for row in rows:
- row["symbol"] = symbol
+ row[config.symbol_field] = symbol
if config.incremental_fields:
# Guarantee ascending order so the declared `sort_mode="asc"` matches the data the
# incremental watermark is checkpointed against, regardless of the API's response order.
@@ -223,18 +235,20 @@ def get_rows(
symbols: str | None,
exchange: str | None,
logger: FilteringBoundLogger,
+ indices: str | None = None,
should_use_incremental_field: bool = False,
db_incremental_field_last_value: Any = None,
) -> Iterator[list[dict[str, Any]]]:
config = FINNHUB_ENDPOINTS[endpoint]
session = make_tracked_session(headers=_headers(api_key), redact_values=(api_key,))
- if config.requires_symbol:
- tickers = _parse_symbols(symbols, logger)
+ if config.requires_symbol or config.requires_index:
+ field_label = "Indices" if config.requires_index else "Symbols"
+ tickers = _parse_symbols(indices if config.requires_index else symbols, logger)
if not tickers:
logger.warning(
- f"Finnhub: endpoint '{endpoint}' needs symbols but none are configured; nothing to sync. "
- "Add tickers to the source's Symbols field."
+ f"Finnhub: endpoint '{endpoint}' needs {field_label.lower()} but none are configured; nothing "
+ f"to sync. Add them to the source's {field_label} field."
)
return
for ticker in tickers:
@@ -260,6 +274,7 @@ def finnhub_source(
symbols: str | None,
exchange: str | None,
logger: FilteringBoundLogger,
+ indices: str | None = None,
should_use_incremental_field: bool = False,
db_incremental_field_last_value: Optional[Any] = None,
) -> SourceResponse:
@@ -273,6 +288,7 @@ def finnhub_source(
symbols=symbols,
exchange=exchange,
logger=logger,
+ indices=indices,
should_use_incremental_field=should_use_incremental_field,
db_incremental_field_last_value=db_incremental_field_last_value,
),
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/settings.py
index c89758c81aef..6542c177f7b0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/settings.py
@@ -19,6 +19,12 @@ class FinnhubEndpointConfig:
# The response is parallel arrays keyed by field name (Finnhub's candle shape) that are
# zipped back into one row per index.
columnar: bool = False
+ # The rows are a bare array of strings rather than objects. Each string becomes one row
+ # under this field name.
+ string_list_field: Optional[str] = None
+ # Key holding a bare array of strings, read when `data_key` is absent from the response,
+ # because Finnhub only returns the richer breakdown list on plans that include it.
+ fallback_string_list_key: Optional[str] = None
primary_keys: list[str] = field(default_factory=lambda: ["symbol"])
incremental_fields: list[IncrementalField] = field(default_factory=list)
# Stable field used to partition the Delta table. Either a date string or epoch seconds,
@@ -27,6 +33,11 @@ class FinnhubEndpointConfig:
# Per-symbol fan-out: the endpoint needs a `symbol` query param and is queried once per
# configured ticker, with the requested symbol injected into each emitted row.
requires_symbol: bool = False
+ # Same fan-out, driven by the source-level `indices` field instead of `symbols`.
+ requires_index: bool = False
+ # Row key the fanned-out value is injected into. Index constituents carry their own
+ # `symbol`, so the index they belong to needs a column of its own.
+ symbol_field: str = "symbol"
# Static query params merged into every request for this endpoint (e.g. `metric=all`,
# `category=general`). Keeps an endpoint's full request shape in this one config.
fixed_params: dict[str, str] = field(default_factory=dict)
@@ -93,6 +104,23 @@ FINNHUB_ENDPOINTS: dict[str, FinnhubEndpointConfig] = {
# Same future-dating caveat as the IPO calendar — full refresh over a rolling window.
description="Recent and upcoming company earnings over a rolling window. Full refresh.",
),
+ "economic_calendar": FinnhubEndpointConfig(
+ name="economic_calendar",
+ path="/calendar/economic",
+ data_key="economicCalendar",
+ # Macro releases carry no id, and one country can publish several figures at the same
+ # release time, so the event name is part of the key.
+ primary_keys=["country", "event", "time"],
+ partition_key="time",
+ windowed=True,
+ forward_days=180,
+ # Unlike the other market-wide endpoints, this one is premium, so a free-tier key gets
+ # a 403 the source treats as a permanent failure. Keep it opt-in.
+ should_sync_default=False,
+ # Same future-dating caveat as the IPO and earnings calendars, and `actual` is only
+ # filled in once a release lands, so this is a full refresh over a rolling window.
+ description="Recent and upcoming macroeconomic releases over a rolling window. Full refresh.",
+ ),
"country": FinnhubEndpointConfig(
name="country",
path="/country",
@@ -277,6 +305,56 @@ FINNHUB_ENDPOINTS: dict[str, FinnhubEndpointConfig] = {
],
description="Insider buy and sell transactions reported on Form 3/4/5, for each configured symbol. Supports incremental sync on the transaction date.",
),
+ "dividends": FinnhubEndpointConfig(
+ name="dividends",
+ path="/stock/dividend",
+ requires_symbol=True,
+ # Payouts carry no id, and a company can pay a regular and a special dividend on the
+ # same ex-date, so the amount is part of what identifies the row.
+ primary_keys=["symbol", "date", "amount"],
+ partition_key="date",
+ windowed=True,
+ # `from`/`to` are required here, and a dividend series is only useful with several
+ # years behind it.
+ lookback_days=1825,
+ should_sync_default=False,
+ incremental_fields=[
+ # Finnhub documents `from`/`to` without naming the date they filter. `date` is the
+ # ex-dividend date the row is built around, and it is the only date present on
+ # every payout, so it is what the watermark tracks.
+ {
+ "label": "date",
+ "type": IncrementalFieldType.DateTime,
+ "field": "date",
+ "field_type": IncrementalFieldType.Date,
+ },
+ ],
+ description="Dividend payouts with ex-date, amount, record and pay dates, for each configured symbol. Supports incremental sync on the ex-dividend date.",
+ ),
+ "peers": FinnhubEndpointConfig(
+ name="peers",
+ path="/stock/peers",
+ requires_symbol=True,
+ string_list_field="peer",
+ primary_keys=["symbol", "peer"],
+ should_sync_default=False,
+ description="Comparable companies for each configured symbol, one row per peer. Full refresh.",
+ ),
+ # --- Per-index fan-out (requires configured indices) ---
+ "index_constituents": FinnhubEndpointConfig(
+ name="index_constituents",
+ path="/index/constituents",
+ requires_index=True,
+ symbol_field="index_symbol",
+ # The breakdown list carries names and weights; plans without it still return the plain
+ # symbol array, which lands in the same `symbol` column.
+ data_key="constituentsBreakdown",
+ fallback_string_list_key="constituents",
+ string_list_field="symbol",
+ primary_keys=["index_symbol", "symbol"],
+ should_sync_default=False,
+ description="Member symbols of each configured index, with company name and index weight where the plan provides them. Full refresh.",
+ ),
}
ENDPOINTS = tuple(FINNHUB_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/source.py
index 48dc8a5c2417..00449e514f06 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/source.py
@@ -99,6 +99,7 @@ class FinnhubSource(SimpleSource[FinnhubSourceConfig]):
symbols=config.symbols,
exchange=config.exchange,
logger=inputs.logger,
+ indices=config.indices,
should_use_incremental_field=inputs.should_use_incremental_field,
db_incremental_field_last_value=inputs.db_incremental_field_last_value
if inputs.should_use_incremental_field
@@ -116,7 +117,7 @@ class FinnhubSource(SimpleSource[FinnhubSourceConfig]):
Create a free API key in your [Finnhub dashboard](https://finnhub.io/dashboard).
-Per-company tables (company profile, quote, company news, basic financials, recommendation trends, earnings surprises, stock candles, as-reported financials, SEC filings, insider transactions) are synced for each ticker you list in **Symbols**. Market-wide tables (stock symbols, market news, IPO calendar, earnings calendar, countries) sync without any symbols.
+Per-company tables (company profile, quote, company news, basic financials, recommendation trends, earnings surprises, stock candles, as-reported financials, SEC filings, insider transactions, dividends, peers) are synced for each ticker you list in **Symbols**. The index constituents table is synced for each index you list in **Indices**. Market-wide tables (stock symbols, market news, IPO calendar, earnings calendar, economic calendar, countries) sync without any symbols.
Note: the free tier is rate limited to 60 requests/minute, and some endpoints require a paid plan.""",
iconPath="/static/services/finnhub.png",
@@ -140,6 +141,14 @@ Note: the free tier is rate limited to 60 requests/minute, and some endpoints re
placeholder="AAPL, MSFT, GOOGL",
secret=False,
),
+ SourceFieldInputConfig(
+ name="indices",
+ label="Indices (comma-separated)",
+ type=SourceFieldInputConfigType.TEXT,
+ required=False,
+ placeholder="^GSPC, ^IBEX",
+ secret=False,
+ ),
SourceFieldInputConfig(
name="exchange",
label="Exchange (for the stock symbols table)",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub.py
index 45db578ef85c..4550c1ca4d3b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub.py
@@ -121,6 +121,44 @@ class TestExtractRows:
def test_columnar_non_ok_returns_empty(self, _name: str, payload: Any) -> None:
assert _expand_columnar(payload) == []
+ def test_string_array_becomes_one_row_per_entry(self) -> None:
+ # Peers come back as a bare array of tickers, not objects.
+ rows = _extract_rows(["AAPL", "DELL", "HPQ"], FINNHUB_ENDPOINTS["peers"])
+ assert rows == [{"peer": "AAPL"}, {"peer": "DELL"}, {"peer": "HPQ"}]
+
+ @parameterized.expand(
+ [
+ ("non_string_entries", ["AAPL", 7, None], [{"peer": "AAPL"}]),
+ ("blank_entries", ["AAPL", ""], [{"peer": "AAPL"}]),
+ ("not_a_list", {"error": "boom"}, []),
+ ]
+ )
+ def test_string_array_skips_unusable_entries(self, _name: str, payload: Any, expected: Any) -> None:
+ assert _extract_rows(payload, FINNHUB_ENDPOINTS["peers"]) == expected
+
+ def test_index_constituents_prefer_the_breakdown(self) -> None:
+ payload = {
+ "symbol": "^IBEX",
+ "constituents": ["SAN.MC", "IBE.MC"],
+ "constituentsBreakdown": [{"symbol": "SAN.MC", "name": "Banco Santander SA", "weight": 17.5}],
+ }
+ assert _extract_rows(payload, FINNHUB_ENDPOINTS["index_constituents"]) == [
+ {"symbol": "SAN.MC", "name": "Banco Santander SA", "weight": 17.5}
+ ]
+
+ @parameterized.expand(
+ [
+ ("breakdown_absent", {"constituents": ["SAN.MC", "IBE.MC"]}),
+ ("breakdown_empty", {"constituents": ["SAN.MC", "IBE.MC"], "constituentsBreakdown": []}),
+ ]
+ )
+ def test_index_constituents_fall_back_to_the_plain_symbol_list(self, _name: str, payload: Any) -> None:
+ # Plans without the breakdown still return the symbol array; it lands in the same column.
+ assert _extract_rows(payload, FINNHUB_ENDPOINTS["index_constituents"]) == [
+ {"symbol": "SAN.MC"},
+ {"symbol": "IBE.MC"},
+ ]
+
def test_columnar_truncates_to_shortest_array(self) -> None:
# A short array would otherwise leave a half-populated final row.
payload = {"s": "ok", "t": [100, 200], "c": [1.0]}
@@ -295,6 +333,40 @@ class TestGetRows:
list(get_rows(api_key="k", endpoint="insider_transactions", symbols="AAPL", exchange="US", logger=logger))
logger.error.assert_not_called()
+ def test_peers_rows_carry_the_requested_symbol(self, monkeypatch: Any) -> None:
+ self._patch_fetch(monkeypatch, {"AAPL": ["AAPL", "DELL"]})
+ batches = list(get_rows(api_key="k", endpoint="peers", symbols="AAPL", exchange="US", logger=MagicMock()))
+ assert batches == [[{"peer": "AAPL", "symbol": "AAPL"}, {"peer": "DELL", "symbol": "AAPL"}]]
+
+ def test_index_constituents_fan_out_over_indices_injecting_the_index(self, monkeypatch: Any) -> None:
+ calls = self._patch_fetch(
+ monkeypatch,
+ {"^GSPC": {"constituentsBreakdown": [{"symbol": "AAPL", "weight": 7.0}]}},
+ )
+ batches = list(
+ get_rows(
+ api_key="k",
+ endpoint="index_constituents",
+ symbols="MSFT",
+ exchange="US",
+ logger=MagicMock(),
+ indices="^GSPC",
+ )
+ )
+ # The fan-out reads Indices, not Symbols, and the constituent keeps its own `symbol`.
+ assert [c["params"]["symbol"] for c in calls] == ["^GSPC"]
+ assert batches == [[{"symbol": "AAPL", "weight": 7.0, "index_symbol": "^GSPC"}]]
+
+ def test_index_constituents_with_no_indices_yields_nothing_and_warns(self, monkeypatch: Any) -> None:
+ # A configured Symbols list must not be mistaken for an index list.
+ self._patch_fetch(monkeypatch, {})
+ logger = MagicMock()
+ batches = list(
+ get_rows(api_key="k", endpoint="index_constituents", symbols="AAPL", exchange="US", logger=logger)
+ )
+ assert batches == []
+ assert "Indices" in logger.warning.call_args[0][0]
+
def test_calendar_unwraps_data_key(self, monkeypatch: Any) -> None:
self._patch_fetch(
monkeypatch,
@@ -337,6 +409,10 @@ class TestFinnhubSource:
"transactionDate",
"asc",
),
+ ("dividends", ["symbol", "date", "amount"], "date", "asc"),
+ ("peers", ["symbol", "peer"], None, None),
+ ("index_constituents", ["index_symbol", "symbol"], None, None),
+ ("economic_calendar", ["country", "event", "time"], "time", None),
]
)
def test_source_response_keys_and_partitioning(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub_source.py
index 30a896739c05..6627fd3ac3bb 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/finnhub/tests/test_finnhub_source.py
@@ -13,7 +13,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
def _config(**overrides: Any) -> FinnhubSourceConfig:
- base: dict[str, Any] = {"api_key": "key", "symbols": "AAPL", "exchange": "US"}
+ base: dict[str, Any] = {"api_key": "key", "symbols": "AAPL", "indices": "^GSPC", "exchange": "US"}
base.update(overrides)
return FinnhubSourceConfig.from_dict(base)
@@ -21,12 +21,13 @@ def _config(**overrides: Any) -> FinnhubSourceConfig:
class TestSourceConfig:
def test_fields(self) -> None:
fields = {f.name: f for f in FinnhubSource().get_source_config.fields if isinstance(f, SourceFieldInputConfig)}
- assert set(fields) == {"api_key", "symbols", "exchange"}
+ assert set(fields) == {"api_key", "symbols", "indices", "exchange"}
assert fields["api_key"].type == SourceFieldInputConfigType.PASSWORD
assert fields["api_key"].required is True
assert fields["api_key"].secret is True
# The fan-out and exchange fields must be optional so market-wide tables work alone.
assert fields["symbols"].required is False
+ assert fields["indices"].required is False
assert fields["exchange"].required is False
@@ -49,6 +50,10 @@ class TestGetSchemas:
"stock_candles",
"sec_filings",
"insider_transactions",
+ "dividends",
+ "peers",
+ "index_constituents",
+ "economic_calendar",
}
def test_incremental_endpoints_advertise_their_cursor(self) -> None:
@@ -61,6 +66,7 @@ class TestGetSchemas:
"stock_candles": "t",
"sec_filings": "filedDate",
"insider_transactions": "transactionDate",
+ "dividends": "date",
}
@parameterized.expand(
@@ -80,6 +86,10 @@ class TestGetSchemas:
("stock_candles", False),
("sec_filings", False),
("insider_transactions", False),
+ ("dividends", False),
+ ("peers", False),
+ ("index_constituents", False),
+ ("economic_calendar", False),
]
)
def test_should_sync_default(self, endpoint: str, expected_default: bool) -> None:
@@ -105,7 +115,7 @@ class TestDocumentedTables:
def test_lists_tables_without_credentials(self) -> None:
assert FinnhubSource.lists_tables_without_credentials is True
tables = FinnhubSource().get_documented_tables()
- assert len(tables) == 15
+ assert len(tables) == 19
class TestSourceForPipeline:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/finnhub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/finnhub.py
index 2e770a64369d..3eb1101df6b3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/finnhub.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/finnhub.py
@@ -8,4 +8,5 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp
class FinnhubSourceConfig(config.Config):
api_key: str
symbols: str | None = None
+ indices: str | None = None
exchange: str | None = None