Utility class for exchange operations.
Provides simplified access to exchange schema methods with validation. Exported as singleton instance for convenient usage.
constructor();
_getInstance: any
Memoized function to get or create ExchangeInstance for an exchange. Each exchange gets its own isolated instance.
getCandles: (symbol: string, interval: CandleInterval, limit: number, context: { exchangeName: string; }) => Promise<any>
Fetch candles from data source (API or database).
Automatically calculates the start date based on Date.now() and the requested interval/limit. Uses the same logic as ClientExchange to ensure backwards compatibility.
getAveragePrice: (symbol: string, context: { exchangeName: string; }) => Promise<number>
Calculates VWAP (Volume Weighted Average Price) from last N 1m candles.
formatQuantity: (symbol: string, quantity: number, context: { exchangeName: string; }) => Promise<string>
Format quantity according to exchange precision rules.
formatPrice: (symbol: string, price: number, context: { exchangeName: string; }) => Promise<string>
Format price according to exchange precision rules.
getOrderBook: (symbol: string, context: { exchangeName: string; }, depth?: number) => Promise<IOrderBookData>
Fetch order book for a trading pair.
Delegates to ExchangeInstance which calculates time range and passes it to the exchange schema implementation. The from/to parameters may be used (backtest) or ignored (live) depending on the implementation.
getAggregatedTrades: (symbol: string, context: { exchangeName: string; }, limit?: number) => Promise<IAggregatedTradeData[]>
Fetch aggregated trades for a trading pair.
getRawCandles: (symbol: string, interval: CandleInterval, context: { exchangeName: string; }, limit?: number, sDate?: number, eDate?: number) => Promise<ICandleData[]>
Fetches raw candles with flexible date/limit parameters.
Uses Date.now() instead of execution context when for look-ahead bias protection.