kuhl_haus.mdp.data package¶
Data models for market data analysis pipeline results and cache structures.
Provides dataclasses used across the MDP system for passing analyzed market data between components (analyzers, cache, publishers). No business logic; pure data containers with optional serialization helpers.
Submodules¶
kuhl_haus.mdp.data.market_data_analyzer_result module¶
Result envelope for market data analyzer output with caching and publishing metadata.
Carries analyzed data from analyzer components to downstream consumers (cache, Redis pub/sub). Supports optional Redis caching with TTL and optional publication to specific channels.
- class kuhl_haus.mdp.data.market_data_analyzer_result.MarketDataAnalyzerResult(data: Any, cache_key: str | None = None, cache_ttl: int | None = 0, publish_key: str | None = None, cache_list_max: int | None = None)[source]¶
Bases:
objectContainer for analyzed market data with cache and publish routing metadata.
Returned by all analyzer implementations (MassiveDataAnalyzer, LeaderboardAnalyzer, TopTradesAnalyzer). The data field contains the analysis result (leaderboard dict, trade list, etc.). Cache fields control Redis persistence; publish_key routes to specific Redis pub/sub channels for real-time distribution to WebSocket consumers.
Intentionally minimal: no validation or transformation logic. Pure data transfer.
- Variables:
data – The analyzed market data or result content.
cache_key – Optional key used to cache the analysis result.
cache_ttl – Time-to-live (in seconds) for caching the result. Defaults to 0.
publish_key – Optional key for publishing or disseminating the analysis result.
kuhl_haus.mdp.data.top_stocks_cache_item module¶
In-memory cache for intraday stock leaderboards computed from Massive.com WebSocket streams.
Maintains running aggregates and ranked maps for top volume, gappers, and gainers. Updated continuously as aggregate minute bars arrive from ws_stocks_am channel. Designed for high-frequency reads by WebSocket consumers (widget clients).
- class kuhl_haus.mdp.data.top_stocks_cache_item.TopStocksCacheItem(day_start_time: float | None = 0.0, symbol_data_cache: Dict[str, dict] | None=<factory>, top_volume_map: Dict[str, float] | None=<factory>, top_gappers_map: Dict[str, float] | None=<factory>, top_gainers_map: Dict[str, float] | None=<factory>)[source]¶
Bases:
objectSnapshot container for intraday stock rankings and per-symbol aggregate data.
Holds denormalized symbol data alongside three sorted ranking maps (volume, gappers, gainers). The ranking maps store only the metric value; full symbol details are retrieved from symbol_data_cache on demand. Self-healing: removes stale entries if cache inconsistency is detected during query methods.
Data sourced from Massive.com ws_stocks_am WebSocket aggregates.
- top_volume(limit)[source]¶
Return top N stocks by cumulative volume with full aggregate data.
Queries top_volume_map for ranked tickers, then hydrates each with denormalized symbol data from symbol_data_cache. Self-healing: if a ticker is missing from cache (orphaned map entry), it is silently removed from top_volume_map.
Called by WebSocket consumers; expect 10-50 calls/sec during market hours.
- top_gappers(limit)[source]¶
Return top N stocks by pre-market gap percentage with full aggregate data.
Filters for positive gaps only (pct_change > 0). Stops iteration early once non-positive gap is encountered (ranking is descending). Self-healing: removes orphaned map entries on KeyError.
Called by WebSocket consumers; expect 10-50 calls/sec during market hours.
- top_gainers(limit)[source]¶
Return top N stocks by intraday gain percentage with full aggregate data.
Filters for positive gains only (pct_change_since_open > 0). Stops iteration early once non-positive gain is encountered. Self-healing: removes orphaned map entries on KeyError.
Called by WebSocket consumers; expect 10-50 calls/sec during market hours.