Accounts & sessions API
Create accounts, open sessions, advance the clock, and read financials.
A trading account is a persistent, named, cash-only container with a continuous balance that carries day to day. Each account has a fixed engine, and you trade it one day at a time through sessions. See Accounts & trading days for the concepts. All endpoints require authentication.
Engines
| Engine | What it does |
|---|---|
historical |
An editable replay ledger: open any past recorded day, trade it with a clock you control, and settle it into the carried balance. Editing an earlier day re-threads all later days. |
live_sim |
Paper-trades today's real session against the live tick stream. Past sessions are frozen. |
broker_* |
broker_ibkr, broker_schwab, broker_tastytrade, broker_tradestation, broker_tradier, broker_etrade — reserved but not yet available. Creating one returns 409 engine_not_available. |
An account also has a type — manual (ships now) or bot (not yet available). Trading is 0DTE SPX-index options only: cash-only, no equities, no overnight positions, so the carried balance is a single number.
Account endpoints
| Method | Path | Purpose |
|---|---|---|
GET |
/accounts |
List your accounts |
POST |
/accounts |
Create an account |
GET |
/accounts/{id} |
Get one account |
PATCH |
/accounts/{id} |
Rename, archive, or edit starting capital |
DELETE |
/accounts/{id} |
Delete an account |
Create an account
curl -s https://api.0dtespx.com/accounts \
-X POST -H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{
"name": "Iron condors",
"engine": "historical",
"starting_capital": 100000,
"description": "Defined-risk study account"
}'
starting_capital ranges from 1000 to 10000000. name is required (≤ 80 chars) and must be unique among your active accounts. engine is fixed for the account's life. type defaults to manual. The response is the account object:
{
"id": "f3c88e1a-…",
"name": "Iron condors",
"description": "Defined-risk study account",
"engine": "historical",
"type": "manual",
"starting_capital": "100000",
"cash_balance": "100000",
"current_value": "100000",
"status": "active",
"created_at": "2026-06-21T12:00:00Z"
}
cash_balanceis the settled carry — it never folds in unsettled intraday P&L.current_valueis the live net-liquidation value when a session is open on the account, otherwise it equalscash_balance.
Creating a broker_* account returns 409 engine_not_available; a bot type returns 400.
Edit or archive an account
PATCH accepts any of name, description, status, starting_capital — only the fields you send are applied.
# rename
curl -s -X PATCH https://api.0dtespx.com/accounts/$ACCT \
-H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"Condors — 2025"}'
# archive (blocked while a session is open)
curl -s -X PATCH https://api.0dtespx.com/accounts/$ACCT \
-H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{"status":"archived"}'
starting_capital is the ledger's day-0 input. On a historical account it is editable any time and re-threads the ledger — the new genesis ripples forward to every settled day's carried balance and the account's cash_balance. On a live_sim account it is immutable once the account has traded (409 capital_immutable). Either way it cannot change while a session is open (409 session_open).
DELETE /accounts/{id} soft-deletes the account and returns 204. It is blocked while a session is open (409 session_open) — cash carry is driven by settlement, never by deletion.
Session endpoints
A session is one trading day under an account. Orders, positions, transactions, and history all live under a session.
| Method | Path | Purpose |
|---|---|---|
GET |
/accounts/{id}/sessions |
List trading days (newest first) |
GET |
/accounts/{id}/sessions/current |
The open live session, or null |
GET |
/accounts/{id}/sessions/head |
Default landing session, or null |
GET |
/accounts/{id}/sessions/{sid} |
Get one session |
POST |
/accounts/{id}/sessions |
Open (or re-open) a session |
PATCH |
/accounts/{id}/sessions/{sid} |
Advance/rewind the replay clock (historical) |
DELETE |
/accounts/{id}/sessions/{sid} |
Delete a session |
GET |
/accounts/{id}/sessions/{sid}/history |
Per-second financial history |
/current is for live / broker accounts — a historical account has no "current" concept and returns 404; use /head for those (it returns the open day if any, else the latest settled day).
Open a session
The server dispatches by the account's engine:
# historical — pick a past recorded date
curl -s https://api.0dtespx.com/accounts/$ACCT/sessions \
-X POST -H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{"date":"2025-01-15"}'
# live_sim — empty body; the date is implicitly today
curl -s https://api.0dtespx.com/accounts/$ACCT/sessions \
-X POST -H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{}'
- Historical —
datemust be a past recorded date. The day opens at the market open (9:30 AM ET) with the carried cash balance. Re-opening a day that is already open returns it as-is (200, idempotent); re-opening a previously settled day re-opens it for editing. A new day must be at or after the account's latest day (409 insert_earlier). - Live (
live_sim) — opens today's session at the latest tick with the carried cash balance, gated on market hours and fresh recorder ticks (400if the market is closed or live data is unavailable). Re-requesting today's session while it is open returns it (200). - Broker engines →
409 engine_not_available.
The response is the session object:
{
"id": "9a1b…",
"account_id": "f3c88e1a-…",
"date": "2025-01-15",
"mode": "historical",
"opening_balance": "100000",
"starting_capital": "100000",
"status": "open",
"ended": false,
"time": "2025-01-15T14:30:00Z",
"start_time": "2025-01-15T14:30:00Z",
"end_time": "2025-01-15T21:00:00Z",
"available_buying_power": "100000",
"net_liquidation_value": "100000",
"unrealized_profit_loss": "0",
"realized_profit_loss": "0",
"profit_loss": "0"
}
modeishistoricalorlive, stamped from the account's engine.opening_balanceis the carried cash the day opened with;starting_capitalmirrors it for wire continuity (net_liquidation_value = starting_capital + intraday P&L).statusis the authoritative lifecycle field —open,settled, orabandoned.endedis a convenience flag that istrueonce the day has settled (status == settled).- A settled session also carries
closing_balance(the cash it settled to, carried into the account) andsettled_at.
The full object also breaks financials out into equities vs equity-options components (all zero for SPX-only trading).
Advance the clock (historical)
A fresh historical session is parked at start_time. Move the clock with PATCH:
curl -s https://api.0dtespx.com/accounts/$ACCT/sessions/$SID \
-X PATCH -H "Authorization: $TOKEN" -H 'Content-Type: application/json' \
-d '{"time":"2025-01-15T17:00:00Z"}'
The response is the same shape, with time filled in and all financials recomputed at the new moment. time must satisfy start_time ≤ time ≤ end_time, or you get 400. Moving time is read-only — it recomputes positions, delta, P&L, and buying power from existing trades; it never writes orders or transactions. Setting it backward reverts not-yet-filled orders to pending and hides later trades; rewinding a settled day back before the close re-opens it for editing.
Setting the clock to end_time (the 4:00 PM ET close) finalizes the day: it settles, status becomes settled (ended flips to true), and the closing balance carries into the account's cash_balance (re-threading the ledger forward).
PATCH on a live session returns 409 — its clock is the real clock.
Delete a session
curl -s -X DELETE https://api.0dtespx.com/accounts/$ACCT/sessions/$SID -H "Authorization: $TOKEN"
- Historical — deletes the day and its trades, and re-threads any downstream days. Returns
204. - Live — a session that has traded cannot be deleted (
409 session_traded; it settles at the close, so cash carry is never driven by deletion). A live session with no orders is abandoned and the day's slot is freed (204).
Per-second history
curl -s "https://api.0dtespx.com/accounts/$ACCT/sessions/$SID/history?interval=5" \
-H "Authorization: $TOKEN"
Returns an array of per-second snapshots (net liquidation value, P&L, buying power, fees, …) for charting. Sampled at 1-second resolution; pass ?interval=<seconds> to down-sample. History is recomputed and stored whenever you create or delete an order; advancing the clock alone doesn't change it.
Next: place orders and read positions. For today's real-time session, see live trading.