Function getRawCandles

  • Fetches raw candles with flexible date/limit parameters.

    All modes respect execution context and prevent look-ahead bias.

    Parameter combinations:

    1. sDate + eDate + limit: fetches with explicit parameters, validates eDate <= when
    2. sDate + eDate: calculates limit from date range, validates eDate <= when
    3. eDate + limit: calculates sDate backward, validates eDate <= when
    4. sDate + limit: fetches forward, validates calculated endTimestamp <= when
    5. Only limit: uses execution.context.when as reference (backward)

    Parameters

    • symbol: string

      Trading pair symbol (e.g., "BTCUSDT")

    • interval: CandleInterval

      Candle interval ("1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h")

    • Optionallimit: number

      Optional number of candles to fetch

    • OptionalsDate: number

      Optional start date in milliseconds

    • OptionaleDate: number

      Optional end date in milliseconds

    Returns Promise<ICandleData[]>

    Promise resolving to array of candle data

    // Fetch 100 candles backward from current context time
    const candles = await getRawCandles("BTCUSDT", "1m", 100);

    // Fetch candles for specific date range
    const rangeCandles = await getRawCandles("BTCUSDT", "1h", undefined, startMs, endMs);

    // Fetch with all parameters specified
    const exactCandles = await getRawCandles("BTCUSDT", "1m", 100, startMs, endMs);