Promise resolving to current state value, or initialValue if no signal
import { getSignalState } from "backtest-kit";
const { peakPercent, minutesOpen } = await getSignalState({
bucketName: "trade",
initialValue: { peakPercent: 0, minutesOpen: 0 },
});
if (minutesOpen >= 15 && peakPercent < 0.3) {
await commitMarketClose(symbol); // capitulate — LLM thesis not confirmed
}
Reads the state value scoped to the current active signal.
Resolves the active pending signal automatically from execution context. If no pending signal exists, logs a warning and returns the initialValue.
Automatically detects backtest/live mode from execution context.
Intended for LLM-driven capitulation strategies that accumulate per-trade metrics (e.g. peakPercent, minutesOpen) across onActivePing ticks. Profitable trades endure -0.5–2.5% drawdown and reach peak 2–3%+. SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25). Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.