Class PersistPartialInstance

Default file-based implementation of IPersistPartialInstance.

Features:

  • Wraps PersistBase for atomic JSON writes
  • Uses signalId as entity ID within a per-context PersistBase
  • Crash-safe via atomic writes
const instance = new PersistPartialInstance("BTCUSDT", "my-strategy", "binance");
await instance.waitForInit(true);
await instance.writePartialData(partialData, "signal-id-1");
const restored = await instance.readPartialData("signal-id-1");

Implements

Constructors

  • Creates new partial data persistence instance.

    Parameters

    • symbol: string

      Trading pair symbol

    • strategyName: string

      Strategy identifier

    • exchangeName: string

      Exchange identifier

    Returns PersistPartialInstance

Properties

exchangeName: string
strategyName: string
symbol: string

Methods

  • Reads the partial data for the given signal using signalId as the entity key.

    Parameters

    • signalId: string

      Signal identifier

    • _when: Date

    Returns Promise<PartialData>

    Promise resolving to partial data record (empty object if not found)

  • Initializes the underlying PersistBase storage.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

    Promise that resolves when initialization is complete

  • Writes the partial data for the given signal using signalId as the entity key.

    Parameters

    • data: PartialData

      Partial data record to persist

    • signalId: string

      Signal identifier

    • _when: Date

    Returns Promise<void>

    Promise that resolves when write is complete