Konstas Markets Desk: An FX Dealing Room on One Mac
A complete foreign-exchange dealing room that runs on one Mac mini: live two-way prices from eight banks, Reuters-style dealing conversations, client calls, orders, forwards and money markets, a full back office with double-entry accounting, and every formula of the ACI Dealing Certificate.
Interbank FX is learnt on the desk, not in a textbook. The Markets Desk recreates that desk: a market that never stops moving, counterparties who answer in dealer shorthand and refuse stale prices, clients who call with fifteen seconds to quote, and a back office that confirms, settles and books every deal. It was built as a study companion for the ACI Dealing Certificate (exam 002-101) and grew into a full trading simulator with a web dealing room and an old-school terminal.
Everything runs locally. The server listens only on the Mac's loopback address, so nothing on the network or the internet can reach it. The only things it fetches are public reference prices.
Capabilities
- Live interbank market — EUR/USD, GBP/USD, USD/JPY, USD/CHF, AUD/USD, USD/CAD, EUR/GBP and gold, anchored to ECB reference rates and the live gold price, moving continuously.
- Eight competing banks — Each quotes its own two-way price and size, shades prices with its inventory, goes off-line, and refuses stale prices with “last look”.
- Reuters-style dealing — Open a conversation with a bank code, ask “EUR 10”, deal with MINE or YOURS, close with BIBI. Confirmations come back with value date and settlement instructions.
- Clients who call you — Corporates, funds and a central bank ask for two-way prices. Quote within fifteen seconds; tougher clients need tighter prices.
- Orders — AT BEST, limit and stop orders, GTC and GFD validity, one-cancels-other take-profit and stop-loss, immediate-or-cancel.
- Forwards, swaps, money markets — Forward curves from overnight to one year, outright forwards, B/S and S/B FX swaps, deposits and loans with interest accrual.
- Back office — Trade tickets, confirmation matching with random breaks, settlement through nostro accounts, end of day at 17:00 New York.
- Double-entry ledger — Every settlement, revaluation, carry and interest posting is a journal; the trial balance balances in every currency.
- Risk and performance — Positions, average rates, realised and open P&L in USD, position and stop-loss limits, win rate, drawdown, client hit rate.
- Study tools — 46 ACI formula calculators verified against the official sample answers, an exam-practice quiz on live numbers, and more than 100 HELP topics.
- Two front ends — A web dealing room with click-to-deal prices and an amber terminal with candlestick charts and Tab completion, on the same live market.
- Always on — Starts at login, opens both screens, saves its book continuously and backs itself up, encrypted, every night.
The screens
desk command). The top of the screen redraws four times a second; commands are typed at the DEAL> prompt. Shown here: the depth for EUR/USD and the built-in help for MINE.
CHART EUR). One-minute candles in simulated time, drawn with block characters; 5, 15 and 60-minute views are available.
Screenshots are from a demonstration copy of the simulator. All prices, banks, clients and amounts are simulated; the banks are fictional.
Life of a deal
- Price. Eight banks quote two-way prices around the market mid. In a conversation you ask for a price:
EUR 10→1.1203/05. - Deal.
MINEbuys at 1.1205. The bank confirms:TO CONFIRM AT 1.1205 I SELL 10 MIO EUR VAL 13OCT26 · MY USD TO ATLB NY. - Position. The position, average rate and open P&L update at once; limits are checked.
- Ticket. The back office captures a ticket: trade date, value date, both currency amounts.
- Confirmation. The counterparty's confirmation arrives seconds later and is matched. About one in twenty disagrees and becomes an exception.
- End of day. At 17:00 New York, positions are revalued at closing rates, P&L and carry are posted, and the business date rolls forward.
- Settlement. On the value date the two currencies move through the nostro accounts and the ticket is marked settled.
Command reference
Commands are typed at the DEAL> prompt and are not case-sensitive. Amounts are in millions of the first currency (gold in thousands of ounces). Tab completes words, and HELP followed by any word explains it with an example.
Dealing conversations
| Command | What it does |
|---|---|
ATLB | Open a conversation with a bank: ATLB, NRDC, MRDN, HLVT, PCFT, CRWN, SKRA, LBTY, or BRKR for the voice broker. |
EUR 10 | Ask for a two-way price in 10 million. Pair words: EUR, CABLE, YEN, SWISSY, AUSSIE, LOONIE, EURGBP, GOLD. |
MINE · MINE 5 | Buy at the bank's offer, all or part of the size. |
YOURS · YOURS 5 | Sell at the bank's bid. |
NTG | Nothing, no deal. |
BIBI | Close the conversation. |
20/22 | Answer a client who is calling: your bid and offer in pips, or in full as 1.1220/22. |
q 7 20 22 | Answer a specific call when two clients call at once. |
Electronic broker and orders
| Command | What it does |
|---|---|
BUY 5 EUR AT BEST | Buy now at the best offer. Fast key: b eur 5; from one bank: b eur 5 mrdn. |
SELL 5 EUR AT BEST | Sell now at the best bid. Fast key: s eur 5. |
ok | Take the smaller size a bank offered after “only good for 2 MIO”. |
BUY 50 YEN IOC | Immediate or cancel: take the size available now, cancel the rest. |
SELL 5 EUR AT 1.1250 GTC | Limit order, good till cancelled. |
SELL 5 EUR STOP 1.1180 GFD | Stop order, good for the day. |
OCO EUR 1.1250 1.1180 | Take profit and stop loss on the whole position; when one fills, the other is cancelled. Also tp eur 1.1250, sl eur 1.1180. |
ORDERS · CXL 3 | List working orders with their distance in pips; cancel order 3. |
sq eur | Square the whole EUR/USD position at best. |
d eur | Depth: every bank's bid, offer and size. |
Forwards, swaps and money markets
| Command | What it does |
|---|---|
FWD EUR | Forward curve: ON, TN, SN, 1W, 2W, 1M, 2M, 3M, 6M, 9M, 1Y with dates, points and outrights. |
BUY 5 EUR 3M | Outright forward for the 3-month value date. |
SWAP B/S EUR 10 1M | FX swap: buy near, sell far. S/B is the opposite; TN rolls a position. |
MM USD | Deposit and loan rates by tenor (you lend at the bid, borrow at the offer). |
LEND USD 10 1M · BORROW EUR 5 3M | Place a deposit or take a loan; interest accrues each night. |
MMBOOK | Your deposits and loans with accrued interest. |
Book, back office and study
| Command | What it does |
|---|---|
pos · deals | Positions with average and P&L; recent trades with value dates. |
news · tape | Recent headlines; trades between other banks. |
BO · CONF | Back-office overview and exceptions; all tickets and their status. |
MATCH D1010 | Resolve a confirmation break or a failed settlement. |
SETT · NOSTRO | Settlement ladder by value date; cash per currency at each correspondent bank. |
GL · JNL 12 · PNL | Trial balance; latest journals; daily P&L history including carry and interest. |
EOD | Run end of day now (it also runs by itself at 17:00 New York). |
CHART EUR 5 · CHART OFF | Candlestick chart, 1, 5, 15 or 60-minute candles. |
QUIZ then A–D | Exam practice with explanations and a running score. |
PERF | Performance report. |
HELP · HELP OCO | All help topics by group; one topic with usage and example. |
speed 1 · pause · resume | Market speed (1, 5, 10, 30, 60) and freeze. |
HOURS REAL · HOURS ALWAYS | Close at weekends like real FX (Friday 17:00 to Sunday 17:00 New York), or stay open. |
quit | Close the screen; the market keeps running. |
How the market works
Price process
Each currency pair follows a random walk scaled to its typical annual volatility (EUR/USD 7%, USD/JPY 10%, gold 15%) over a 252-day trading year. EUR/GBP is derived from EUR/USD and GBP/USD so the crosses never disagree. Prices are pulled back towards their real reference levels with a half-life of about six simulated hours, more firmly beyond ±3%, so the simulation stays close to the real market over time.
Reference data
Currencies anchor to the European Central Bank's daily reference rates; gold anchors to the live spot price. Both refresh every four hours. Money-market rate levels and forward points are computed from simulated interest rates, labelled as such on every screen.
Banks and liquidity
Eight fictional banks quote around the mid with their own spread and size. A bank that is long shades its prices lower, quotes update at different moments, and a quote the market has moved through is refreshed so the best bid never crosses the best offer. Dealing on a stale price, or for more than the size shown, can be refused with last look.
Events
News shocks (central banks, data releases, intervention, risk-off, the occasional flash crash) jump prices and widen spreads, with a one-hour cooldown per currency. Other banks trade with each other on the tape, and clients call at random with sizes that fit their type.
Reproducibility
Randomness comes from a seeded xoshiro128** generator, the same family as C++'s standard generators, so a session can be replayed from its seed.
Limits
50 million per pair (gold 20,000 oz), 150 million net open position, and a USD 250,000 daily stop-loss, with warnings when breached.
Back office & accounting
Spot FX is off-balance-sheet between trade date and value date. On the value date each deal settles: the currency bought arrives in its nostro, the currency sold leaves it, and each leg is booked against a currency position account so every journal balances in its own currency. End of day revalues open positions at closing mids and posts the unrealised result in USD, reversed the next day; realised results, tom/next carry and interest are posted alongside.
| Account | Meaning |
|---|---|
| 1100 Nostro (per currency) | Cash at the correspondent bank: JPMorgan Chase New York (USD), Deutsche Bank Frankfurt (EUR), Barclays London (GBP), MUFG Tokyo, UBS Zurich, Westpac Sydney, RBC Toronto, loco London for gold. Each is pre-funded. |
| 1200 / 2200 | Money-market deposits placed / deposits taken. |
| 1210 / 2210 | Interest receivable / payable. |
| 1900 FX position | Currency position accounts, the other side of each settlement leg. |
| 1950 Revaluation adjustment | Mark-to-market of open positions at the last close. |
| 1960 P&L clearing | Offset for realised trading results. |
| 3000 Capital | Opening funding of the desk. |
| 4000 / 4100 | FX trading P&L realised / revaluation P&L unrealised. |
| 4200 | FX swap carry from the nightly tom/next roll. |
| 4300 / 4310 | Interest income / interest expense. |
Ticket statuses run captured → matched → settled. A break shows as unmatched; if it is still unmatched on the value date the ticket fails and settles late once resolved. Dates follow market conventions: spot is T+2 (USD/CAD T+1), month tenors use modified-following with the end/end rule, and money markets use ACT/360 or ACT/365 by currency.
Architecture
Mac mini — listens on 127.0.0.1 only
┌────────────────────────────────────────────────────┐
│ server.mjs ── HTTP, event stream, JSON API │
│ │ │
│ sim/engine.mjs ── market, banks, orders, risk │
│ ├── sim/backoffice.mjs tickets · settlement · ledger
│ ├── sim/rates.mjs tenors · points · money markets
│ ├── sim/quiz.mjs exam questions │
│ └── data/sim-state.json the live book │
└───────────▲───────────────▲───────────────▲────────┘
│ │ │
Terminal client Web dealing room Formula desk
(cli/desk.mjs) (/dealing) (46 calculators)
every 4 h ──► ECB reference rates · live gold price
The server is plain Node.js with no third-party packages. The engine ticks four times a second, saves the book every five seconds and on every deal, and pushes a snapshot to every connected screen over a server-sent event stream. Both front ends are thin: they render the snapshot and send commands back as JSON.
| Component | Role |
|---|---|
server.mjs | Static files, the event stream, the JSON API, security headers. |
sim/engine.mjs | Market dynamics, bank quotes, news, clients, conversations, orders, positions, limits, performance. |
sim/backoffice.mjs | Tickets, confirmations, settlement, end of day, ledger, reports. |
sim/rates.mjs | Tenor dates, forward points, forward and money-market tables. |
sim/quiz.mjs · sim/rng.mjs | Exam questions; seeded random numbers. |
cli/desk.mjs · cli/help.mjs | Terminal client; the help topics (over 100). |
public/ | Formula desk, web dealing room, offline service worker, KaTeX for formulas. |
API reference
All routes live under /api/sim on 127.0.0.1:9300. Requests that change anything must be JSON and carry the header X-Desk: 1; a web page from another site cannot send that header, which protects the local server from cross-site requests.
| Route | Purpose |
|---|---|
GET /stream | Server-sent events: a full snapshot about four times a second. |
GET /state | One full snapshot. |
GET /bars?pair=&tf=&n= | OHLC candles in simulated minutes. |
GET /fwd?pair= · GET /mmq?ccy= | Forward curve; money-market rates. |
GET /perf | Performance report. |
GET /bo/{summary,tickets,nostro,ladder,gl,journal,pnl,mm} | Back-office views. |
POST /deal | Deal on a bank's price: pair, side, amount, bank. |
POST /quote | Answer a client call: id, bid, offer. |
POST /chat | Send a conversation line to a bank or the broker. |
POST /order · /protect · /order/cancel | Limit or stop order; take-profit and stop-loss pair; cancel. |
POST /forward · /swap · /mm | Outright forward; FX swap; deposit or loan. |
POST /bo/match · /cancel | Resolve a break; back-office deal cancellation. |
POST /quiz · /quiz/answer | New question; answer it. |
POST /control | pause, resume, speed, hours, eod, reset. |
Operations
- Always on — the server starts automatically at login and opens both screens once the market is up.
- Persistence — the whole book (positions, deals, orders, back office, ledger, price history) is saved continuously and survives restarts.
- Backups — code and the live book are backed up every night, encrypted, off the machine.
- Testing — every change is tested on a separate copy of the simulator, never against the live book.
- Security — loopback-only listener, host-header check, a custom header required for every change, a strict Content-Security-Policy, and no third-party server packages.
Formula desk
Forty-six calculators cover the ACI FMA formula sheet effective 22 June 2026 for the Dealing Certificate (002-101), Operations Certificate (002-201) and Diploma (003-102): spot amounts and cross rates, forward points and outrights, short dates, interpolation, deposits and rollovers, discount instruments and CDs, repo with margin or haircut, forward-forwards, FRAs and single-period swaps, futures, bonds, swaps, options strategies, volatility, VaR and the Basel III ratios. Each shows the formula, an explanation, the working, and can be saved to a blotter. A test script checks the results against every numeric answer in the official sample questions.
Konstas Markets Desk is a training system. Prices are simulated around public reference rates, the banks and clients are fictional, and no real money is involved. ACI and ACI FMA are trademarks of their owners; the formula sheet is referenced for study purposes.