Skip to content

PriceFetchManager

Centralizes all price data fetching from PriceAlert DOs for order execution and portfolio queries.

Purpose

PriceFetchManager is the single point of contact for fetching price data from PriceAlert Durable Objects. It handles instance selection (load balancing across 10 instances), price arrival alert registration, and extracting price data from alert results.

The manager serves two distinct use cases: single-symbol fetches for order execution (which may register price arrival alerts and return pending status), and multi-symbol fetches for portfolio queries (read-only from the in-memory cache). It also provides a fetchRecentPrice method for validation-only use cases that do not register alerts.

Edge Cases & Error Handling

  • Permanent price fetch failures (TIMESTAMP_PAST, TIMESTAMP_FUTURE) return isPending: false with an error message, distinct from pending status
  • If price is already cached in PriceAlert, returns immediately without creating a pending order
  • Portfolio price fetches are best-effort: missing prices for individual symbols are silently omitted from the result map
  • AccountId is included in price arrival alert registration for stale alert rejection after account reset

See Also