# Pit Officer 0.4.0: orders that wait for a person

Pit Officer 0.4.0 lets a limit park an order for an operator, with or without its funds held, instead of only passing or rejecting it; an AI agent over MCP sees the review but cannot decide it. It adds position limits, a daily P&L reset, an Execution Simulator, and Bybit, OKX, Coinbase and OpenAlgo.

Canonical: <https://pitofficer.com/blog/pit-officer-0-4-0/>
Author: Anna Palchukovsky <https://www.linkedin.com/in/anna-palchukovsky/>
Description: A hard limit either rejects the large order you wanted or passes a runaway one. Pit Officer 0.4.0 parks it for an operator, with funds held or not.
Published: 2026-11-30T22:45:41+02:00
Updated: 2026-11-30T22:45:41+02:00
Tags: pit-officer, risk-controls, order-validation, order-management, trading-bots, kill-switch

A 1 BTC order-size cap rejects the 1.5 BTC breakout buy your AI agent was
built for; raise the cap to 2 BTC and a runaway 1.9 BTC buy goes through with
nobody looking.

:::stat
**190,000 USD**

The 1.9 BTC runaway buy at 100,000 USD that a 2 BTC cap passes unseen, while a
1 BTC cap would reject the breakout. Illustrative numbers.
:::

:::timeline

1. **The agent sends a 1.5 BTC buy at 100,000 USD for an account named desk.**
   It is over a 1 BTC review limit and under a 2 BTC reject limit.
2. **Officer answers "review".** The order waits, nothing reaches the venue,
   and 150,000 USD is set aside for it.
3. **An alert goes out.** An open panel tab with notifications allowed shows
   it.
4. **An operator reads the reason and confirms.** Every pre-trade check runs
   again.
5. **The order is sent and fills.** The money set aside pays for it.

:::

