PersistRiskInstance

Implements IPersistRiskInstance

Default file-based implementation of IPersistRiskInstance.

Features:

  • Wraps PersistBase for atomic JSON writes
  • Uses fixed entity ID "positions" within a per-context PersistBase
  • Crash-safe via atomic writes
constructor(riskName: string, exchangeName: string);
riskName: string
exchangeName: string
STORAGE_KEY: any

Fixed entity key for storing the positions array

_storage: any

Underlying file-based storage scoped to this context

waitForInit(initial: boolean): Promise<void>;

Initializes the underlying PersistBase storage.

readPositionData(_when: Date): Promise<RiskData>;

Reads the persisted positions array using the fixed STORAGE_KEY.

writePositionData(riskRow: RiskData, _when: Date): Promise<void>;

Writes the positions array using the fixed STORAGE_KEY.