Stream live quotes over the wire
This script opens your own Taji's market socket, asks for live quotes of SPY, and prints the first four frames that come back: a greeting, then rows of quotes and a status for SPY, in the order the kernel has them.
You need a running Taji, and Python with websockets 14 or later and pyarrow (pip install websockets pyarrow). Without a linked brokerage the quotes are Yahoo's: free, and labelled by Yahoo as delayed.
Run the script:
STATE="$HOME/Library/Application Support/Taji"
PORT=$(cat "$STATE/wire-port") TOKEN=$(cat "$STATE/wire-token") python3 - <<'PY'
import json, os
from websockets.sync.client import connect
import pyarrow as pa
ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY"], "session": "regular"}
with connect(f"ws://127.0.0.1:{os.environ['PORT']}/ws/market", additional_headers={"x-taji-token": os.environ["TOKEN"]}) as ws:
ws.send(json.dumps(ask))
for _ in range(4):
frame = ws.recv()
n = int.from_bytes(frame[:4], "little")
print(json.loads(frame[4:4 + n]))
if len(frame) > 4 + n:
print(pa.ipc.open_stream(frame[4 + n:]).read_all().to_pylist())
PY
STATE,wire-port,wire-tokenare as in Read bars over the wire with curl: the state dir, the port the kernel listens on, and this launch's token./ws/marketis the wire's market-data WebSocket. It takes the token in thex-taji-tokenheader of the upgrade request, so no auth message follows; a wrong token is a 401 before the socket opens. A socket refuses a foreignOrigin; this script sends none.askis the one message you send, as text JSON.productisquotes;symbolsare items, eachkind:text;idis your own name for the subscription, and every frame about it carries it back. An equity's quotes stream requiressession, which keeps the ticks whose time falls in that session:regularis 09:30 to 16:00 ET. Without it the answer is anerrorframe, 400bad_ask.nis the frame's layout. Every frame the kernel sends is binary: a 4-byte little-endian header length, the header as JSON, then, only where the frame has rows, an Arrow IPC stream of one batch.frame[4:4 + n]is the header, always decoded: itstypesays what the frame is, andseqcounts the frames on this socket from 0.frame[4 + n:]is the Arrow stream, decoded bypyarrowto rows when the frame has any. The prices arrive asDecimal128: Python prints them asDecimal, and the harness's JSON below as numbers.
The same frames as the harness decoded them, each {"header", "rows"?}:
[
{
"header": {
"type": "hello",
"seq": 0
}
},
{
"header": {
"type": "rows",
"id": "q1",
"history": false,
"seq": 1
},
"rows": [
{
"symbol": "SPY",
"ts": "2026-12-04T18:58:42.315433+00:00",
"ts_init": 1796410722315433000,
"provider": "samplefeed",
"delayed": false,
"halted": null,
"session": null,
"bid": 142.3,
"ask": 142.32,
"last": null,
"bid_size": null,
"ask_size": null,
"book_ts": null,
"last_ts": null,
"last_exchange": null,
"last_conditions": [],
"prev_close": 142.62,
"change": null,
"change_pct": null,
"session_close": null,
"session_change": null,
"session_change_pct": null,
"market_session": "regular",
"next_session": "post",
"next_at": "2026-12-04T21:00:00+00:00"
}
]
},
{
"header": {
"type": "status",
"id": "q1",
"symbol": "equity:SPY",
"provider": "samplefeed",
"liveness": "live",
"delay_s": null,
"last_tick_utc": null,
"session": null,
"adjusted": null,
"prev_close": "142.62",
"error": null,
"code": null,
"seq": 2
}
},
{
"header": {
"type": "rows",
"id": "q1",
"history": false,
"seq": 3
},
"rows": [
{
"symbol": "SPY",
"ts": "2026-12-04T18:58:43.317684+00:00",
"ts_init": 1796410723317684000,
"provider": "samplefeed",
"delayed": false,
"halted": null,
"session": null,
"bid": 142.3,
"ask": 142.32,
"last": null,
"bid_size": null,
"ask_size": null,
"book_ts": null,
"last_ts": null,
"last_exchange": null,
"last_conditions": [],
"prev_close": 142.62,
"change": null,
"change_pct": null,
"session_close": null,
"session_change": null,
"session_change_pct": null,
"market_session": "regular",
"next_session": "post",
"next_at": "2026-12-04T21:00:00+00:00"
}
]
}
]
Captured 2026-12-04 on a headless kernel reading made-up quotes for SPY.
hello,seq0, is the kernel greeting the socket. It carries onlyseq.statussays how the subscription for one symbol stands, and comes again whenever that changes. Hereproviderissamplefeed, the capture's made-up source, andlivenessislive. A feed that arrives late readsdelayedwithdelay_sset; this one readslive, anddelay_sisnull.prev_closeis yesterday's close as a decimal string,"142.62", ornulluntil the kernel has read it.session,adjustedandlast_tick_utcarenullhere.rowscarries the quotes,historyfalse: a quotes stream has no history, only the newest row for each symbol since the last frame, then another frame on each later tick. These are SPY's, rows ofGET /get/quotes' schema.bidandaskare the book's top, 142.30 and 142.32;last, the print, isnullbecause this source streams a book and no prints (Yahoo's carries prints only, so therebidandaskarenullinstead).changeandchange_pct,lastlessprev_closeand that overprev_closein percent, arenullwith it.market_sessionisregular, andnext_sessionispostatnext_at, 21:00 UTC, the close at 16:00 ET.delayedisfalse. A vendor may label its feed late (Yahoo says 15 minutes), but Taji does not take that word: it setsdelayedfrom each tick,truewhen the tick's own time is over 60 s behind when Taji received it (ts_init, in nanoseconds). Read this flag, not the vendor's label, to know whether a price is current.
Change it
Ask for two symbols. The kernel sends a status for each and one rows frame with both rows, so read six frames to get past them:
-ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY"], "session": "regular"}
+ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY", "equity:QQQ"], "session": "regular"}
- for _ in range(4):
+ for _ in range(6):
Keep the pre- and post-market ticks as well. Outside 09:30 to 16:00 ET, a regular stream waits for a tick that is in the session, so use extended:
-ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY"], "session": "regular"}
+ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY"], "session": "extended"}
Read the quotes once instead of subscribing. A get message takes any GET /get/<product> product with its query string and answers one rows frame, cursor null, so read two frames, the greeting and the answer:
-ask = {"type": "stream", "id": "q1", "product": "quotes", "symbols": ["equity:SPY"], "session": "regular"}
+ask = {"type": "get", "id": "g1", "product": "quotes", "query": "symbols=equity:SPY"}
Next
- Wire: listeners, token scopes, refusals, and every WebSocket feed.
- Read bars over the wire with curl: the same token on a plain HTTP read.
- Configuration: the state dir and every file in it.