Position query functions are read-only utilities for inspecting the state of the currently open position without mutating it. They all operate within the current execution context (symbol, strategy, exchange, frame), automatically reading the correct backtest timestamp or live wall-clock time. Functions that depend on the current price — such as PNL queries — callDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
getAveragePrice internally, so no explicit price argument is needed. All functions return null when no pending or scheduled signal exists for the given symbol.
Signal Access
getPendingSignal
Returns the currently active pending signal for the strategy, ornull if no position is open.
Trading pair symbol (e.g.,
"BTCUSDT").IPublicSignalRow extends ISignalRow with originalPriceStopLoss, originalPriceTakeProfit, originalPriceOpen, partialExecuted, totalEntries, totalPartials, and real-time pnl, peakProfit, maxDrawdown snapshots.
getScheduledSignal
Returns the currently waiting scheduled signal (limit entry order), ornull.
Trading pair symbol.
hasNoPendingSignal
Returnstrue if no active pending signal exists. Inverse of an internal hasPendingSignal check. Use as a guard before opening a new position.
Trading pair symbol.
hasNoScheduledSignal
Returnstrue if no scheduled signal is waiting. Use as a guard before scheduling a new limit entry.
Trading pair symbol.
Price & PNL
getPositionEffectivePrice
Returns the cost-weighted harmonic mean of all DCA entry prices. With no DCA entries, equalspriceOpen. Returns null if no pending signal exists.
Trading pair symbol.
costBasisAtClose snapshots, then blended with any entries added after the last partial. This is the price used in all internal PNL calculations.
getPositionPnlPercent
Returns the current unrealized PNL as a percentage. Accounts for partial closes, DCA entries, slippage, and fees.Trading pair symbol.
getPositionPnlCost
Returns the current unrealized PNL in dollars:pnlPercentage / 100 × totalInvestedCost.
Trading pair symbol.
getPositionInvestedCost
Returns the total invested cost basis in dollars — the sum of all_entry.cost values.
Trading pair symbol.
getPositionInvestedCount
Returns the number of DCA entries.1 = original entry only; increments by 1 with each successful commitAverageBuy.
Trading pair symbol.
Timing
getPositionEstimateMinutes
Returns theminuteEstimatedTime set in the signal DTO — the maximum expected hold duration before time_expired.
Trading pair symbol.
getPositionCountdownMinutes
Returns the remaining minutes beforetime_expired, clamped to 0. Computes minuteEstimatedTime − elapsedMinutes.
Trading pair symbol.
getPositionActiveMinutes
Returns the number of minutes the position has been active sincependingAt.
Trading pair symbol.
getPositionWaitingMinutes
Returns the number of minutes the scheduled signal has been waiting for activation (sincescheduledAt).
Trading pair symbol.
Peak Profit & Max Drawdown
getPositionHighestProfitPrice
Returns the best price reached in the profit direction during this position’s life. For LONG: maximum VWAP seen above effective entry. For SHORT: minimum VWAP seen below effective entry.Trading pair symbol.
getPositionHighestProfitTimestamp
Returns the timestamp (milliseconds) when the best profit price was recorded during this position’s life.Trading pair symbol.
getPositionHighestPnlPercentage
Returns the PNL percentage at the moment the best profit price was recorded.Trading pair symbol.
getPositionHighestPnlCost
Returns the PNL cost (in quote currency) at the moment the best profit price was recorded during this position’s life.Trading pair symbol.
getPositionHighestProfitBreakeven
Returns whether breakeven was mathematically reachable at the highest profit price, using the same threshold formula asgetBreakeven. Returns null if no pending signal exists.
Trading pair symbol.
getPositionDrawdownMinutes
Returns the number of minutes elapsed since the highest profit price was recorded — measuring how long the position has been pulling back from its peak.Trading pair symbol.
getPositionHighestProfitMinutes
Alias forgetPositionDrawdownMinutes. Returns the number of minutes elapsed since the last profit peak.
Trading pair symbol.
getPositionMaxDrawdownMinutes
Returns the number of minutes elapsed since the worst loss price was recorded — how long ago the deepest drawdown occurred.Trading pair symbol.
getPositionMaxDrawdownPrice
Returns the price at the worst drawdown point. For LONG: minimum VWAP below effective entry. For SHORT: maximum VWAP above effective entry.Trading pair symbol.
getPositionMaxDrawdownTimestamp
Returns the timestamp (milliseconds) when the worst loss price was recorded during this position’s life.Trading pair symbol.
getPositionMaxDrawdownPnlPercentage
Returns the PNL percentage at the worst price seen during this position’s life (deepest drawdown from entry).Trading pair symbol.
getPositionMaxDrawdownPnlCost
Returns the PNL cost (in quote currency) at the worst price seen during this position’s life.Trading pair symbol.
getPositionHighestProfitDistancePnlPercentage
Returns the distance in PNL percentage between the current price and the highest profit peak. Computed asmax(0, peakPnlPercentage − currentPnlPercentage).
Trading pair symbol.
getPositionHighestProfitDistancePnlCost
Returns the distance in PNL cost between the current price and the highest profit peak. Computed asmax(0, peakPnlCost − currentPnlCost).
Trading pair symbol.
getPositionHighestMaxDrawdownPnlPercentage
Returns the recovery distance in PNL percentage between the current price and the worst drawdown trough. Computed asmax(0, currentPnlPercentage − fallPnlPercentage).
Trading pair symbol.
getPositionHighestMaxDrawdownPnlCost
Returns the recovery distance in PNL cost between the current price and the worst drawdown trough. Computed asmax(0, currentPnlCost − fallPnlCost).
Trading pair symbol.
getMaxDrawdownDistancePnlPercentage
Returns the peak-to-trough PNL percentage distance between the position’s highest profit and deepest drawdown. Computed asmax(0, peakPnlPercentage − fallPnlPercentage).
Trading pair symbol.
getMaxDrawdownDistancePnlCost
Returns the peak-to-trough PNL cost distance between the position’s highest profit and deepest drawdown. Computed asmax(0, peakPnlCost − fallPnlCost).
Trading pair symbol.
DCA & Partial History
getPositionLevels
Returns the list of DCA entry prices for the current pending signal. The first element is always the originalpriceOpen; each subsequent element is a price added by commitAverageBuy. Returns null if no pending signal exists.
Trading pair symbol.
getPositionPartials
Returns the history of partial close events for the current pending signal. Each record includestype ("profit" or "loss"), percent, currentPrice, costBasisAtClose, entryCountAtClose, and timestamp. Returns null if no pending signal exists; returns an empty array if no partials have been executed.
Trading pair symbol.
getPositionEntries
Returns the list of DCA entry records (price and cost) for the current pending signal. The first element is the initial open; each subsequent element is added bycommitAverageBuy. Returns null if no pending signal exists.
Trading pair symbol.
Entry Overlap Guards
getPositionEntryOverlap
Returnstrue if currentPrice falls within the tolerance zone of any existing DCA entry level. Use this to prevent duplicate DCA entries at the same price area.
Trading pair symbol.
Price to check against existing DCA levels.
Tolerance zone config with
upperPercent and lowerPercent (0–100 format). Default: 1.5% both sides.false if no pending signal exists.
getPositionPartialOverlap
Returnstrue if currentPrice falls within the tolerance zone of any existing partial close price. Use this to prevent duplicate partial closes at the same price area.
Trading pair symbol.
Price to check against existing partial close prices.
Tolerance zone config. Default:
1.5% both sides.false if no pending signal exists or no partials have been executed yet.
getBreakeven
Returnstrue if the current price has moved far enough in the profit direction to cover transaction costs. Uses the formula (CC_PERCENT_SLIPPAGE + CC_PERCENT_FEE) * 2.
Trading pair symbol.
Current market price to check against the breakeven threshold.
Totals
getTotalPercentClosed
Returns the total percentage of the position already closed via partial closes (0–100).0 means nothing has been closed; 100 means fully exited via partials.
Trading pair symbol.
getTotalCostClosed
Returns the cost basis in dollars currently held (not yet closed by partials). EqualstotalInvestedCost when no partials have been executed; decreases with each partial close and increases with each commitAverageBuy.
Trading pair symbol.