Function getPositionEffectivePrice

  • Returns the effective (DCA-weighted) entry price for the current pending signal.

    Uses cost-weighted harmonic mean: Σcost / Σ(cost/price). When partial closes exist, the price is computed iteratively using costBasisAtClose snapshots from each partial, then blended with any DCA entries added after the last partial. With no DCA entries, equals the original priceOpen.

    Returns null if no pending signal exists.

    Automatically detects backtest/live mode from execution context.

    Parameters

    • symbol: string

      Trading pair symbol

    Returns Promise<number>

    Promise resolving to effective entry price or null

    import { getPositionEffectivePrice } from "backtest-kit";

    const avgPrice = await getPositionEffectivePrice("BTCUSDT");
    // No DCA: avgPrice === priceOpen
    // After DCA at lower price: avgPrice < priceOpen