Skip to main content

Description

Retrieves real-time market prices for specified cryptocurrency symbols. Used to calculate unrealized P&L, display current market values, and update position valuations in real-time.

Input Schema

string[]
Array of cryptocurrency trading pair symbols to fetch prices for (e.g., ["BTC-USD", "ETH-USD", "SOL-USD"]). If omitted or empty, returns prices for all available symbols.

TypeScript Type

Output Schema

CryptoPrice[]
Array of cryptocurrency price objects.

TypeScript Type

Example Usage

Basic Query

Real-time Price Ticker

Calculate Position Values

Price Alert System

Fetch All Prices

Implementation Notes

  • Normalization: Input symbols are normalized using parseSymbols() before fetching (handles various formats).
  • Error Handling: Returns empty array (prices: []) on fetch failure instead of throwing an error.
  • Data Source: Prices are fetched from @/server/features/trading/queries.server.fetchCryptoPrices().
  • Caching: Recommended to use short staleTime (1-5 seconds) for near real-time updates.