Errors and rejects¶
OpenPit separates business rejects from API errors.
Business rejects¶
Policy rejects are expected outcomes. They are returned in result objects:
StartResult.rejectsExecuteResult.rejectsAccountAdjustmentBatchResult.rejects
Each reject contains a stable code, reason, details, policy name, scope, and an
optional user_data token.
result = engine.execute_pre_trade(order=order)
if not result:
for reject in result.rejects:
print(reject.policy, reject.code, reject.reason)
Exceptions¶
Exceptions are reserved for invalid API usage or unexpected callback failures. Common cases include:
TypeErrorfor wrong wrapper types, such as rawintaccount IDs.ValueErrorfor invalid domain values, such as empty assets.RuntimeErrorfor lifecycle misuse, such as executing a request twice.RejectErrorfor callback-level failures surfaced by the binding.
Do not raise exceptions for normal risk decisions in custom policies. Return
PolicyReject or PolicyDecision.reject(...) instead.