@openpit/engine
    Preparing search index...

    Class Accounts

    Handle to the engine's account-group registry, currency configuration, and block controls.

    Obtained from Engine.accounts(). It shares the engine's single account control state, so changes made through it are visible to every other handle and to later policy calls. Calling it from a callback of the same engine throws LifecycleError.

    For an example of good practice in building a control plane on this SDK, see Pit Officer.

    Index
    • Returns void

    • Blocks account out of band with the operator-supplied reason.

      account accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid identifier.

      Parameters

      • account: string | number | bigint | AccountId
      • reason: string

      Returns void

    • Blocks every account in group with the operator-supplied reason.

      group accepts an AccountGroupId or a numeric/string identifier.

      Errors

      Throws AccountBlockError (err.kind === "ReservedGroup") when group is the reserved default group, or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Clears the currency configured for account.

      Effective currency resolves from the account, then its group, then AccountGroupId.DEFAULT().

      This write is unchecked and re-evaluates nothing. Stored PnL and cost basis accumulated under a different effective currency lose their meaning; the SDK guarantees nothing about them and does not convert, detect, or report the change. Barrier selection itself stays deterministic: the next policy access re-resolves the cascade with the new effective currency.

      account accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid account identifier.

      Parameters

      • account: string | number | bigint | AccountId

      Returns void

    • Clears the fallback currency configured for group.

      AccountGroupId.DEFAULT() selects the global fallback tier. This write is unchecked and re-evaluates nothing. Effective currency resolves from the account, then its group, then AccountGroupId.DEFAULT(). Stored PnL and cost basis accumulated under a different effective currency lose their meaning; the SDK guarantees nothing about them and does not convert, detect, or report the change. Barrier selection itself stays deterministic: the next policy access re-resolves the cascade with the new effective currency.

      group accepts an AccountGroupId or a numeric/string identifier.

      Errors

      Throws ParamError on an invalid group identifier.

      Parameters

      Returns void

    • Returns void

    • Returns the group of account, or undefined when it is unregistered.

      account accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid identifier.

      Parameters

      • account: string | number | bigint | AccountId

      Returns AccountGroupId | undefined

    • Atomically registers every account in accounts into group.

      accounts is an iterable of AccountId or numeric/string identifiers; group accepts an AccountGroupId or a numeric/string identifier. If joining changes effective currency, stored PnL and cost basis accumulated under the previous one lose their meaning; the SDK guarantees nothing about them. If membership changes the effective PnL barrier, this call checks current account PnL, treating an unset ledger as zero and halted state as a breach, and latches any resulting account block before returning. An unchanged effective barrier is not checked again.

      Errors

      Throws AccountGroupRegistrationError on a conflict, or ParamError/AccountIdError on a bad input.

      Parameters

      Returns void

    • Replaces the stored reason for an already-blocked account.

      account accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountBlockError (err.kind === "AccountNotBlocked") when account is not currently blocked, or AccountIdError on an invalid identifier.

      Parameters

      • account: string | number | bigint | AccountId
      • reason: string

      Returns void

    • Replaces the stored reason for an already-blocked group.

      group accepts an AccountGroupId or a numeric/string identifier.

      Errors

      Throws AccountBlockError when group is the reserved default group (err.kind === "ReservedGroup") or is not currently blocked (err.kind === "GroupNotBlocked"), or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Sets the currency used by account-aware policies for account.

      Effective currency resolves from the account, then its group, then AccountGroupId.DEFAULT().

      This write is unchecked and re-evaluates nothing. Stored PnL and cost basis accumulated under a different effective currency lose their meaning; the SDK guarantees nothing about them and does not convert, detect, or report the change. Barrier selection itself stays deterministic: the next policy access re-resolves the cascade with the new effective currency.

      account accepts an AccountId or a numeric/string identifier. asset must be a valid asset identifier.

      Errors

      Throws AccountIdError on an invalid account identifier or AssetError on an invalid asset identifier.

      Parameters

      • account: string | number | bigint | AccountId
      • asset: string

      Returns void

    • Sets the fallback currency used by account-aware policies for group.

      AccountGroupId.DEFAULT() selects the global fallback tier. This write is unchecked and re-evaluates nothing. Effective currency resolves from the account, then its group, then AccountGroupId.DEFAULT(). Stored PnL and cost basis accumulated under a different effective currency lose their meaning; the SDK guarantees nothing about them and does not convert, detect, or report the change. Barrier selection itself stays deterministic: the next policy access re-resolves the cascade with the new effective currency.

      group accepts an AccountGroupId or a numeric/string identifier. asset must be a valid asset identifier.

      Errors

      Throws ParamError on an invalid group identifier or AssetError on an invalid asset identifier.

      Parameters

      Returns void

    • Unblocks account, clearing any block on it.

      account accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid identifier.

      Parameters

      • account: string | number | bigint | AccountId

      Returns void

    • Clears the engine-wide block, letting every account trade again.

      An engine-wide block is never raised by an admin call. The engine raises it itself when a kill switch is reported for an execution report whose account cannot be read, and when a mutation finalizer fails for a mutation a custom policy registered - which every Mutation registered from JavaScript is - because the engine cannot bound how far that policy's state reaches. The reject the block produces carries "SystemUnavailable".

      Idempotent: a no-op when no engine-wide block is active. Accounts and groups blocked individually stay blocked; clear those with unblock() and unblockGroup().

      Errors

      Throws LifecycleError when the owning engine is re-entered synchronously from one of its policy callbacks.

      Returns void

    • Unblocks every account in group.

      group accepts an AccountGroupId or a numeric/string identifier.

      Errors

      Throws AccountBlockError (err.kind === "ReservedGroup") when group is the reserved default group, or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Atomically removes every account in accounts from group.

      accounts is an iterable of AccountId or numeric/string identifiers; group accepts an AccountGroupId or a numeric/string identifier. If leaving changes effective currency, stored PnL and cost basis accumulated under the previous one lose their meaning; the SDK guarantees nothing about them. If membership changes the effective PnL barrier, this call checks current account PnL, treating an unset ledger as zero and halted state as a breach, and latches any resulting account block before returning. An unchanged effective barrier is not checked again.

      Errors

      Throws AccountGroupRegistrationError on a conflict, or ParamError/AccountIdError on a bad input.

      Parameters

      Returns void