pit

Engine

Back to index

OpenPitSyncPolicy

Runtime selector for the engine’s storage synchronization policy.

typedef uint8_t OpenPitSyncPolicy;
/**
 * Concurrent invocation of public methods on the same handle is safe.
 * Sequential cross-thread access is also safe. Use this when the engine is
 * shared across threads.
 */
#define OpenPitSyncPolicy_Full ((OpenPitSyncPolicy) 0)
/**
 * The handle stays on the OS thread that created it. Use this for
 * single-threaded embeddings where synchronization overhead must be zero.
 */
#define OpenPitSyncPolicy_Local ((OpenPitSyncPolicy) 1)
/**
 * Sequential cross-thread access on the same handle is safe; the caller pins
 * each account to a single processing chain (one queue or one worker at a
 * time). Concurrent invocation on the same handle is not supported in this
 * mode.
 */
#define OpenPitSyncPolicy_Account ((OpenPitSyncPolicy) 2)

OpenPitEngineBuilder

Opaque builder pointer used to assemble an engine instance.

Ownership:

typedef struct OpenPitEngineBuilder OpenPitEngineBuilder;

OpenPitEngine

Opaque engine pointer.

The engine stores policies and mutable risk state. The caller owns the pointer until openpit_destroy_engine.

typedef struct OpenPitEngine OpenPitEngine;

OpenPitPretradePreTradeRequest

Opaque pointer for a deferred pre-trade request.

This is returned by openpit_engine_start_pre_trade. It can be executed once with openpit_pretrade_pre_trade_request_execute or discarded with openpit_destroy_pretrade_pre_trade_request.

typedef struct OpenPitPretradePreTradeRequest OpenPitPretradePreTradeRequest;

OpenPitPretradePreTradeReservation

Opaque reservation pointer returned by a successful pre-trade check.

A reservation represents resources that have been tentatively locked. The caller must resolve it exactly once by calling openpit_pretrade_pre_trade_reservation_commit, openpit_pretrade_pre_trade_reservation_rollback, or openpit_destroy_pretrade_pre_trade_reservation.

typedef struct OpenPitPretradePreTradeReservation
    OpenPitPretradePreTradeReservation;

OpenPitPretradePreTradeLock

Price-lock snapshot returned from a reservation.

typedef struct OpenPitPretradePreTradeLock {
    OpenPitParamPriceOptional price;
} OpenPitPretradePreTradeLock;

OpenPitPretradeStatus

Result status for pre-trade operations.

typedef uint8_t OpenPitPretradeStatus;
/**
 * Order/request passed this stage; read the success out-pointer.
 */
#define OpenPitPretradeStatus_Passed ((OpenPitPretradeStatus) 0)
/**
 * Order/request was rejected; read the reject out-pointer.
 */
#define OpenPitPretradeStatus_Rejected ((OpenPitPretradeStatus) 1)
/**
 * Call failed due to invalid input; read the error out-pointer.
 */
#define OpenPitPretradeStatus_Error ((OpenPitPretradeStatus) 2)

OpenPitAccountAdjustmentBatchError

Batch rejection details returned by account-adjustment apply API.

Ownership:

typedef struct OpenPitAccountAdjustmentBatchError
    OpenPitAccountAdjustmentBatchError;

openpit_create_engine_builder

Creates a new engine builder with the chosen synchronization policy.

Success:

Error:

Cleanup:

OpenPitEngineBuilder * openpit_create_engine_builder(
    uint8_t sync_policy,
    OpenPitOutError out_error
);

openpit_destroy_engine_builder

Releases a builder pointer owned by the caller.

Contract:

void openpit_destroy_engine_builder(
    OpenPitEngineBuilder * builder
);

openpit_engine_builder_build

Finalizes a builder and creates an engine.

Success:

Error:

Ownership:

OpenPitEngine * openpit_engine_builder_build(
    OpenPitEngineBuilder * builder,
    OpenPitOutError out_error
);

openpit_destroy_engine

Releases an engine pointer owned by the caller.

Contract:

void openpit_destroy_engine(
    OpenPitEngine * engine
);

openpit_engine_start_pre_trade

Starts pre-trade processing and returns a deferred request pointer.

This stage validates whether the order can enter the full pre-trade flow.

Success:

Error:

Cleanup:

Reject ownership contract:

Order lifetime contract:

