Skip to main content
The client.risk namespace exposes risk state inspection, per-subaccount limit configuration, an account-wide kill switch, and a risk-layer cancel-all endpoint. Use these controls to enforce pre-trade guardrails, respond to adverse market conditions, and satisfy operational risk requirements. The kill switch is a hard stop: activating it immediately halts all order submission and rejects new order requests until you explicitly deactivate it.

risk.state

Retrieve the current risk state for a subaccount, including whether any limits are breached or the kill switch is active. Method: client.risk.state(subaccount_id) — GET /v1/risk
string
required
The subaccount whose risk state to retrieve.

risk.limits

Retrieve configured risk limits. Pass a subaccount_id to get limits for a specific subaccount, or omit it to retrieve account-level limits. Method: client.risk.limits(subaccount_id=None) — GET /v1/risk/limits
string
The subaccount whose risk limits to retrieve. Omit to retrieve account-level limits.

risk.set_limits

Configure risk limits. Provide the fields you want to set as keyword arguments. Fields omitted retain their existing values. Method: client.risk.set_limits(**payload) — PUT /v1/risk/limits
string
The subaccount to configure. Omit to set account-level limits.
string
Maximum quantity allowed on a single order submission.
string
Maximum aggregate position size across all instruments.
integer
Maximum number of simultaneously resting orders.

risk.kill_switch

Activate or deactivate the kill switch. When activated, Molecule immediately rejects all new order submissions and returns ForbiddenError with error code kill_switch. Deactivating the kill switch restores normal order flow. Method: client.risk.kill_switch(enabled) — POST /v1/risk/kill-switch
boolean
required
Pass True to activate the kill switch and halt all order submission. Pass False to deactivate it and resume normal operation.
Activating the kill switch is immediate and affects all subaccounts associated with your API key. Any in-flight orders that have not yet been acknowledged by the venue may still execute. Open resting orders are not automatically cancelled — use risk.cancel_all() or orders.cancel_all() first if you need to remove resting orders simultaneously.

risk.cancel_all

Cancel all open orders for a subaccount via the risk layer. Method: client.risk.cancel_all(subaccount_id) — POST /v1/risk/cancel-all
string
required
The subaccount whose open orders to cancel.

Error reference