Account Control
OpenPitAccountControl
Opaque handle to the per-account blocking facility bound to one account.
What it is:
- A caller-owned handle that records a block against a single, already-bound account on the engine's shared blocked-accounts facility.
Why it exists:
- It lets a policy callback both block the bound account immediately and retain the ability to block it later within the same pre-trade transaction, for example from a deferred commit or rollback callback that has no other channel to surface a block.
Lifetime contract:
- Every handle returned to the caller is owned by the caller and MUST be released with
openpit_destroy_account_controlexactly once. - A handle is valid to use ONLY within the pre-trade processing of the request it belongs to — from the callback that produced it through the commit or rollback of that request's reservation. Recording a block through it after that pre-trade transaction has completed is undefined behaviour.
typedef struct OpenPitAccountControl OpenPitAccountControl;
openpit_account_control_block
Records a block against the account bound to an account-control handle.
Records block against the bound account on the engine's shared blocked-accounts facility. The first cause recorded for an account wins; later calls for the same account are no-ops.
Contract:
controlmust be a valid non-null account-control handle, or null.blockpayload fields are copied into internal storage before this call returns.- Passing a null
controlrecords nothing and has no effect.
Safety
control must be either null or a valid account-control handle provided by this library.
void openpit_account_control_block(
const OpenPitAccountControl * control,
OpenPitPretradeAccountBlock block
);
openpit_account_control_clone
Returns a new handle referring to the same account-control facility.
Use this to retain the ability to block the bound account from a later callback within the same pre-trade transaction. The returned handle records blocks against the same account as the source handle and shares its validity window: it is valid to use only within that pre-trade transaction, and is undefined afterwards.
Success:
- returns a non-null caller-owned handle to the same facility.
Error:
- returns null when
controlis null.
Cleanup:
- the returned handle MUST be released with
openpit_destroy_account_controlexactly once.
Safety
control must be either null or a valid account-control handle provided by this library.
OpenPitAccountControl * openpit_account_control_clone(
const OpenPitAccountControl * control
);
openpit_destroy_account_control
Releases a caller-owned account-control handle.
Lifetime contract:
- Call this exactly once for each handle that was returned to the caller.
- After this call the handle is no longer valid.
- Passing a null pointer is allowed and has no effect.
- This function always succeeds.
void openpit_destroy_account_control(
OpenPitAccountControl * control
);
openpit_pretrade_context_get_account_control
Returns an account-control handle for a main-stage pre-trade context.
A main-stage pre-trade context carries account control only when an account could be bound to the request.
Contract:
ctxmust be the callback-scoped context pointer passed to a custom main-stage pre-trade callback; it is valid only for the duration of that callback.
Success:
- returns a non-null caller-owned handle when the context carries account control.
Error:
- returns null when
ctxis null or the context carries no account control (no account could be bound).
Cleanup:
- the returned handle MUST be released with
openpit_destroy_account_controlexactly once. It may be retained for deferred blocking, but it is valid to use only within the pre-trade transaction of this request — through the commit or rollback of its reservation; recording a block through it afterwards is undefined.
Safety
ctx must be either null or a valid callback-scoped pre-trade context pointer provided to this library.
OpenPitAccountControl * openpit_pretrade_context_get_account_control(
const OpenPitPretradeContext * ctx
);
openpit_account_adjustment_context_get_account_control
Returns an account-control handle for an account-adjustment context.
An account-adjustment context always carries account control, so this call returns a non-null handle for any valid context.
Contract:
ctxmust be the callback-scoped context pointer passed to a custom account-adjustment callback; it is valid only for the duration of that callback.
Success:
- returns a non-null caller-owned handle.
Error:
- returns null when
ctxis null.
Cleanup:
- the returned handle MUST be released with
openpit_destroy_account_controlexactly once. It may be retained for deferred blocking, but it is valid to use only within the account adjustment processing of this request — through the commit or rollback of that request; recording a block through it afterwards is undefined.
Safety
ctx must be either null or a valid callback-scoped account-adjustment context pointer provided to this library.
OpenPitAccountControl * openpit_account_adjustment_context_get_account_control(
const OpenPitAccountAdjustmentContext * ctx
);
openpit_pretrade_context_get_account_group
Returns the account-group for a main-stage pre-trade context.
Looks up the group registered for the bound order account. The result is cached on first call and reused for subsequent calls within the same context lifetime.
Contract:
ctxmust be the callback-scoped context pointer passed to a custom main-stage pre-trade callback; it is valid only for the duration of that callback.out_groupmust be a valid non-null pointer.
Success:
- returns
trueand writes the group toout_groupwhen the account is registered in a group; - returns
falsewhenctxis null, no account was bound to the request, or the account belongs to no group;out_groupis not written to.
Safety
ctx must be either null or a valid callback-scoped pre-trade context pointer provided to this library.
bool openpit_pretrade_context_get_account_group(
const OpenPitPretradeContext * ctx,
OpenPitParamAccountGroupId * out_group
);
openpit_account_adjustment_context_get_account_group
Returns the account-group for an account-adjustment context.
Looks up the group registered for the adjusted account. The result is cached on first call and reused for subsequent calls within the same context lifetime.
Contract:
ctxmust be the callback-scoped context pointer passed to a custom account-adjustment callback; it is valid only for the duration of that callback.out_groupmust be a valid non-null pointer.
Success:
- returns
trueand writes the group toout_groupwhen the account is registered in a group; - returns
falsewhenctxis null or the account belongs to no group;out_groupis not written to.
Safety
ctx must be either null or a valid callback-scoped account-adjustment context pointer provided to this library.
bool openpit_account_adjustment_context_get_account_group(
const OpenPitAccountAdjustmentContext * ctx,
OpenPitParamAccountGroupId * out_group
);
openpit_post_trade_context_get_account_group
Returns the account-group for a post-trade context.
Looks up the group registered for the report's account. The result is cached on first call and reused for subsequent calls within the same context lifetime.
Contract:
ctxmust be the callback-scoped context pointer passed to a customapply_execution_reportcallback; it is valid only for the duration of that callback.out_groupmust be a valid non-null pointer.
Success:
- returns
trueand writes the group toout_groupwhen the account is registered in a group; - returns
falsewhenctxis null or the account belongs to no group;out_groupis not written to.
Safety
ctx must be either null or a valid callback-scoped post-trade context pointer provided to this library.
bool openpit_post_trade_context_get_account_group(
const OpenPitPostTradeContext * ctx,
OpenPitParamAccountGroupId * out_group
);