OpenPitSyncPolicyRuntime 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)
OpenPitEngineBuilderOpaque builder pointer used to assemble an engine instance.
Ownership:
openpit_create_engine_builder;openpit_destroy_engine_builder;openpit_engine_builder_build.typedef struct OpenPitEngineBuilder OpenPitEngineBuilder;
OpenPitEngineOpaque engine pointer.
The engine stores policies and mutable risk state. The caller owns the pointer
until openpit_destroy_engine.
typedef struct OpenPitEngine OpenPitEngine;
OpenPitPretradePreTradeRequestOpaque 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;
OpenPitPretradePreTradeReservationOpaque 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;
OpenPitPretradePreTradeLockPrice-lock snapshot returned from a reservation.
typedef struct OpenPitPretradePreTradeLock {
OpenPitParamPriceOptional price;
} OpenPitPretradePreTradeLock;
OpenPitPretradeStatusResult 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)
OpenPitAccountAdjustmentBatchErrorBatch rejection details returned by account-adjustment apply API.
Ownership:
openpit_engine_apply_account_adjustment on Rejected;openpit_destroy_account_adjustment_batch_error.typedef struct OpenPitAccountAdjustmentBatchError
OpenPitAccountAdjustmentBatchError;
openpit_create_engine_builderCreates a new engine builder with the chosen synchronization policy.
Success:
Error:
sync_policy is not one of OpenPitSyncPolicy_Full (0),
OpenPitSyncPolicy_Local (1), or OpenPitSyncPolicy_Account (2);out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.Cleanup:
openpit_destroy_engine_builder if you stop before
building;openpit_destroy_engine_builder.OpenPitEngineBuilder * openpit_create_engine_builder(
uint8_t sync_policy,
OpenPitOutError out_error
);
openpit_destroy_engine_builderReleases a builder pointer owned by the caller.
Contract:
void openpit_destroy_engine_builder(
OpenPitEngineBuilder * builder
);
openpit_engine_builder_buildFinalizes a builder and creates an engine.
Success:
Error:
builder is null, the builder was already consumed, or
configuration is invalid;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.Ownership:
openpit_destroy_engine;OpenPitEngine * openpit_engine_builder_build(
OpenPitEngineBuilder * builder,
OpenPitOutError out_error
);
openpit_destroy_engineReleases an engine pointer owned by the caller.
Contract:
void openpit_destroy_engine(
OpenPitEngine * engine
);
openpit_engine_start_pre_tradeStarts pre-trade processing and returns a deferred request pointer.
This stage validates whether the order can enter the full pre-trade flow.
Success:
Passed when the order passed this stage; read out_request;Rejected when the order was rejected; read out_rejects if not
null.Error:
Error when input pointers are invalid or the order payload cannot
be decoded;Error, if out_error is not null, it is filled with a caller-owned
OpenPitSharedString that MUST be destroyed by the caller.Cleanup:
openpit_pretrade_pre_trade_request_execute or
openpit_destroy_pretrade_pre_trade_request.Reject ownership contract:
Rejected, a non-null OpenPitRejectList pointer is written to
out_rejects if it is not null;openpit_destroy_reject_list; failing to do so leaks the heap allocation
made inside this call;Passed and Error, null is written to out_rejects, and the caller
must not call destroy in those cases.Order lifetime contract:
order is read as a borrowed view during this call;OpenPitPretradeStatus openpit_engine_start_pre_trade(
OpenPitEngine * engine,
const OpenPitOrder * order,
OpenPitPretradePreTradeRequest ** out_request,
OpenPitRejectList ** out_rejects,
OpenPitOutError out_error
);
openpit_engine_execute_pre_tradeRuns the complete pre-trade check in one call.
Success:
Passed when the order passed this stage; read out_reservation;Rejected when the order was rejected is not null; read
out_rejects.Error:
Error when input pointers are invalid or the order payload cannot
be decoded;Error, if out_error is not null, it is filled with a caller-owned
OpenPitSharedString that MUST be destroyed by the caller.Cleanup:
openpit_pretrade_pre_trade_reservation_commit,
openpit_pretrade_pre_trade_reservation_rollback, or
openpit_destroy_pretrade_pre_trade_reservation.Reject ownership contract:
Rejected, a non-null OpenPitRejectList pointer is written to
out_rejects if it is not null;openpit_destroy_reject_list; failing to do so leaks the heap allocation
made inside this call;Passed and Error, null is written to out_rejects, and the caller
must not call destroy in those cases.Order lifetime contract:
order is read as a borrowed view during this call only;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_executeExecutes a deferred request returned by openpit_engine_start_pre_trade.
Success:
Passed when the order passed this stage; read out_reservation;Rejected when the order was rejected and out_rejects is not
null; read out_rejects.Error:
Error when input pointers are invalid or the order payload cannot
be decoded;Error, if out_error is not null, it is filled with a caller-owned
OpenPitSharedString that MUST be destroyed by the caller.Ownership:
openpit_destroy_pretrade_pre_trade_request, but it cannot be
executed again.Reject ownership contract:
Rejected, a non-null OpenPitRejectList pointer is written to
out_rejects if it is not null;openpit_destroy_reject_list; failing to do so leaks the heap allocation
made inside this call;Passed and Error, null is written to out_rejects, and the caller
must not call destroy in those cases.OpenPitPretradeStatus openpit_pretrade_pre_trade_request_execute(
OpenPitPretradePreTradeRequest * request,
OpenPitPretradePreTradeReservation ** out_reservation,
OpenPitRejectList ** out_rejects,
OpenPitOutError out_error
);
openpit_destroy_pretrade_pre_trade_requestReleases a deferred request pointer owned by the caller.
Contract:
void openpit_destroy_pretrade_pre_trade_request(
OpenPitPretradePreTradeRequest * request
);
openpit_pretrade_pre_trade_reservation_commitFinalizes 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_rollbackCancels 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_lockReturns a snapshot of the lock attached to a reservation.
Contract:
reservation must be a valid non-null pointer;Lifetime contract:
OpenPitPretradePreTradeLock openpit_pretrade_pre_trade_reservation_get_lock(
const OpenPitPretradePreTradeReservation * reservation
);
openpit_destroy_pretrade_pre_trade_reservationReleases a reservation pointer owned by the caller.
Contract:
void openpit_destroy_pretrade_pre_trade_reservation(
OpenPitPretradePreTradeReservation * reservation
);
OpenPitEngineApplyExecutionReportResultResult of openpit_engine_apply_execution_report.
typedef struct OpenPitEngineApplyExecutionReportResult {
OpenPitPretradePostTradeResult post_trade_result;
bool is_error;
} OpenPitEngineApplyExecutionReportResult;
openpit_engine_apply_execution_reportApplies an execution report to engine state.
Success:
OpenPitEngineApplyExecutionReportResult { is_error = false, ... }.Error:
OpenPitEngineApplyExecutionReportResult { is_error = true, post_trade_result = { kill_switch_triggered = false } } when input pointers
are invalid or the report payload cannot be decoded;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string;is_error is true, do not trust any other fields beyond the fact
that the call failed.Lifetime contract:
report is read as a borrowed view during this call only;OpenPitEngineApplyExecutionReportResult openpit_engine_apply_execution_report(
OpenPitEngine * engine,
const OpenPitExecutionReport * report,
OpenPitOutError out_error
);
openpit_destroy_account_adjustment_batch_errorReleases 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_indexReturns the failing adjustment index from a batch error.
Contract:
batch_error must be a valid non-null pointer;size_t openpit_account_adjustment_batch_error_get_failed_adjustment_index(
const OpenPitAccountAdjustmentBatchError * batch_error
);
openpit_account_adjustment_batch_error_get_rejectsReturns a non-owning reject-list view from a batch error.
Contract:
batch_error must be a valid non-null pointer;batch_error is alive;const OpenPitRejectList * openpit_account_adjustment_batch_error_get_rejects(
const OpenPitAccountAdjustmentBatchError * batch_error
);
openpit_engine_apply_account_adjustmentApplies a batch of account adjustments to one account.
Success:
OpenPitAccountAdjustmentApplyStatus::Applied when the batch was
accepted and applied;OpenPitAccountAdjustmentApplyStatus::Rejected when the call itself
completed normally but a policy rejected the batch; read out_reject.Error:
OpenPitAccountAdjustmentApplyStatus::Error when input pointers are
invalid or some adjustment payload cannot be decoded;Error, if out_error is not null, it is filled with a caller-owned
OpenPitSharedString that MUST be destroyed by the caller.Result handling:
Applied means there is no reject object to clean up;Rejected stores batch error details in out_reject, the caller must
release a returned object with
openpit_destroy_account_adjustment_batch_error;openpit_account_adjustment_batch_error_get_rejects
contain string views borrowed from the batch error and must not be used
after the batch error is destroyed;Error is returned, do not use any pointer from a previous unrelated
call as if it belonged to this failure.Lifetime contract:
adjustment entry from the contiguous input array is read as a
borrowed view during this call only;openpit_destroy_account_adjustment_batch_error.OpenPitAccountAdjustmentApplyStatus openpit_engine_apply_account_adjustment(
OpenPitEngine * engine,
OpenPitParamAccountId account_id,
const OpenPitAccountAdjustment * adjustments,
size_t adjustments_len,
OpenPitAccountAdjustmentBatchError ** out_reject,
OpenPitOutError out_error
);