0018 · Cash per currency, and a conversion the owner signs
Status: accepted, 2026-09-27. The code is src/currency/book.ts (the book, valuation, the no-margin check) and
src/currency/fx.ts (the conversion ticket), with the check in src/gateway/gateway.ts and the events
fx.issued, fx.signed and fx.converted in src/record/schemas.ts. Tests: test/currency.test.ts. Reference:
docs/ibkr.md.
Context
The book held one cash figure in euros. A dollar buy was converted at the fill's rate, silently, on paper, and live orders outside the euro were refused (0016, decision 8). That hides two things an owner needs to see: a conversion is a trade with its own rate and commission, and a fund with no cash in a currency is borrowing when it buys in it. The fund never borrows (L-CASH, and IBKR's ledger check at send).
Decision
- The book holds cash per currency.
cashkeeps its meaning: all cash, in euros, at the rates it was booked at. A currency account holds an amount and the euros it was booked at. Euro cash iscashless the booked euros of the accounts. An account opens only with a signed conversion into its currency. - A conversion is its own signed ticket. The ticket names what is sold and bought, the rate, the estimated conversion commission (none under the flat fee model, IBKR's 0.2 bp with a USD 2 minimum under the IBKR models) and an expiry of 15 minutes. Its hash is what the owner signs, with the same key and message form as an order. At signing, the kill switch, the fund's cash and the rate are checked again; a rate more than 0.5% from the ticket's issues a new ticket and refuses the signature.
- No margin, per currency. Once any account exists, and always when live, a buy is signed only if the cash it is paid from covers the order at its limit plus the fee estimate, less what orders already signed and not yet filled will take. A buy in a currency with an account is paid from that account; the difference between the account's booked rate and the fill's rate is realised currency gain or loss. Sales in such a currency keep their proceeds in it.
- Valuation at recorded rates. Each account is valued at the last rate recorded for it (from a fill or a conversion) and flagged when that rate is older than 72 hours.
- Reconciliation compares cash per currency. Live, IBKR's ledger is read per currency; a currency where the ledger holds less than the book, or is below zero, is recorded as a cash break with the reconciliation. It is shown and not halted on: the send-time ledger check already refuses an order the account cannot pay for.
- Live conversions are refused. Sending a conversion to IBKR is not built. A live conversion ticket is refused, and so, live, is a buy in any currency but the euro.
Alternatives
- Convert inside the order (IBKR can auto-convert). Rejected: the owner would sign a stock order and get a currency trade with it, at a rate and commission not on the ticket.
- One cash figure with a per-currency view. Rejected: the no-margin check needs the cash in the order's currency, and a view cannot hold what was not booked.
- Revalue currency cash into
cashdaily. Rejected: it would move the book's cash without an event. The valuation is computed on the screen; only a fill or a conversion moves money in the Record.
Consequences
- A book that never converts behaves exactly as before: no accounts, the same cash, the same projection hash, and no new refusal on paper.
- A conversion moves
book_version, so a verdict issued before it is re-checked, as after any fill. - On paper, a buy in a currency with no account is still converted at the fill's rate, as before, and paid from euros.
- Live, only euro orders can be sent until the live conversion leg exists.
Falsifier
A folded Record whose cash per currency differs from what a reader computes from its fx.converted and
fill.recorded events, or a signed buy that leaves any account below zero.
Validated by
No spike; test/currency.test.ts (book arithmetic, valuation, the ticket's refusals, the no-margin check, cash
reconciliation) and the unchanged suite.