OpenPitPretradeStatus openpit_engine_start_pre_trade(
    OpenPitEngine * engine,
    const OpenPitOrder * order,
    OpenPitPretradePreTradeRequest ** out_request,
    OpenPitRejectList ** out_rejects,
    OpenPitOutError out_error
);

openpit_engine_execute_pre_trade

Runs the complete pre-trade check in one call.

Success:

Error:

Cleanup:

Reject ownership contract:

Order lifetime contract:

OpenPitPretradeStatus openpit_engine_execute_pre_trade(
    OpenPitEngine * engine,
    const OpenPitOrder * order,
    OpenPitPretradePreTradeReservation ** out_reservation,
    OpenPitRejectList ** out_rejects,
    OpenPitOutError out_error
);

openpit_pretrade_pre_trade_request_execute

Executes a deferred request returned by openpit_engine_start_pre_trade.

Success:

Error:

Ownership:

Reject ownership contract:

OpenPitPretradeStatus openpit_pretrade_pre_trade_request_execute(
    OpenPitPretradePreTradeRequest * request,
    OpenPitPretradePreTradeReservation ** out_reservation,
    OpenPitRejectList ** out_rejects,
    OpenPitOutError out_error
);

openpit_destroy_pretrade_pre_trade_request

Releases a deferred request pointer owned by the caller.

Contract:

void openpit_destroy_pretrade_pre_trade_request(
    OpenPitPretradePreTradeRequest * request
);

openpit_pretrade_pre_trade_reservation_commit

Finalizes a reservation and applies the reserved state permanently.

This call is idempotent at the pointer level: if the reservation was already consumed, nothing happens. Passing null is allowed.

Contract:

void openpit_pretrade_pre_trade_reservation_commit(
    OpenPitPretradePreTradeReservation * reservation
);

openpit_pretrade_pre_trade_reservation_rollback

Cancels a reservation and releases the reserved state.

This call is idempotent at the pointer level: if the reservation was already consumed, nothing happens. Passing null is allowed.

Contract:

void openpit_pretrade_pre_trade_reservation_rollback(
    OpenPitPretradePreTradeReservation * reservation
);

openpit_pretrade_pre_trade_reservation_get_lock

Returns a snapshot of the lock attached to a reservation.

Contract:

Lifetime contract:

OpenPitPretradePreTradeLock openpit_pretrade_pre_trade_reservation_get_lock(
    const OpenPitPretradePreTradeReservation * reservation
);

openpit_destroy_pretrade_pre_trade_reservation

Releases a reservation pointer owned by the caller.

Contract:

void openpit_destroy_pretrade_pre_trade_reservation(
    OpenPitPretradePreTradeReservation * reservation
);

OpenPitEngineApplyExecutionReportResult

Result of openpit_engine_apply_execution_report.

typedef struct OpenPitEngineApplyExecutionReportResult {
    OpenPitPretradePostTradeResult post_trade_result;
    bool is_error;
} OpenPitEngineApplyExecutionReportResult;

openpit_engine_apply_execution_report

Applies an execution report to engine state.

Success:

Error:

Lifetime contract:

OpenPitEngineApplyExecutionReportResult openpit_engine_apply_execution_report(
    OpenPitEngine * engine,
    const OpenPitExecutionReport * report,
    OpenPitOutError out_error
);

openpit_destroy_account_adjustment_batch_error

Releases a batch-error object returned by account-adjustment apply.

Contract:

void openpit_destroy_account_adjustment_batch_error(
    OpenPitAccountAdjustmentBatchError * batch_error
);

openpit_account_adjustment_batch_error_get_failed_adjustment_index

Returns the failing adjustment index from a batch error.

Contract:

size_t openpit_account_adjustment_batch_error_get_failed_adjustment_index(
    const OpenPitAccountAdjustmentBatchError * batch_error
);

openpit_account_adjustment_batch_error_get_rejects

Returns a non-owning reject-list view from a batch error.

Contract:

const OpenPitRejectList * openpit_account_adjustment_batch_error_get_rejects(
    const OpenPitAccountAdjustmentBatchError * batch_error
);

openpit_engine_apply_account_adjustment

Applies a batch of account adjustments to one account.

Success:

Error:

Result handling:

Lifetime contract:

OpenPitAccountAdjustmentApplyStatus openpit_engine_apply_account_adjustment(
    OpenPitEngine * engine,
    OpenPitParamAccountId account_id,
    const OpenPitAccountAdjustment * adjustments,
    size_t adjustments_len,
    OpenPitAccountAdjustmentBatchError ** out_reject,
    OpenPitOutError out_error
);