trader.marketdata.index_provider module

Index membership, scraped from Wikipedia (issue #27).

Never raises past get_members: a scrape failure degrades to [], the same shape a discovery source degrades to when themes: []trader scan-universe still records whatever analyst_consensus_history already has, and discover_symbols’s analyst-scan candidate source simply has nothing new to check that cycle.

class trader.marketdata.index_provider.WikipediaIndexProvider(html_source=None)[source]

Bases: object

Index constituents scraped from Wikipedia. No bs4 type escapes.

Parameters:

html_source (Callable[[str], str] | None)

get_members(index_name)[source]

Cleaned, deduplicated symbols for index_name, or [] on failure.

Raises ValueError only for an unsupported index_name — a caller programming error, not a runtime condition to degrade from. Every other failure (network, markup change, an empty page) is caught and logged; trader scan-universe still has a table to record.

Parameters:

index_name (str)

Return type:

list[str]

trader.marketdata.index_provider.validate_symbol(raw)[source]

A cleaned ticker symbol, or None if raw is not one.

Wikipedia table scraping mixes years, footnote markers, and company names into the symbol column (a confirmed pattern, per docs/ideas.md’s “validate ticker symbols at the boundary” entry) — this is the one validator at the scrape boundary that rejects those, the same discipline listing_gate applies to a warrant suffix: logged, countable, never a crash reaching discover_symbols.

Parameters:

raw (str)

Return type:

str | None