Returns the unrealized PNL in dollars for the current pending signal at current market price.
Calculated as: pnlPercentage / 100 × totalInvestedCost. Accounts for partial closes, DCA entries, slippage and fees.
Returns null if no pending signal exists.
Automatically detects backtest/live mode from execution context. Automatically fetches current price via getAveragePrice.
Trading pair symbol
Promise resolving to PNL in dollars or null
import { getPositionPnlCost } from "backtest-kit";const pnlCost = await getPositionPnlCost("BTCUSDT");// LONG at 100, invested $100, current=105: pnlCost ≈ 5// LONG at 100, invested $200 (DCA), current=95: pnlCost ≈ -10 Copy
import { getPositionPnlCost } from "backtest-kit";const pnlCost = await getPositionPnlCost("BTCUSDT");// LONG at 100, invested $100, current=105: pnlCost ≈ 5// LONG at 100, invested $200 (DCA), current=95: pnlCost ≈ -10
Returns the unrealized PNL in dollars for the current pending signal at current market price.
Calculated as: pnlPercentage / 100 × totalInvestedCost. Accounts for partial closes, DCA entries, slippage and fees.
Returns null if no pending signal exists.
Automatically detects backtest/live mode from execution context. Automatically fetches current price via getAveragePrice.