@openpit/engine
    Preparing search index...

    Class MarketDataService

    Thread-shareable live market-data service.

    Reads use get(instrumentId, accountId, accountInfo, resolution) and getOrErr(...). accountInfo is any object exposing an accountGroup getter returning an AccountGroupId or null; the group is read only when the read needs it.

    Every method touches shared service state, so every one of them throws InternalError once a module panic has poisoned the module instance.

    Index
    • Returns void

    • Removes every stored quote for instrumentId.

      instrumentId accepts an InstrumentId or a numeric/string identifier.

      Errors

      Throws ParamError on an invalid identifier.

      Parameters

      Returns void

    • Clears the TTL override for accountGroupId.

      accountGroupId accepts an AccountGroupId or a numeric/string identifier. Passing AccountGroupId.DEFAULT targets the service-level default-group ("everyone-else") bucket.

      Errors

      Throws ParamError on an invalid identifier.

      Parameters

      Returns void

    • Clears the TTL override for accountId.

      accountId accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid identifier.

      Parameters

      • account_id: string | number | bigint | AccountId

      Returns void

    • Clears the per-instrument, per-group TTL override.

      instrumentId/accountGroupId accept the wrapper or a numeric/string id. Passing AccountGroupId.DEFAULT targets the instrument-level default-group bucket.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Clears the per-instrument, per-account TTL override.

      instrumentId/accountId accept the wrapper or a numeric/string id.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError/AccountIdError on an invalid identifier.

      Parameters

      Returns void

    • Clears the per-instrument TTL override.

      instrumentId accepts an InstrumentId or a numeric/string identifier.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Returns void

    • Returns the latest quote for (instrumentId, accountId), or undefined.

      instrumentId/accountId accept the wrapper or a numeric/string id. accountInfo is any object exposing an accountGroup getter; the group is consulted only when the read needs it. resolution is a QuoteResolution or its wire string.

      Errors

      Throws ParamError/AccountIdError on an invalid identifier, resolution, or a consulted accountInfo shape. Unknown instruments, unavailable quotes, and expired quotes return undefined.

      Parameters

      • instrument_id: string | number | bigint | InstrumentId
      • account_id: string | number | bigint | AccountId
      • account_info: AccountInfo | null | undefined
      • resolution:
            | QuoteResolution
            | "ACCOUNT_ONLY"
            | "ACCOUNT_THEN_GROUP"
            | "ACCOUNT_THEN_GROUP_THEN_DEFAULT"

      Returns Quote | undefined

    • Returns the latest quote for (instrumentId, accountId), throwing when no usable quote exists.

      instrumentId/accountId accept the wrapper or a numeric/string id. accountInfo is any object exposing an accountGroup getter; resolution is a QuoteResolution or its wire string.

      Errors

      Throws UnknownInstrument when instrumentId is not registered, QuoteUnavailable when no quote is available, QuoteExpired with the selected stale quote when its TTL elapsed, and ParamError/ AccountIdError on an invalid identifier, resolution, or accountInfo shape.

      Parameters

      • instrument_id: string | number | bigint | InstrumentId
      • account_id: string | number | bigint | AccountId
      • account_info: AccountInfo | null | undefined
      • resolution:
            | QuoteResolution
            | "ACCOUNT_ONLY"
            | "ACCOUNT_THEN_GROUP"
            | "ACCOUNT_THEN_GROUP_THEN_DEFAULT"

      Returns Quote

    • Publishes one quote observation to the default bucket for instrumentId.

      instrumentId accepts an InstrumentId or a numeric/string identifier; quote accepts a Quote object or a plain QuoteInit literal. A field absent from quote is absent from the observation, not retained from an older quote. sourceAgeMs is the elapsed source age in milliseconds; negative and unrepresentable values are clamped to zero. Non-finite values are rejected.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError on an invalid identifier or quote literal, or RangeError when sourceAgeMs is non-finite.

      Parameters

      Returns void

    • Publishes one quote observation to instrument's default bucket, auto-registering it.

      instrument accepts an Instrument object or a plain InstrumentInit literal; quote accepts a Quote object or a plain QuoteInit literal. An absent quote field is not retained from an older quote. sourceAgeMs is the elapsed source age in milliseconds; negative and unrepresentable values are clamped to zero, while non-finite values are rejected. Returns the resolved (or newly assigned) instrument id.

      Errors

      Throws AssetError/ParamError on an invalid instrument or quote, or RangeError when sourceAgeMs is non-finite.

      Parameters

      Returns InstrumentId

    • Publishes one quote observation to the given accounts and groups.

      instrumentId accepts an InstrumentId or a numeric/string id; quote accepts a Quote object or a plain QuoteInit literal; the target iterables accept AccountId/AccountGroupId or numeric/string ids. To target the default ("everyone-else") bucket, include AccountGroupId.DEFAULT in accountGroupIds. An absent quote field is not retained from an older quote. sourceAgeMs is the elapsed source age in milliseconds; negative and unrepresentable values are clamped to zero, while non-finite values are rejected.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, RangeError when both target lists are empty or sourceAgeMs is non-finite, or ParamError/AccountIdError on an invalid input.

      Parameters

      Returns void

    • Registers instrument and returns its assigned id.

      instrument accepts an Instrument object or a plain InstrumentInit literal.

      Errors

      Throws AlreadyRegistered when the instrument is already registered, or AssetError/ParamError on an invalid literal.

      Parameters

      Returns InstrumentId

    • Registers instrument under an explicit id and returns it.

      instrument accepts an Instrument object or a plain InstrumentInit literal; id accepts an InstrumentId or a numeric/string identifier.

      Errors

      Throws RegistrationError when the id or instrument already exists, or AssetError/ParamError on an invalid input.

      Parameters

      Returns InstrumentId

    • Registers instrument under an explicit id with a TTL.

      instrument accepts an Instrument object or a plain InstrumentInit literal; id accepts an InstrumentId or a numeric/string identifier.

      Errors

      Throws RegistrationError when the id or instrument already exists, or AssetError/ParamError on an invalid input.

      Parameters

      Returns InstrumentId

    • Registers instrument with a per-instrument TTL and returns its id.

      instrument accepts an Instrument object or a plain InstrumentInit literal.

      Errors

      Throws AlreadyRegistered when the instrument is already registered, or AssetError/ParamError on an invalid literal.

      Parameters

      Returns InstrumentId

    • Returns the id instrument is registered under, or undefined.

      instrument accepts an Instrument object or a plain InstrumentInit literal.

      Errors

      Throws AssetError/ParamError on an invalid literal.

      Parameters

      Returns InstrumentId | undefined

    • Sets the TTL override for accountGroupId.

      accountGroupId accepts an AccountGroupId or a numeric/string identifier. Passing AccountGroupId.DEFAULT targets the service-level default-group ("everyone-else") bucket.

      Errors

      Throws ParamError on an invalid identifier.

      Parameters

      Returns void

    • Sets the TTL override for accountId.

      accountId accepts an AccountId or a numeric/string identifier.

      Errors

      Throws AccountIdError on an invalid identifier.

      Parameters

      Returns void

    • Sets the per-instrument, per-group TTL override.

      instrumentId/accountGroupId accept the wrapper or a numeric/string id. Passing AccountGroupId.DEFAULT targets the instrument-level default-group bucket.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError on an invalid identifier.

      Parameters

      Returns void

    • Sets the per-instrument, per-account TTL override.

      instrumentId/accountId accept the wrapper or a numeric/string id.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError/AccountIdError on an invalid identifier.

      Parameters

      Returns void

    • Sets the per-instrument TTL override.

      instrumentId accepts an InstrumentId or a numeric/string identifier.

      Errors

      Throws UnknownInstrumentId when instrumentId is not registered, or ParamError on an invalid identifier.

      Parameters

      Returns void