trader.persistence.index_membership module¶
Repository for index_membership (issue #27).
A set, not a history: trader scan-universe upserts on every scrape, and discover_symbols’s analyst-scan candidate source reads the current members of one named index.
- class trader.persistence.index_membership.IndexMembershipRepository(session_factory)[source]¶
Bases:
objectWrites and reads index_membership.
- Parameters:
session_factory (sessionmaker[Session])
- upsert(index_name, symbols, *, now)[source]¶
Record symbols as the current membership of index_name.
Existing members not in symbols are left as they were — this only ever adds. A departed constituent lingering in index_membership after the next scrape costs nothing: it still has to clear is_strong_buy_consensus and the full _evaluate chain like any other candidate, and asset_gate rejects it if it is no longer tradable.
- Parameters:
index_name (str)
symbols (Iterable[str])
now (datetime)
- Return type:
None