PersistRecentUtils

Utility class for managing recent signal persistence.

Features:

  • Memoized storage instances per (symbol, strategyName, exchangeName, frameName) context
  • Custom adapter support
  • Atomic read/write operations
  • Crash-safe recent signal state management

Used by RecentPersistBacktestUtils/RecentPersistLiveUtils for recent signal persistence.

constructor();
PersistRecentInstanceCtor: any

Constructor used to create per-context recent signal instances. Replaceable via usePersistRecentAdapter() / useJson() / useDummy().

createKey: any

Builds the composite memoization key for a recent signal context. Includes optional frameName and the backtest/live mode flag.

getStorage: any

Memoized factory creating one IPersistRecentInstance per context tuple.

readRecentData: (symbol: string, strategyName: string, exchangeName: string, frameName: string, backtest: boolean) => Promise<IPublicSignalRow>

Reads the latest recent signal for the given context. Lazily initializes the instance on first access.

writeRecentData: (signalRow: IPublicSignalRow, symbol: string, strategyName: string, exchangeName: string, frameName: string, backtest: boolean, when: Date) => Promise<void>

Writes the latest recent signal for the given context. Lazily initializes the instance on first access.

usePersistRecentAdapter(Ctor: TPersistRecentInstanceCtor): void;

Registers a custom IPersistRecentInstance constructor. Clears the memoization cache so subsequent calls use the new adapter.

clear(): void;

Clears the memoized instance cache. Call when process.cwd() changes between strategy iterations.

useJson(): void;

Switches to the default file-based PersistRecentInstance.

useDummy(): void;

Switches to PersistRecentDummyInstance (all operations are no-ops).