Skip to content

Emergency Controls

Kill switch methods for rapid risk reduction. These are destructive operations — use with caution.

Account Kill Switch

Cancels all working orders and closes all live positions for an account.

python
# Paper account
result = client.account_kill_switch(mode="paper")

# Live account
result = client.account_kill_switch(mode="live")

# Fund account
result = client.account_kill_switch(mode="fund")

# If mode is omitted, inferred from the client's strategy_id prefix
result = client.account_kill_switch()

Returns:

python
{
    "status": "success",
    "result": {
        "mode": "paper",
        "cancelled_orders": [
            {"order_id": "1234567", "result": {...}}
        ],
        "closed_positions": [
            {"conid": 265598, "symbol": "AAPL", "side": "SELL", "qty": 10, "result": {...}}
        ],
        "skipped_orders": [
            {"order_id": "1234569", "status": "filled"}
        ],
        "skipped_positions": [
            {"conid": 999, "symbol": "SPX BAG", "reason": "combo/BAG position (requires manual close)"}
        ],
        "errors": []
    }
}

Behavior:

  • Cancels all non-final orders (skips filled/cancelled/inactive)
  • Closes all non-zero positions via market orders
  • Skips combo/BAG positions (must be closed leg-by-leg manually)
  • Invalidates the position cache after execution

Flatten All

Alias of account_kill_switch():

python
result = client.flatten_all(mode="paper")
result = client.flatten_all(mode="live")
result = client.flatten_all(mode="fund")

Strategy Kill Switch (Deprecated)

python
result = client.strategy_kill_switch()

Deprecated. Use flatten_all() or account_kill_switch() instead. Emits a DeprecationWarning.

Async Client

python
result = await async_client.account_kill_switch(mode="paper")
result = await async_client.flatten_all(mode="live")