PersistStorageUtils

Utility class for managing signal storage persistence.

Features:

  • Memoized storage instances
  • Custom adapter support
  • Atomic read/write operations for StorageData
  • Each signal stored as separate file keyed by id
  • Crash-safe signal state management

Used by SignalLiveUtils for live mode persistence of signals.

constructor();
PersistStorageFactory: any
getStorageStorage: any
readStorageData: (backtest: boolean) => Promise<StorageData>

Reads persisted signals data.

Called by StorageLiveUtils/StorageBacktestUtils.waitForInit() to restore state. Uses keys() from PersistBase to iterate over all stored signals. Returns empty array if no signals exist.

writeStorageData: (signalData: StorageData, backtest: boolean) => Promise<void>

Writes signal data to disk with atomic file writes.

Called by StorageLiveUtils/StorageBacktestUtils after signal changes to persist state. Uses signal.id as the storage key for individual file storage. Uses atomic writes to prevent corruption on crashes.

usePersistStorageAdapter(Ctor: TPersistBaseCtor<string, IStorageSignalRow>): void;

Registers a custom persistence adapter.

useJson(): void;

Switches to the default JSON persist adapter. All future persistence writes will use JSON storage.

useDummy(): void;

Switches to a dummy persist adapter that discards all writes. All future persistence writes will be no-ops.