Implements TStateAdapter
Live trading state adapter with pluggable storage backend.
Features:
Primary use case — LLM-driven capitulation rule:
Profitable trades endure -0.5–2.5% drawdown and still reach peak 2–3%+.
SL trades never go positive (Feb25) or show peak < 0.15% (Feb08, Feb13).
Rule: if position open >= N minutes and peakPercent < threshold (e.g. 0.3%),
the LLM thesis was not confirmed by market — exit immediately.
State persists { peakPercent, minutesOpen } per signal across process restarts.
constructor();
StateFactory: any
getInstance: any
disposeSignal: (signalId: string) => void
Disposes all memoized instances for the given signalId. Called by StateAdapter when a signal is cancelled or closed.
getState: <Value extends object = object>(dto: { signalId: string; bucketName: string; initialValue: object; }) => Promise<Value>
Read the current state value for a signal.
setState: <Value extends object = object>(dispatch: Value | Dispatch<Value>, dto: { signalId: string; bucketName: string; initialValue: object; }) => Promise<Value>
Update the state value for a signal.
useLocal: () => void
Switches to in-memory adapter. All data lives in process memory only.
usePersist: () => void
Switches to file-system backed adapter (default). Data is persisted to disk via PersistStateAdapter.
useDummy: () => void
Switches to dummy adapter that discards all writes.
useStateAdapter: (Ctor: TStateInstanceCtor) => void
Switches to a custom state adapter implementation.
clear: () => void
Clears the memoized instance cache. Call this when process.cwd() changes between strategy iterations so new instances are created with the updated base path.