Appearance
PriceFetchManager
Centralizes all PriceCollector and PriceAlert interactions for fetching price data.
Purpose
PriceFetchManager abstracts away the details of fetching price data from the price infrastructure (PriceAlert read replica and PriceCollector). It provides range queries, single-timestamp lookups, and hour-scoped convenience methods.
The manager returns the authoritative finalizedUpTo value from PriceCollector alongside price data, allowing the parent DO to determine whether missing timestamps represent permanent gaps (finalized) or data that hasn't arrived yet. This replaces the previous time-based heuristic with PriceCollector's backfill cursor — the single source of truth for finalization.
All methods are stateless and handle errors gracefully by logging and returning empty results rather than throwing.
Edge Cases & Error Handling
- All fetch methods catch errors, log them, and return empty results (never throw)
getPriceAtTimestampreturnsnullfor unavailable data, allowing callers to retry- Empty price records (
size === 0) are filtered out of range query results fetchPriceRangereturns empty map andfinalizedUpTo: 0ifstartTime > endTimeor on error
See Also
- ExtremesTrackingManager -- primary consumer of fetched prices
- AccountValueTrackingManager -- uses single-timestamp fetch for subscribe/reset
- AccountValueAggregationTracker -- parent DO