OptionalcallbacksOptional lifecycle event callbacks (onCandleData)
Unique exchange identifier for registration
OptionalformatFormat price according to exchange precision rules.
Optional. If not provided, defaults to Bitcoin precision on Binance (2 decimal places).
Trading pair symbol
Raw price value
Whether running in backtest mode
Promise resolving to formatted price string
OptionalformatFormat quantity according to exchange precision rules.
Optional. If not provided, defaults to Bitcoin precision on Binance (8 decimal places).
Trading pair symbol
Raw quantity value
Whether running in backtest mode
Promise resolving to formatted quantity string
OptionalgetFetch aggregated trades for a trading pair. Optional. If not provided, throws an error when called.
Trading pair symbol (e.g., "BTCUSDT")
Start of time range (used in backtest for historical data, can be ignored in live)
End of time range (used in backtest for historical data, can be ignored in live)
Whether running in backtest mode
Promise resolving to array of aggregated trade data
// Backtest implementation: returns historical aggregated trades for the time range
const backtestAggregatedTrades = async (symbol: string, from: Date, to: Date, backtest: boolean) => {
if (backtest) {
return await database.getAggregatedTrades(symbol, from, to);
}
return await exchange.fetchAggregatedTrades(symbol);
};
// Live implementation: ignores from/to when not in backtest mode
const liveAggregatedTrades = async (symbol: string, _from: Date, _to: Date, backtest: boolean) => {
return await exchange.fetchAggregatedTrades(symbol);
};
Fetch candles from data source (API or database).
Trading pair symbol (e.g., "BTCUSDT")
Candle time interval (e.g., "1m", "1h")
Start date for candle fetching
Maximum number of candles to fetch
Whether running in backtest mode
Promise resolving to array of OHLCV candle data
OptionalgetFetch order book for a trading pair.
Optional. If not provided, throws an error when called.
Trading pair symbol (e.g., "BTCUSDT")
Maximum depth levels for both bids and asks (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
Start of time range (used in backtest for historical data, can be ignored in live)
End of time range (used in backtest for historical data, can be ignored in live)
Whether running in backtest mode
Promise resolving to order book data
// Backtest implementation: returns historical order book for the time range
const backtestOrderBook = async (symbol: string, depth: number, from: Date, to: Date, backtest: boolean) => {
if (backtest) {
return await database.getOrderBookSnapshot(symbol, depth, from, to);
}
return await exchange.fetchOrderBook(symbol, depth);
};
// Live implementation: ignores from/to when not in backtest mode
const liveOrderBook = async (symbol: string, depth: number, _from: Date, _to: Date, backtest: boolean) => {
return await exchange.fetchOrderBook(symbol, depth);
};
OptionalnoteOptional developer note for documentation
Exchange schema registered via addExchange(). Defines candle data source and formatting logic.