PersistPartialUtils

Utility class for managing partial profit/loss levels persistence.

Features:

  • Memoized storage instances per symbol:strategyName
  • Custom adapter support
  • Atomic read/write operations for partial data
  • Crash-safe partial state management

Used by ClientPartial for live mode persistence of profit/loss levels.

constructor();
PersistPartialFactory: any
getPartialStorage: any
readPartialData: (symbol: string, strategyName: string, signalId: string, exchangeName: string) => Promise<PartialData>

Reads persisted partial data for a symbol and strategy.

Called by ClientPartial.waitForInit() to restore state. Returns empty object if no partial data exists.

writePartialData: (partialData: PartialData, symbol: string, strategyName: string, signalId: string, exchangeName: string) => Promise<void>

Writes partial data to disk with atomic file writes.

Called by ClientPartial after profit/loss level changes to persist state. Uses atomic writes to prevent corruption on crashes.

usePersistPartialAdapter(Ctor: TPersistBaseCtor<string, PartialData>): 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.