Function getPositionPartialOverlap

  • Checks whether the current price falls within the tolerance zone of any existing partial close price. Use this to prevent duplicate partial closes at the same price area.

    Returns true if currentPrice is within [partial.currentPrice - lowerStep, partial.currentPrice + upperStep] for any partial, where step = partial.currentPrice * percent / 100. Returns false if no pending signal exists or no partials have been executed yet.

    Parameters

    • symbol: string

      Trading pair symbol

    • currentPrice: number

      Price to check against existing partial close prices

    • 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 partial price (partial not recommended)

    import { getPositionPartialOverlap } from "backtest-kit";

    // Partials at [45000], check if 45100 is too close
    const overlap = await getPositionPartialOverlap("BTCUSDT", 45100, { upperPercent: 1.5, lowerPercent: 1.5 });
    // overlap = true (45100 is within 1.5% of 45000)
    if (!overlap) {
    await commitPartialProfit("BTCUSDT", 50);
    }