Function addExchange

  • Registers an exchange data source in the framework.

    The exchange provides:

    • Historical candle data via getCandles
    • Price/quantity formatting for the exchange
    • VWAP calculation from last 5 1m candles

    Parameters

    • exchangeSchema: IExchangeSchema

      Exchange configuration object

      Exchange schema registered via addExchange(). Defines candle data source and formatting logic.

      • Optionalcallbacks?: Partial<IExchangeCallbacks>

        Optional lifecycle event callbacks (onCandleData)

      • exchangeName: string

        Unique exchange identifier for registration

      • formatPrice: (symbol: string, price: number) => Promise<string>

        Format price according to exchange precision rules.

      • formatQuantity: (symbol: string, quantity: number) => Promise<string>

        Format quantity according to exchange precision rules.

      • getCandles: (
            symbol: string,
            interval: CandleInterval,
            since: Date,
            limit: number,
        ) => Promise<ICandleData[]>

        Fetch candles from data source (API or database).

      • Optionalnote?: string

        Optional developer note for documentation

    Returns void

    addExchange({
    exchangeName: "binance",
    getCandles: async (symbol, interval, since, limit) => {
    // Fetch from Binance API or database
    return [{
    timestamp: Date.now(),
    open: 50000,
    high: 51000,
    low: 49000,
    close: 50500,
    volume: 1000,
    }];
    },
    formatPrice: async (symbol, price) => price.toFixed(2),
    formatQuantity: async (symbol, quantity) => quantity.toFixed(8),
    });