Reading market data
Every product is read {route: "get/<product>", query}; describe {under: "get"} lists them, describe {route: "get/bars"} one's words. read/calendar/<class> lists session days. A plugin's own products are listed at GET /read/plugins (each row's products: its word, columns and spans) and read as GET /get/<id>.<name>?symbols=…&from=…&to=…, streamed as any tick product on /ws/market.
What, which, when
- Which:
get/bars,get/quotesand aget/searchwithsymbolstakesymbols, a comma list of items, eachkind:text(one is a list of one;symbolis refused everywhere):equity:AAPL,index:$SPX,future:ESZ26(a dated future spells its two-digit year),option:<OCC>,crypto:BTC/USD,future_option,forex,continuous:ES.c.0orcontinuous:@ES,parent:ES.FUT,spread:buy:1:<OCC>,sell:1:<OCC>,series:GDP. A search row'sclassandsymbolmake its item. A bare symbol is a 400 naming its kind, andclassbesidesymbolsis a 400:classnames the class of a symbol-less read (aget/searchwith text: absent = every class; with none, equity, or future withcontracts). Every answer but aget/searchwith no text (JSON{rows}) and aholdread is{meta, rows}: the symbols' rows in the asked order, instants RFC 3339 UTC, prices, sizes and volumes exact decimal strings ("187.2", never a number),meta.missingan entry{product, symbol, timeframe, error, status}for each symbol not served beside those that were,meta.sourcewhere each came from;metaalso carriestimeframe,adjustmentanddataset_idon bars.provider(a provider or an account handle) pins the source; else the class'slink.prefer.datalist leads in its order, then every other linked provider that serves the ask. Every answer names itsprovider. - When:
- A span:
from/to(UTC seconds or aYYYY-MM-DDNew York date;toabsent is now) onbars, and onquoteswith afrom, which is bid/ask history. At mostlimitrows (default 5,000, max 10,000): a clamped page carriesmeta.cursor, and the same tool withcursoralone reads the next page (once, within 60 s; else read the span again from the laststart_dt). An answer past 24,000 bytes is fitted: a span is read again at thelimitthat fits, named inmeta.fit(a tail pages back withto), and anything still over is cut into pages; followmeta.cursoralone until it is absent. Aquotesspan answers a row per tick, off the vendor every read: ticks are never stored. - As of:
at(UTC seconds; aYYYY-MM-DDdate is its start, New York midnight, UTC midnight on daily bars) on abarsspan answers only rows knowable by then, a bar at its end, or its session's close where that is sooner (topast it is 400lookahead; notoreads toat). A backtest-style read isatplusstore_only: true. - Now:
quotesasks the vendor every read;searchanswers fromlistingsthencontracts, asking the vendor only when no row matches the text exactly. Every other answer now is stored and reused unlessrefresh: true. - Live:
hold: <ms>(100 to 60,000) onquotesattaches to Taji's one stream for the symbols and answers atlimitrows orms;sessionkeeps an equity's ticks in that session. Live rows are never stored.
- A span:
Bars or quotes
get/barsfor candles and anything compared with history (timeframe1mtoM). A running session's bars are answered but never stored;knowableis the instant each bar may be read. Aspread:item is one item ofsymbols, its legs' net.- A chart's bars on
/ws/marketcome withstatusframes;status.gaps([[from_utc, to_utc]], absent when none) names the spans inside its history no source vouches for, each asked to fill once per stream span and once its provider holds it. An untraded minute inside a vouched span has no bar and is no gap. - An unpinned
get/barsis composed from every linked provider that serves its class:meta.segmentsand a chart'sstatus.segmentsname each provider's span{provider, from_utc, to_utc}; aproviderpin answers one provider's bars with none. Where two providers' bars cannot be joined the read is 409seam{providers, at, reason}: ask again fromat, or pin oneprovider. get/quotesfor the state now: the last quote and trade of each symbol as a row{symbol, provider, ts, ts_init, bid, ask, last, bid_size, ask_size, book_ts, last_ts, last_exchange, last_conditions, delayed, halted, session, prev_close, change, change_pct, session_close, session_change, session_change_pct, market_session, next_session, next_at}(book_tsnullwhere the vendor dates no book, its age unknown;last_exchangeandlast_conditions(a list, empty where none) the last trade's;haltedandsessionthe vendor's own word,nullwhere it says none; the day figures the kernel's, never computed by you), a figure the vendor lacksnull. Afromread answers a row per quote tick on the same columns, aholdread a row per frame, its symbol's newest quote beside its newest trade. Today's session and the previous close are bars: the previous close is the close of the bar before the formingDbar (get/bars). Aspread:item answers a row per leg: the leg set's net (net_bid,net_ask,net_mid,net_ts) andproviderandfeedon each, beside the leg (instrument,side,ratio) and its chain row.
Before anything is linked
- Yahoo answers on a new install: 1m-and-up
bars(an option's too),quotesandsearch. It ranks after every linked provider, so linking one moves its reads to that provider;providerstill pins the source, and alink.prefer.datalist puts its sources first. - It is switched off with the setting
data.yahoo(false), EDGAR (which serves no tool here) withdata.edgar: it then answers nothing, as if unlinked. - Truth:
read read/data/coverageon the running kernel: what answers, per class, and what Yahoo gives and its limits.
Cache first
- Every answer but a tick span is stored under the provider that gave it. A repeat is served from the store, and a span past what is held fetches only the rest. The
{meta, rows}answers say so inmeta.source. - Before choosing a provider or a span:
read read/data/coverage(who serves what per class; anullcell is unmeasured, never a no),data/coverage/<class>(how far back),data/freshness(how late live data arrives),data/datasetsanddata/cache(what this device holds). commit verb/data/dumpdrops one dataset's stored rows and coverage (adataset_idoffdata/datasets); its pulls and cost stay, and the next read of the range fetches and pays again. Ask the user first.- A read never buys. A metered provider (Databento), or any provider under
store_only: true, answers 409fetch_firstwithgaps(each{product, provider, symbol, timeframe, from, to}) andquote_usd, what buying them costs.commit {route: "fetch", body: {…, dry_run: true}}prices it; buy only on the user's yes; it is held to the data budget. - An answer's equity bars are on one basis: the
adjustmentasked, else a pinned provider's own, else split-spinoff; a symbol held only on another basis is a gap, and a pinned provider that does not state the basis isnot_served(Databento serves raw alone, Massive raw and split); unpinned, where no linked provider of the class serves it (a basis, an interval, reach, a session or a word it lacks), the read is 501not_served,skippednaming each and why. Every refusal is one body{error: <code>, reason, …};describe {route}'srefusalsnames a route's codes.
Anti-patterns
- Building candles from quotes. A quote samples state and misses the prints between updates. Read
get/bars; coarser timeframes come from cached 1m, 5m, 30m, 1h, 4h or D bars. - One call per symbol.
get/barsandget/quotestake the whole comma list in one call. - Reading an empty answer as "no data". No provider serving the ask is 501
not_served, naming each linked provider passed over and why. Aholdread answersrows: []when nothing arrived in the window, a closed market included.data/coveragesays what is served.