StorageLiveAdapter

Implements IStorageUtils

Live trading storage adapter with pluggable storage backend.

Features:

  • Adapter pattern for swappable storage implementations
  • Default adapter: StoragePersistLiveUtils (persistent storage)
  • Alternative adapters: StorageMemoryLiveUtils, StorageDummyLiveUtils
  • Convenience methods: usePersist(), useMemory(), useDummy()
constructor();
_signalLiveFactory: any

Factory producing the active storage utils instance

getInstance: any

Lazily constructs the storage utils from the registered factory and memoizes the result via singleshot.

The instance is built on the first call and cached for all subsequent calls. Reset via clear() so the next call rebuilds from the current factory.

handleOpened: (tick: IStrategyTickResultOpened) => Promise<void>

Handles signal opened event. Proxies call to the underlying storage adapter.

handleClosed: (tick: IStrategyTickResultClosed) => Promise<void>

Handles signal closed event. Proxies call to the underlying storage adapter.

handleScheduled: (tick: IStrategyTickResultScheduled) => Promise<void>

Handles signal scheduled event. Proxies call to the underlying storage adapter.

handleCancelled: (tick: IStrategyTickResultCancelled) => Promise<void>

Handles signal cancelled event. Proxies call to the underlying storage adapter.

findById: (id: string) => Promise<IStorageSignalRow>

Finds a signal by its ID. Proxies call to the underlying storage adapter.

list: () => Promise<IStorageSignalRow[]>

Lists all stored signals. Proxies call to the underlying storage adapter.

handleActivePing: (event: ActivePingContract) => Promise<void>

Handles active ping event for opened signals. Updates updatedAt for the signal if it is currently opened.

handleSchedulePing: (event: SchedulePingContract) => Promise<void>

Handles schedule ping event for scheduled signals. Updates updatedAt for the signal if it is currently scheduled.

useStorageAdapter: (Ctor: TStorageUtilsCtor) => void

Sets the storage adapter constructor. All future storage operations will use this adapter.

useDummy: () => void

Switches to dummy storage adapter. All future storage writes will be no-ops.

usePersist: () => void

Switches to persistent storage adapter (default). Signals will be persisted to disk.

useMemory: () => void

Switches to in-memory storage adapter. Signals will be stored in memory only.

clear: () => void

Clears the memoized utils instance. Call this when process.cwd() changes between strategy iterations so a new instance is created with the updated base path.