Function getPositionEntryOverlap

  • Checks whether the current price falls within the tolerance zone of any existing DCA entry level. Use this to prevent duplicate DCA entries at the same price area.

    Returns true if currentPrice is within [level - lowerStep, level + upperStep] for any level, where step = level * percent / 100. Returns false if no pending signal exists.

    Parameters

    • symbol: string

      Trading pair symbol

    • currentPrice: number

      Price to check against existing DCA levels

    • Optionalladder: IPositionOverlapLadder

      Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)

    Returns Promise<boolean>

    Promise - true if price overlaps an existing entry level (DCA not recommended)

    import { getPositionEntryOverlap } from "backtest-kit";

    // LONG with levels [43000, 42000], check if 42100 is too close to 42000
    const overlap = await getPositionEntryOverlap("BTCUSDT", 42100, { upperPercent: 5, lowerPercent: 5 });
    // overlap = true (42100 is within 5% of 42000 = [39900, 44100])
    if (!overlap) {
    await commitAverageBuy("BTCUSDT");
    }