Pit Officer 0.4.0 gives a limit that third answer: wait for a person
([release notes](https://github.com/openpitkit/officer/releases/tag/v0.4.0)).

:::cards

- **A limit can ask for a person.** Order-size, rate, position and P&L limits
  can send an order to review instead of rejecting it, and a review limit and
  a reject limit can sit on the same target.
- **Holding the funds is your choice.** A review with hold sets the order's
  money aside while it waits; without the hold, other bots on the account can
  spend it, and the operator's confirm can then fail.
- **The operator decides.** Confirm, force and cancel live in the panel and
  the REST API, behind the operator's access; an AI agent over MCP sees the
  review but cannot decide it.
- **Somebody has to be watching.** Browser notifications arrive only while a
  panel tab is open, and the 0.4.0 documentation describes no expiry for a
  waiting order.
- **Test the order path first.** The Execution Simulator takes paper orders
  through Officer's real send path, with no venue keys.

:::

## What changed in 0.4.0?

**Beyond review: four changes for a trading desk, and three that can break an
integration.**

:::cards

- **Position limit.** A ceiling per account and asset that counts the
  account's open buys, whichever bot sent them.
- **Daily P&L reset.** Realized P&L back to zero at a set time each day.
- **Venues.** Spot orders on Bybit, OKX and Coinbase; orders and prices
  through OpenAlgo.
- **Alerts.** For an order awaiting review, and for an account that gains
  both paper and live access.

:::

:::more[The full change list and the breaking changes]
By the [release](https://github.com/openpitkit/officer/releases/tag/v0.4.0)
and the [compare of the tags](https://github.com/openpitkit/officer/compare/v0.3.0...v0.4.0),
0.4.0, released 2026-11-30, brings:

- Review modes: rate, order-size, position and P&L-bound limits take the mode
  `reject`, `review_without_hold` or `review_with_hold`; the mode is part of
  the limit's key. The Spot Funds limit mode gains `review_with_hold` and
  `review_without_hold` for a funds shortfall. They come from the OpenPit
  engine [0.12.0](https://github.com/openpitkit/pit/releases/tag/v0.12.0)
  ([Review Mode](https://wiki.openpit.dev/Review-Mode/)).
- The operator's decision on a waiting order: confirm, force or cancel, in the
  panel and REST; MCP reads only.
- A position limit per account and asset.
- A manual realized P&L reset per account and one daily schedule for all
  accounts.
- The Execution Simulator, a paper-only venue.
- Spot trading on Bybit, OKX and Coinbase Advanced Trade; trading and market
  data through OpenAlgo.
- Alerts with browser notifications and an unread count on the tab.

The breaking changes are in
[What must you change when you upgrade?](#what-must-you-change-when-you-upgrade)
:::

## What happens to an order that waits for review?

**It waits as "Awaiting review", nothing is sent, an alert goes out, and an
operator moves it on by confirming, forcing or canceling it; the 0.4.0
documentation describes no timeout.** A review limit and a reject limit on the
same target make a tier: up to the first the order passes the size check,
over it and up to the second it waits, over the second it is rejected. Other
checks can still reject it.

![Order-size limits on an account named desk, BTC: up to 1 BTC an order passes the size check, over 1 and up to 2 BTC it waits for a person, with its funds held when every review mark holds and no other check rejects it, over 2 BTC it is rejected. The 1.5 BTC breakout buy, which a 1 BTC cap rejects, now waits; the 1.9 BTC runaway buy, which a 2 BTC cap passes unseen, now waits too.](https://pitofficer.com/blog/assets/tiered-limit.BTSUBwpG_2hdj1g.webp)

A paper or live send that passes the checks goes straight to the venue. A
waiting one moves on only through the operator:

```d2 title="What happens to a waiting order, and who moves it"
grid-rows: 3
grid-columns: 2
horizontal-gap: 70
vertical-gap: 60
wait: "Waits for an\noperator; an AI\nagent can only\nread it"
cancel: "Cancel:\nnothing sent,\nhold freed"
confirm: "Confirm: checks\nrerun on the\naccount now; a\nfail keeps it\nwaiting"
force: "Force: held,\nnot blocked;\nno pre-trade\nrerun"
send: "Sent to\nthe venue"
gap: "" {style.opacity: 0}
wait -> cancel
wait -> confirm
wait -> force
confirm -> send: "pass"
force -> send
```

The order in the panel, from a local run of the 0.4.0 image with test data:

![Pit Officer 0.4.0 order detail for a 1.5 BTC buy on account desk: status Awaiting review, a review mark from the order-size limit in review-with-hold mode (requested 1.5, max allowed 1), funds Held, the Execution Simulator connection, and the Confirm, Cancel order and Force buttons.](https://pitofficer.com/blog/assets/order-awaiting-review.BH9FmKMS_ZPBpSL.webp)

:::more[Definitions: review limit, review verdict, review mark, held review]
A **review limit** is a limit in a review mode: an order over it waits for an
operator instead of being rejected.
A **review verdict** is a pre-trade answer besides accept and reject: the
order is recorded as awaiting review and not sent. Each limit that asked for
review leaves a **review mark** - the limit, its reason and its mode, with
hold or without. A review is **held** when it has at least one mark and every
mark is with hold: the order's funds are then set aside as for an accepted
order. One mark without hold means nothing is held
([Order review](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#order-review)).
:::

:::more[What each decision does in the API]

- **Confirm**, `POST /orders/{id}/review/confirm`, reruns pre-trade, which
  spends rate-limit units again. A rejection answers HTTP `200` with a `reject`
  decision and leaves the order waiting; retry through the same endpoint. A
  trading order that passes is sent to its stored destination, and the answer
  carries `venueSend`.
- **Force**, `POST /orders/{id}/review/force`, accepts only a held review and
  does not rerun pre-trade; the block check and a trading order's connection
  and venue pre-checks still apply. A review without hold, or an account blocked by its own
  flag or its group, answers `409` `conflict`; a blocked order keeps waiting
  with its hold until the block is lifted.
- **Cancel**, `POST /orders/{id}/review/cancel`, cancels the order and releases
  a held review's hold.
- The ordinary `/confirm` and `/cancel` shortcuts and execution reports refuse
  a waiting order with `409` `conflict`.
- After a `500` the decision may already be recorded: read `GET /orders/{id}`
  before retrying.
- `GET /orders/{id}` carries `review` while the order waits: `held`, `marks`,
  the last failed confirmation in `lastConfirm`, and the stored destination.
  `review.held` is the authority on whether funds are held.

The behavior, the hold included, is from
[Order review](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#order-review)
at v0.4.0; the endpoint shapes are in the
[OpenAPI document](https://github.com/openpitkit/officer/blob/v0.4.0/httpapi/openapi.yaml).
On the 0.4.0 image, orders sent through `POST /orders/send-paper` showed the
`review.held` `true` with hold and `false` without, and a confirm, a force, a force refused for an unheld
review, a review cancel and the ordinary confirm refused with `409` behaved
as described.
:::

## Should a waiting order hold its funds?

**Hold them when the order must still be payable when the operator gets to it;
leave them free when other bots on the account must keep trading meanwhile,
and accept that the confirm may then fail.** An account named desk has
200,000 USD and two bots. A 1.5 BTC buy at 100,000 USD waits under a 1 BTC
review limit; then the second bot buys 0.6 BTC, and the operator confirms:

![Available USD on account desk. With hold: 200,000 drops to 50,000 when the 1.5 BTC buy starts waiting, the second bot's 0.6 BTC buy is refused for funds, and the operator's confirm passes and sends the order. Without hold: 200,000 stays available, the 0.6 BTC buy fills and leaves 140,000, and the confirm is rejected because the 1.5 BTC order needs 150,000, so the order keeps waiting.](https://pitofficer.com/blog/assets/shared-account-hold.CjD6tXpH_1kVWoB.webp)

A held review takes 150,000 USD out of every bot's reach until someone
decides. Without the hold, the parked order can lose the race for the money,
which the operator may first see as a failed confirm. The chart's numbers come
from the 0.4.0 image ([the code](#where-is-the-code)).

:::more[Under Check funds, an order over a review limit must still be payable]
With funds checked, the default, an order that the account cannot pay for is
rejected for funds even when a limit would have sent it to review: a second
1.5 BTC buy at 100,000 USD, sent while the first held 150,000 USD of the
200,000 USD, was rejected with "available 50000.0, requested 150000.0" (local
run of the 0.4.0 image).
:::

:::more[A funds shortfall can wait for a person too]
The Spot Funds limit mode, which decides what happens when an order needs more
than the account holds, gains two values. With `review_with_hold` the order
waits and the full amount is held, which can take available funds negative; a
confirmed order keeps the hold. With `review_without_hold` nothing is held
while it waits. Both sit between "Check funds" (`enforce`) and "Accounting
without blocking" (`track_only`); an AI agent cannot set either review value
over MCP
([Spot Funds limit mode](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#spot-funds-limit-mode)).
When Officer's ledger lags the venue, the operator can confirm an order the
venue can pay for instead of losing it, the case in
[API order rejected for insufficient balance but you have enough](/blog/api-order-rejected-insufficient-balance/).
:::

## Who can approve a waiting order, and can an AI agent approve its own?

**Whoever has the operator's access, in the panel or through the REST API. An
AI agent over MCP sees that an order waits, and why, but cannot confirm, force
or cancel it, and cannot change a review limit.** An agent that holds the REST
API token is a
different matter: the token is the operator's, so keep it out of the agent's
environment, along with Docker and your shell
([quickstart](https://github.com/openpitkit/officer/blob/v0.4.0/docs/quickstart.md#open-the-panel)).

The operator has to see the order, too. The alert names it, and an open panel
tab with notifications allowed shows it as a browser notification:

![The Pit Officer 0.4.0 alerts drawer: Browser notifications are on, and one unread alert, Order awaiting review: e-breakout-15. Test data.](https://pitofficer.com/blog/assets/alerts-drawer.DB5d9lPq_ZFQ1DO.webp)

Notifications come only while a panel tab is open, with no push service
behind them; a background tab can deliver them about a minute late, and
Android Chrome cannot show them. The tab title shows the unread count either
way
([Browser notifications](https://github.com/openpitkit/officer/blob/v0.4.0/docs/alerts.md#browser-notifications)).

:::more[What an agent can do over MCP]
`add_limit` and `update_limit` address only reject limits and refuse a `mode`
argument, so review limits are read-only for an agent; `update_limit` refuses
either review value of the Spot Funds limit mode with `validation`.
`get_limits` and `get_account_state` show every limit's mode
([MCP tools](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#mcp-tools)).
The alert tools `list_alerts` and `get_alert` read; `resolve_alert` ships
disabled, and the review alert's only action closes it after the order has
been decided ([alerts](https://github.com/openpitkit/officer/blob/v0.4.0/docs/alerts.md)).
:::

## How do you cap a position across bots?

**Set a position limit for the account and asset: a ceiling on what a buy
projects, counting what the account owns, the incoming quantity of its open
buys, whichever bot sent them, and the order itself.** With a 1 BTC limit, the account holds 0.6 BTC that bot A
bought, and bot B has a 0.3 BTC buy still open:

![Position limit of 1 BTC on an account named desk. Bot A's 0.2 BTC buy projects 0.6 owned plus bot B's open 0.3 plus 0.2, which is 1.1, and is refused without blocking the account; a 0.1 BTC buy projects exactly 1.0 and passes the position limit.](https://pitofficer.com/blog/assets/position-projection.D4jbinSD_Z1pv4PC.webp)

- **Shorts too.** A sell is checked the same way against minus the limit.
- **No block.** A refusal blocks nothing; a smaller order can still pass.
- **Per account and asset only.** It works in every funds mode, rejects or
  sends to review, and has no group or global form in 0.4.0
  ([why bots share one account](/blog/multiple-trading-bots-one-account/)).

:::more[The rule, and the limit in the API]
A **position limit** is a ceiling on an account's worst-case projected
position in one asset, checked before each order.
A buy adds the order to the owned position (`available + held`) plus open
positive `incoming`; a sell subtracts the order from the owned position less
open positive `held`. A buy above the ceiling or a sell below minus the
ceiling triggers the limit; equality passes. The refusal is policy
`SpotFundsPolicy`, code `position_limit_exceeded`, and the account is not
blocked
([Position limit](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#position-limit)).
On the 0.4.0 image the 0.2 BTC buy above answered
`asset "BTC", side long, projected worst-case position 1.1, limit 1`.

`PUT /limits/position?missingAccount=reject` with
`{"scope": "account_asset", "account": "desk", "asset": "BTC", "maxPosition": "1", "mode": "reject"}`
sets it; `maxPosition` is a non-negative decimal string, zero included.
:::

## How do you turn a P&L bound into a daily loss limit?

**Put a lower bound in reject mode on realized P&L and schedule the daily
reset: each successful daily reset sets realized P&L to zero, but an account
the bound has
blocked stays blocked until a person unblocks it.** The account named desk has
a -1,500 USD bound and a reset at 17:00 New York time:

![An illustrative two-day timeline of realized P&L on account desk with a -1,500 USD reject-mode bound. A losing sell realizes -1,800 and its fill blocks the account; the next order is rejected; the 17:00 reset sets realized P&L to 0 but the block stays; the next morning an order is still rejected; an operator unblocks the account and orders pass. The run on 0.4.0 reproduced this sequence with a manual reset in place of the scheduled one.](https://pitofficer.com/blog/assets/daily-loss-reset.BD6iAGOD_dcAKR.webp)

The reset is what makes the unblock work: here realized P&L 0 is inside the
-1,500 USD bound, so after the unblock the next order passed instead of
blocking the account again.

- **Kept.** Positions, cost basis and history.
- **One schedule.** It covers every account.
- **Outside the bot.** The block lives in Officer, as in
  [What happens if my trading bot crashes with a position open?](/blog/trading-bot-crashed-open-position/).

:::more[Realized P&L reset: what it does and its edge cases]
A **realized P&L reset** sets an account's whole realized P&L to zero, also
from a halted or unset value; positions, cost basis and history are kept and
a latched block stays
([Realized account P&L reset](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#realized-account-pl-reset)).
The schedule
([daily realized P&L reset](https://github.com/openpitkit/officer/blob/v0.4.0/docs/configuration.md#daily-realized-pl-reset)):

- One daily time (HH:mm) in a named IANA timezone, ending after N successful
  runs, at a date and time, or never.
- It resets every stored account, accounts hidden by single-account mode
  included; the manual reset beside an account's P&L acts on that account.
- A boundary missed while Officer was stopped, or one more than a minute late,
  is skipped, not caught up, so a later loss is never erased by a late reset.
- A repeated daylight-saving minute runs once; a missing one is skipped.
- A failed or interrupted run waits for an explicit retry or skip.
- An AI agent can read the schedule over MCP but cannot change or recover it.

On the 0.4.0 image the losing fill itself blocked the account: the next order
was rejected with "lower bound breached: realized pnl -1800.0, lower bound
-1500", the manual reset answered realized P&L 0 with the account still
blocked, and after the unblock the next order passed.

![The Daily P&L reset section of the Accounts page in Pit Officer 0.4.0: status Scheduled, successful runs 0, the next execution, Enable daily reset checked, time zone America/New\_York, daily reset time 17:00, repetition ends Never. Test data.](https://pitofficer.com/blog/assets/daily-pnl-reset.BGIRBTwX_Z2185jb.webp)
:::

## How do you test the order path without a venue account?

**Connect the Execution Simulator: a paper-only venue inside Officer that
fills orders by rules you set - whole, in two or three parts, every second one
refused, or left open. A market fill takes the bid or ask of a fresh quote
from one market-data mapping for the pair, Mock included; a limit fill takes
the order's own price.** It needs no keys and sends nothing outside Officer,
and the orders take the same checks, holds and send path as a real venue's.

Use it to check that your bot re-protects a position after a partial fill
([Stop loss not covering your position after a partial fill](/blog/stop-loss-not-covering-partial-fill/))
and survives a refused send. Its limits:

- **Forward only.** It trades on the quotes arriving now, with no historical
  data or replay.
- **Easy fills.** A limit order fills at its own price, without waiting for
  the market to reach it, and there is no commission.
- **A restart forgets.** After a runtime restart, the next reconciliation
  cancels what was left open, with no invented fill; until then the order can
  still show as open.

:::more[Execution Simulator rules, prices and setup]
The **Execution Simulator** is provider `test`, paper mode only, with empty
credentials. Its rules match base and quote masks (`*` is any sequence),
checked top to bottom; the first match wins, and no match refuses the order
with `test_policy_no_match`
([Execution Simulator](https://github.com/openpitkit/officer/blob/v0.4.0/docs/test_trading.md)).

- `execute` fills once; `split` fills in 2 or 3 parts, with the unit taken
  from the quantity's decimal places: `1.00` splits into `0.34 + 0.33 + 0.33`,
  while `1` cannot split in three and is refused.
- `reject_even` fills the first new order and refuses the second, in turn,
  counted per connection and saved revision; every policy save restarts the
  count.
- `rest` keeps the order open for a set number of seconds, then fills it, a
  market order at that moment's quote; or it keeps the order open forever.
- A market buy fills at the ask and a sell at the bid (`normal` and `worst`);
  `best` reverses them.

Orders need a quantity amount and an empty route. A market order needs a fresh
bid and ask from exactly one enabled market-data row for the pair. On the
0.4.0 image a forced 1.5 BTC order under a `split` 3 rule filled as three
0.5 BTC trades.

![The Test execution policy editor of an Execution Simulator connection in Pit Officer 0.4.0: saved revision 3, a first rule BTC/USD - Split execution and a second rule \*/USD - Reject every second order, with Add rule and Save. Test data.](https://pitofficer.com/blog/assets/test-execution-policy.q9KgOtHV_Z1tTSUP.webp)
:::

## Which venues does 0.4.0 add?

**Bybit, OKX and Coinbase Advanced Trade, until now price sources only, take
spot orders; OpenAlgo brings orders and prices through the brokers it
connects; the Execution Simulator takes paper orders.**

:::matrix

| Venue | Paper orders | Live orders | Gives prices |
| --- | --- | --- | --- |
| Bybit | ✓ [1] | ✓ [1] | ✓ |
| OKX | ✓ [2] | ✓ [2] | ✓ |
| Coinbase Advanced Trade | n/a [3] | ✓ [3] | ✓ |
| OpenAlgo | ✓ [4] | ✓ [4] | ✓ [4] |
| Execution Simulator | ✓ [5] | n/a [5] | ✗ [5] |
| Alpaca, IBKR, Binance, eToro | ✓ | ✓ | ~ [6] |

1. Paper on the Bybit testnet of your region; live keys come from Bybit
   Global. A system-generated HMAC key with read-write access and spot trading
   (the panel's
   [trading setup text](https://github.com/openpitkit/officer/blob/v0.4.0/web/src/i18n/locales/en/trading.json)).
2. Paper uses OKX demo trading with demo keys. A connection needs the key,
   secret, passphrase and the `site` the account is registered on:
   `www.okx.com`, `my.okx.com` (EEA) or `app.okx.com` (US, Australia). Spot cash
   only. For a live connection, OKX expires a key with the trading permission
   and no bound IP address after 14 days of inactivity, so bind the public
   IPv4 address of the machine running Officer. The cost: OKX refuses a request
   from an address the key is not linked to (error `50110`), so a changed
   public IP stops live orders until you link the new one
   ([Trading](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#trading),
   [trading setup text](https://github.com/openpitkit/officer/blob/v0.4.0/web/src/i18n/locales/en/trading.json),
   [OKX API keys](https://www.okx.com/docs-v5/en/#overview-api-key-creation)).
3. Live only: creating a paper connection is refused. A CDP API key with an
   ECDSA (ES256) secret; Ed25519 keys are refused. One key trades one
   portfolio. When history needs an SCA proof token, the order stays pending
   with a diagnostic ([Trading](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#trading)).
4. OpenAlgo in analyzer mode for paper and live mode for live; Officer
   refuses a connection in the other mode. Route `product` `CNC` or `MIS`,
   whole lots, tick-size limit prices, INR, symbols like `NSE:SYMBOL`. Its
   books cover the current trading day only, and semi-auto mode leaves an
   order's outcome unknown. No commission is reported
   ([Trading](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#trading)).
5. Paper only, no keys; it reads prices from another source and gives none
   ([Execution Simulator](https://github.com/openpitkit/officer/blob/v0.4.0/docs/test_trading.md)).
6. Since 0.2.1, as in the [0.3.0 post](/blog/pit-officer-0-3-0/): eToro gives
   no prices.

The route each venue takes for a limit or a market order:
[Trading](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#trading)
at v0.4.0.
:::

## When does Officer warn that an account can reach live?

**When an account's access first spans a paper connection and a live one,
counting its group's grants and disabled connections, Officer raises an alert
naming the account.** Acknowledging it changes nothing; a warning stays
beside the account while the access is mixed. The case it catches: a bot meant
for paper whose account, through a group grant, can now also send live
([Trading](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#trading),
[alerts](https://github.com/openpitkit/officer/blob/v0.4.0/docs/alerts.md)).

:::more[Mixed paper/live access, defined]
**Mixed paper/live access** is an account whose effective access - its own
grants, its group's grants, disabled connections included - covers at least
one paper and one live connection. A send still names its mode, so an order
goes live only through the live route; the alert tells you the account could.
:::

## What must you change when you upgrade?

**Back up, recreate the container on 0.4.0, then check three things:** a
client that reads Officer's verdict must not send on "review"; a script that
writes limits over MCP must move to the new add and update tools; a team with
its own host or panel follows the release notes. REST limit writes keep
working as they were.

:::more[The breaking changes, for each kind of client]

- **Verdict readers.** Any client that reads a verdict or a signed approval
  treats every verdict other than `accept`, `review` included, as "do not
  send", and polls `GET /orders/{id}` for the operator's decision: a
  `pre_trade_accepted` event attested as `review_confirm` or `review_force`
  means approved to send; `cancelled` means do not send
  ([Order review](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#order-review)).
- **MCP limit writes.** `set_limit` is replaced by `add_limit`, which answers
  `limit_exists` on an existing key, and `update_limit`, which answers
  `not_found` when the key is absent.
- **REST limit writes.** `PUT` still creates or replaces the limit at its key;
  on the 0.4.0 image a `PUT` to a missing order-size key answered `200` with
  the new limit, as the
  [API notes](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#adding-and-editing-keyed-limits)
  say. The new `POST` adds only, answering `201`, or `409` `limit_exists` on
  an existing key. An absent `mode` means `reject`, so existing bodies keep
  their meaning; changing a limit's mode takes a delete and an add.
- **Custom hosts and panels.** The host changes and Go 1.26.11 or later, in
  the [release notes](https://github.com/openpitkit/officer/releases/tag/v0.4.0).

:::

:::more[The backup and the commands]
Back up on the Service page: Database, Database backup, Export. Then, from the
[upgrade steps](https://github.com/openpitkit/officer/blob/v0.4.0/docs/quickstart.md#upgrade-officer),
pinned to this version:

```sh
docker pull ghcr.io/openpitkit/officer:0.4.0
docker stop pit-officer
docker rm pit-officer
docker run -d --name pit-officer --restart unless-stopped -p 127.0.0.1:8787:8787 -v pit-officer-data:/data ghcr.io/openpitkit/officer:0.4.0
```

Add the extra settings you passed before, a master key for example, to
`docker run`. When a version changes how it stores data, Officer keeps a copy
of the database in the volume and offers it on the Service page.
:::

## Checklist

- Every review limit has a person watching the panel while bots trade.
- Each review limit holds funds where the order must stay payable, and not
  where other bots must keep trading.
- Every client that reads Officer's verdict sends only on "accept".
- The REST API token is not in any AI agent's environment.
- A daily loss limit has someone who unblocks the account; the reset does not.
- Partial fills and refused sends were tested on the Execution Simulator.
- No paper-only account shows a mixed paper/live warning.
- A backup exists from before the upgrade.

## Where is the code?

:::more[The review scenario in REST: tiered limits, the order, the operator's confirm]
The commands are written for token access, with the API token as a Bearer
header ([Mount points](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#mount-points));
request shapes from
[docs/api.md](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md)
and [httpapi/openapi.yaml](https://github.com/openpitkit/officer/blob/v0.4.0/httpapi/openapi.yaml)
at v0.4.0. The answers come from a local run of the 0.4.0 image in open
access mode, which takes no header, with an Execution Simulator connection
granted to account `desk`, which held 200,000 USD. `$CONNECTION_ID` is that
connection's ID. The run's orders keep their IDs here: `a-breakout-15` with
the hold, `b-breakout-15` without it; the screenshots show `e-breakout-15`,
an identical order sent later in the same run.

The two limits on one target, review at 1 BTC and reject at 2 BTC:

```sh
curl -X POST 'http://127.0.0.1:8787/api/v1/limits/order-size?missingAccount=reject' \
  -H "Authorization: Bearer $PIT_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"scope": "account_underlying_asset", "account": "desk", "asset": "BTC",
       "maxQuantity": "1", "maxNotional": "", "mode": "review_with_hold"}'

curl -X POST 'http://127.0.0.1:8787/api/v1/limits/order-size?missingAccount=reject' \
  -H "Authorization: Bearer $PIT_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"scope": "account_underlying_asset", "account": "desk", "asset": "BTC",
       "maxQuantity": "2", "maxNotional": "", "mode": "reject"}'
```

On fresh keys each `POST` answers `201` with the stored limit under
`orderSizeLimit`. In the run the reject limit was created by a `PUT` to the
missing key, which answered `200`; a `POST` of that same key then answered
`409` `limit_exists`, and the review limit's `POST` answered `201`. The bot's
order:

```sh
curl -X POST 'http://127.0.0.1:8787/api/v1/orders/send-paper' \
  -H "Authorization: Bearer $PIT_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"id": "a-breakout-15", "account": "desk", "baseAsset": "BTC",
       "quoteAsset": "USD", "side": "buy", "amountKind": "quantity",
       "amountValue": "1.5", "price": "100000",
       "destination": {"connection": "'"$CONNECTION_ID"'", "route": {}}}'
```

Officer answers `201` with the review and sends nothing (signature fields
elided):

```json
{
  "reviews": [
    {
      "code": "order_qty_exceeds_limit",
      "scope": "order",
      "policy": "OrderSizeLimitPolicy",
      "reason": "order quantity exceeded",
      "details": "requested 1.5, max allowed: 1",
      "mode": "review_with_hold"
    }
  ],
  "signedApproval": "...",
  "keyId": "...",
  "id": "a-breakout-15",
  "verdict": "review"
}
```

`GET /api/v1/orders/a-breakout-15` then shows `"status": "awaiting_review"` and,
trimmed:

```json
{
  "review": {
    "held": true,
    "marks": [{"code": "order_qty_exceeds_limit", "mode": "review_with_hold"}],
    "lastConfirm": null,
    "destination": {"connection": "...", "venueAccount": "", "route": {}}
  }
}
```

and the account's USD balance reads `"available": "50000.0", "held":
"150000.0"`. With the review limit in `review_without_hold` mode instead,
order `b-breakout-15` showed `held` `false` and all 200,000 USD stayed
available. The operator's decision:

```sh
curl -X POST 'http://127.0.0.1:8787/api/v1/orders/a-breakout-15/review/confirm' \
  -H "Authorization: Bearer $PIT_API_TOKEN"
```

With the hold, the answer is `200` with an `accept` decision, the order
`committed` and `venueSend.status` `acknowledged`. Without the hold, after the
second bot's 0.6 BTC filled, the same call for `b-breakout-15` answered `200`
with the order still `awaiting_review` and:

```json
{
  "decision": {
    "verdict": "reject",
    "reasons": [
      {
        "code": "insufficient_funds",
        "scope": "order",
        "policy": "SpotFundsPolicy",
        "reason": "spot funds insufficient",
        "details": "asset \"USD\": available 140000.0, requested 150000.0"
      }
    ]
  }
}
```

A force of that order answered `409` with "order review is not held".
:::

## What else do people ask?

:::more[Does an order waiting for review expire?]
The Officer 0.4.0 documentation describes no expiry for an order awaiting
review; the operator's moves are confirm, force and cancel. Cancel the
ones you will not decide, because a held review keeps its funds out of every
bot's reach until then.
:::

:::more[Can I approve orders from my phone?]
Not with notifications on Android Chrome, which cannot show the panel's
browser notifications, and not at all by default: the quickstart publishes
the panel on the computer running Officer only. Reaching it from another
device takes two changes, a non-loopback bind and that name or address in
`PIT_OFFICER_ALLOWED_HOSTS`, a security decision the
[configuration reference](https://github.com/openpitkit/officer/blob/v0.4.0/docs/configuration.md#allowed-hosts)
describes.
:::

:::more[Does confirming an order count against my rate limit again?]
Yes. Every confirmation that reaches the pre-trade run spends rate-limit units
again, one that rejects included; a confirm refused before the decision, such
as by a disabled connection, does not reach it. Force does not rerun
pre-trade
([Order review](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#order-review)).
:::

:::more[Can I turn an existing reject limit into a review limit?]
Not in place: the mode is part of the limit's key, so you delete the reject
limit and add one in a review mode. Or keep the reject limit and add a review
limit below it on the same target, the tier this post uses
([Adding and editing keyed limits](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md#adding-and-editing-keyed-limits)).
:::

## Where to go next

- [Pit Officer 0.2.1 and 0.3.0](/blog/pit-officer-0-3-0/): live trading and
  P&L bounds on open positions.
- [Pit Officer 0.1.0](/blog/pit-officer-0-1-0/): the first beta and its order
  path.
- [Multiple trading bots on one account](/blog/multiple-trading-bots-one-account/):
  one admission point for every bot that sends the account's orders through
  Officer.
- [What happens if my trading bot crashes with a position open?](/blog/trading-bot-crashed-open-position/):
  a halt that lives outside the bot.
- [How to handle stale market data in a trading bot's loss limits](/blog/stale-market-data-trading-bot/):
  what a loss limit sees when the feed stops.
- [Stop loss not covering your position after a partial fill](/blog/stop-loss-not-covering-partial-fill/):
  the failure to rehearse on the Execution Simulator.
- Pit Officer: [release notes](https://github.com/openpitkit/officer/releases/tag/v0.4.0),
  [API notes](https://github.com/openpitkit/officer/blob/v0.4.0/docs/api.md),
  [Execution Simulator](https://github.com/openpitkit/officer/blob/v0.4.0/docs/test_trading.md).
- OpenPit SDK: [Review Mode](https://wiki.openpit.dev/Review-Mode/),
  [Spot Funds](https://wiki.openpit.dev/Spot-Funds/),
  [Account Blocking](https://wiki.openpit.dev/Account-Blocking/).
