OpenPitPretradePreTradePolicyOpaque pointer for a pre-trade policy.
Contract:
openpit_engine_builder_add_pre_trade_policy.openpit_destroy_pretrade_pre_trade_policy when no longer needed.typedef struct OpenPitPretradePreTradePolicy OpenPitPretradePreTradePolicy;
OpenPitPretradePoliciesPnlBoundsBarrierOne broker barrier definition for
openpit_engine_builder_add_builtin_pnl_bounds_killswitch_policy.
What it describes:
Contract:
settlement_asset must point to a valid string for the duration of the
call.typedef struct OpenPitPretradePoliciesPnlBoundsBarrier {
OpenPitStringView settlement_asset;
OpenPitParamPnlOptional lower_bound;
OpenPitParamPnlOptional upper_bound;
} OpenPitPretradePoliciesPnlBoundsBarrier;
OpenPitPretradePoliciesPnlBoundsAccountBarrierPer-(account, settlement-asset) P&L bounds barrier with an initial P&L seed.
What it describes:
initial_pnl is pre-loaded into storage at construction; accumulation
starts from this value.Passed to openpit_engine_builder_add_builtin_pnl_bounds_killswitch_policy in
the account array.
typedef struct OpenPitPretradePoliciesPnlBoundsAccountBarrier {
OpenPitParamAccountId account_id;
OpenPitStringView settlement_asset;
OpenPitParamPnlOptional lower_bound;
OpenPitParamPnlOptional upper_bound;
OpenPitParamPnl initial_pnl;
} OpenPitPretradePoliciesPnlBoundsAccountBarrier;
OpenPitPretradePoliciesRateLimitBrokerBarrierBroker-wide rate-limit barrier for
openpit_engine_builder_add_builtin_rate_limit_policy.
typedef struct OpenPitPretradePoliciesRateLimitBrokerBarrier {
size_t max_orders;
uint64_t window_nanoseconds;
} OpenPitPretradePoliciesRateLimitBrokerBarrier;
OpenPitPretradePoliciesRateLimitAssetBarrierPer-settlement-asset rate-limit barrier for
openpit_engine_builder_add_builtin_rate_limit_policy.
typedef struct OpenPitPretradePoliciesRateLimitAssetBarrier {
OpenPitStringView settlement_asset;
size_t max_orders;
uint64_t window_nanoseconds;
} OpenPitPretradePoliciesRateLimitAssetBarrier;
OpenPitPretradePoliciesRateLimitAccountBarrierPer-account rate-limit barrier for
openpit_engine_builder_add_builtin_rate_limit_policy.
typedef struct OpenPitPretradePoliciesRateLimitAccountBarrier {
OpenPitParamAccountId account_id;
size_t max_orders;
uint64_t window_nanoseconds;
} OpenPitPretradePoliciesRateLimitAccountBarrier;
OpenPitPretradePoliciesRateLimitAccountAssetBarrierPer-(account, settlement-asset) rate-limit barrier for
openpit_engine_builder_add_builtin_rate_limit_policy.
typedef struct OpenPitPretradePoliciesRateLimitAccountAssetBarrier {
OpenPitParamAccountId account_id;
OpenPitStringView settlement_asset;
size_t max_orders;
uint64_t window_nanoseconds;
} OpenPitPretradePoliciesRateLimitAccountAssetBarrier;
OpenPitPretradePoliciesOrderSizeLimitShared order-size limits for
openpit_engine_builder_add_builtin_order_size_limit_policy.
typedef struct OpenPitPretradePoliciesOrderSizeLimit {
OpenPitParamQuantity max_quantity;
OpenPitParamVolume max_notional;
} OpenPitPretradePoliciesOrderSizeLimit;
OpenPitPretradePoliciesOrderSizeBrokerBarrierBroker-wide order-size barrier for
openpit_engine_builder_add_builtin_order_size_limit_policy.
typedef struct OpenPitPretradePoliciesOrderSizeBrokerBarrier {
OpenPitPretradePoliciesOrderSizeLimit limit;
} OpenPitPretradePoliciesOrderSizeBrokerBarrier;
OpenPitPretradePoliciesOrderSizeAssetBarrierPer-settlement-asset order-size barrier for
openpit_engine_builder_add_builtin_order_size_limit_policy.
typedef struct OpenPitPretradePoliciesOrderSizeAssetBarrier {
OpenPitPretradePoliciesOrderSizeLimit limit;
OpenPitStringView settlement_asset;
} OpenPitPretradePoliciesOrderSizeAssetBarrier;
OpenPitPretradePoliciesOrderSizeAccountAssetBarrierPer-(account, settlement-asset) order-size barrier for
openpit_engine_builder_add_builtin_order_size_limit_policy.
typedef struct OpenPitPretradePoliciesOrderSizeAccountAssetBarrier {
OpenPitPretradePoliciesOrderSizeLimit limit;
OpenPitParamAccountId account_id;
OpenPitStringView settlement_asset;
} OpenPitPretradePoliciesOrderSizeAccountAssetBarrier;
openpit_engine_builder_add_builtin_order_validation_policyAdds the built-in order-validation policy to the engine builder.
Contract:
builder must be a valid engine builder pointer.Success:
true; the builder retains the policy.Error:
false when the builder is null or already consumed;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.bool openpit_engine_builder_add_builtin_order_validation_policy(
OpenPitEngineBuilder * builder,
OpenPitOutError out_error
);
openpit_engine_builder_add_builtin_rate_limit_policyAdds the built-in rate-limit policy to the engine builder.
Contract:
builder must be a valid engine builder pointer.broker non-null, asset_len > 0, account_len > 0, or account_asset_len > 0.settlement_asset string view inside an array entry must be valid for
the duration of the call.Success:
true; the builder retains the policy.Error:
false when the builder is null or already consumed, when no
barrier axis is configured, or when argument parsing fails;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.bool openpit_engine_builder_add_builtin_rate_limit_policy(
OpenPitEngineBuilder * builder,
const OpenPitPretradePoliciesRateLimitBrokerBarrier * broker,
const OpenPitPretradePoliciesRateLimitAssetBarrier * asset,
size_t asset_len,
const OpenPitPretradePoliciesRateLimitAccountBarrier * account,
size_t account_len,
const OpenPitPretradePoliciesRateLimitAccountAssetBarrier * account_asset,
size_t account_asset_len,
OpenPitOutError out_error
);
openpit_engine_builder_add_builtin_order_size_limit_policyAdds the built-in order-size limit policy to the engine builder.
Contract:
builder must be a valid engine builder pointer.broker non-null, asset_len > 0, or account_asset_len > 0.settlement_asset string view inside an array entry must be valid for
the duration of the call.max_quantity and max_notional inside each limit must be valid.Success:
true; the builder retains the policy.Error:
false when the builder is null or already consumed, when no
barrier axis is configured, or when argument parsing fails;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.bool openpit_engine_builder_add_builtin_order_size_limit_policy(
OpenPitEngineBuilder * builder,
const OpenPitPretradePoliciesOrderSizeBrokerBarrier * broker,
const OpenPitPretradePoliciesOrderSizeAssetBarrier * asset,
size_t asset_len,
const OpenPitPretradePoliciesOrderSizeAccountAssetBarrier * account_asset,
size_t account_asset_len,
OpenPitOutError out_error
);
openpit_engine_builder_add_builtin_pnl_bounds_killswitch_policyAdds the built-in P&L bounds kill-switch policy to the engine builder.
Contract:
builder must be a valid engine builder pointer.broker_len > 0 or account_len > 0.settlement_asset string view inside an array entry must be valid for
the duration of the call.Success:
true; the builder retains the policy.Error:
false when the builder is null or already consumed, when no
barrier is configured, or when argument parsing fails;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.bool openpit_engine_builder_add_builtin_pnl_bounds_killswitch_policy(
OpenPitEngineBuilder * builder,
const OpenPitPretradePoliciesPnlBoundsBarrier * broker,
size_t broker_len,
const OpenPitPretradePoliciesPnlBoundsAccountBarrier * account,
size_t account_len,
OpenPitOutError out_error
);
openpit_destroy_pretrade_pre_trade_policyDestroys the caller-owned pointer for a pre-trade policy.
Lifetime contract:
void openpit_destroy_pretrade_pre_trade_policy(
OpenPitPretradePreTradePolicy * policy
);
openpit_pretrade_pre_trade_policy_get_nameReturns the stable policy name for a pre-trade policy pointer.
Contract:
policy must be a valid non-null pointer.OpenPitStringView openpit_pretrade_pre_trade_policy_get_name(
const OpenPitPretradePreTradePolicy * policy
);
openpit_engine_builder_add_pre_trade_policyAdds a pre-trade policy to the engine builder.
Contract:
builder must be a valid engine builder pointer.policy must be a valid non-null pre-trade policy pointer.Success:
true and the builder retains its own reference to the policy.Error:
false when the builder or policy cannot be used;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.Lifetime contract:
openpit_destroy_pretrade_pre_trade_policy when it is no
longer needed.bool openpit_engine_builder_add_pre_trade_policy(
OpenPitEngineBuilder * builder,
OpenPitPretradePreTradePolicy * policy,
OpenPitOutError out_error
);
OpenPitPretradeContextOpaque context passed to main-stage C policy callbacks.
Valid only for the duration of the callback. Cannot be constructed by caller code.
Future extension: this type is the designated seam for engine storage-cell access. A read accessor will be added here when the engine store is introduced.
typedef struct OpenPitPretradeContext OpenPitPretradeContext;
OpenPitAccountAdjustmentContextOpaque context passed to account-adjustment C policy callbacks.
Valid only for the duration of the callback. Cannot be constructed by caller code.
Future extension: this type is the designated seam for engine storage-cell access. A read accessor will be added here when the engine store is introduced.
typedef struct OpenPitAccountAdjustmentContext OpenPitAccountAdjustmentContext;
OpenPitMutationsOpaque, non-owning pointer to the mutation collector.
Valid only during the policy callback that received it. The caller must not store or use this pointer after the callback returns.
typedef struct OpenPitMutations OpenPitMutations;
OpenPitMutationFnCallback invoked for either commit or rollback of a registered mutation.
typedef void (*OpenPitMutationFn)(
void * user_data
);
OpenPitMutationFreeFnOptional callback to release mutation user_data after execution.
Called exactly once per openpit_mutations_push:
commit_fn when commit runs;rollback_fn when rollback runs;typedef void (*OpenPitMutationFreeFn)(
void * user_data
);
openpit_mutations_pushRegisters one commit/rollback mutation in the provided collector.
Contract:
mutations must be a valid non-null callback-scoped pointer.commit_fn and rollback_fn must remain callable until one of them is
executed.user_data is passed to both callbacks.commit_fn or rollback_fn runs for each successful push.free_fn is called exactly once when
provided.free_fn runs
exactly once when provided.Error:
false when mutations is null or invalid;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.bool openpit_mutations_push(
OpenPitMutations * mutations,
OpenPitMutationFn commit_fn,
OpenPitMutationFn rollback_fn,
void * user_data,
OpenPitMutationFreeFn free_fn,
OpenPitOutError out_error
);
OpenPitPretradePreTradePolicyCheckPreTradeStartFnCallback used by a custom pre-trade policy to validate one order before a deferred pre-trade request is created.
Contract:
ctx is a read-only context valid only for the duration of the callback.order points to a read-only order view valid only for the duration of the
callback.order is passed as a borrowed view and is not copied before the callback
runs.order, it must copy that data
before returning.code and scope values in every list
item.openpit_create_reject_list.user_data is passed through unchanged from policy creation.typedef OpenPitRejectList *
(*OpenPitPretradePreTradePolicyCheckPreTradeStartFn)(
const OpenPitPretradeContext * ctx,
const OpenPitOrder * order,
void * user_data
);
OpenPitPretradePreTradePolicyPerformPreTradeCheckFnCallback used by a custom pre-trade policy to perform a main-stage check.
Contract:
ctx is a read-only context valid only for the duration of the callback.order points to a read-only order view valid only for the duration of the
callback.order is passed as a borrowed view and is not copied before the callback
runs.order, it must copy that data
before returning.mutations is a callback-scoped non-owning pointer that allows the callback
to register commit/rollback mutations.mutations after return.code and scope values.openpit_create_reject_list.user_data is passed through unchanged from policy creation.typedef OpenPitRejectList *
(*OpenPitPretradePreTradePolicyPerformPreTradeCheckFn)(
const OpenPitPretradeContext * ctx,
const OpenPitOrder * order,
OpenPitMutations * mutations,
void * user_data
);
OpenPitPretradePreTradePolicyApplyExecutionReportFnCallback used by a custom pre-trade policy to observe an execution report.
Contract:
report points to a read-only report view valid only for the duration of
the callback.report is passed as a borrowed view and is not copied before the callback
runs.report, it must copy that data
before returning.true when this policy reports a kill-switch trigger.false otherwise.user_data is passed through unchanged from policy creation.typedef bool (*OpenPitPretradePreTradePolicyApplyExecutionReportFn)(
const OpenPitExecutionReport * report,
void * user_data
);
OpenPitPretradePreTradePolicyApplyAccountAdjustmentFnCallback used by a custom pre-trade policy to validate one account adjustment.
Contract:
ctx is a read-only context valid only for the duration of the callback.adjustment points to a read-only adjustment view valid only for the
duration of the callback.adjustment is passed as a borrowed view and is not copied before the
callback runs.adjustment, it must copy that
data before returning.account_id must follow the same source model as the rest of the runtime
state (numeric-only or string-derived-only).mutations is a callback-scoped non-owning pointer that allows the callback
to register commit/rollback mutations.mutations after return.user_data is passed through unchanged from policy creation.typedef OpenPitRejectList *
(*OpenPitPretradePreTradePolicyApplyAccountAdjustmentFn)(
const OpenPitAccountAdjustmentContext * ctx,
OpenPitParamAccountId account_id,
const OpenPitAccountAdjustment * adjustment,
OpenPitMutations * mutations,
void * user_data
);
OpenPitPretradePreTradePolicyFreeUserDataFnCallback invoked when the last reference to a custom pre-trade policy is released and the policy object is about to be destroyed.
Contract:
user_data is the same value that was passed at policy creation.user_data.typedef void (*OpenPitPretradePreTradePolicyFreeUserDataFn)(
void * user_data
);
openpit_create_pretrade_custom_pre_trade_policyCreates a custom pre-trade policy from caller-provided callbacks.
Contract:
name must point to a valid, null-terminated string for the duration of the
call.check_pre_trade_start_fn, perform_pre_trade_check_fn,
apply_execution_report_fn, and apply_account_adjustment_fn may be null.check_pre_trade_start_fn, perform_pre_trade_check_fn, or
apply_account_adjustment_fn means that hook accepts by default.apply_execution_report_fn means that hook returns false.free_user_data_fn must remain callable for as long
as the policy may still be used by either the caller pointer or the engine.mutations pointer.free_user_data_fn will be called exactly once, when the last reference to
the policy is released.user_data is opaque to the SDK: the engine never inspects, dereferences,
or frees it; it is forwarded verbatim to the registered callbacks. Lifetime,
thread-safety, and meaning of the pointed-at state are entirely the caller’s
responsibility. Under OpenPitSyncPolicy_Local or
OpenPitSyncPolicy_Account, the caller serialises per-handle invocation per
the SDK threading contract; under OpenPitSyncPolicy_Full, the caller is
responsible for making any state reachable through user_data safe under
concurrent invocation.Success:
Error:
name is invalid;out_error is not null, writes a caller-owned OpenPitSharedString
error handle that MUST be released with openpit_destroy_shared_string.Lifetime contract:
name; the caller may release the input
string after this function returns.openpit_destroy_pretrade_pre_trade_policy when no longer needed.free_user_data_fn runs once the last reference to the policy is released;
when the engine is the final holder, it runs as part of engine destruction.OpenPitPretradePreTradePolicy * openpit_create_pretrade_custom_pre_trade_policy(
OpenPitStringView name,
OpenPitPretradePreTradePolicyCheckPreTradeStartFn check_pre_trade_start_fn,
OpenPitPretradePreTradePolicyPerformPreTradeCheckFn perform_pre_trade_check_fn,
OpenPitPretradePreTradePolicyApplyExecutionReportFn apply_execution_report_fn,
OpenPitPretradePreTradePolicyApplyAccountAdjustmentFn apply_account_adjustment_fn,
OpenPitPretradePreTradePolicyFreeUserDataFn free_user_data_fn,
void * user_data,
OpenPitOutError out_error
);