Function getPositionInvestedCost

  • Returns the total invested cost basis in dollars for the current pending signal.

    Equal to the sum of all _entry costs (Σ entry.cost). Each entry cost is set at the time of commitAverageBuy (defaults to CC_POSITION_ENTRY_COST).

    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 total invested cost in dollars or null

    import { getPositionInvestedCost } from "backtest-kit";

    const cost = await getPositionInvestedCost("BTCUSDT");
    // No DCA, default cost: cost === 100
    // After one DCA with default cost: cost === 200