Skip to main content

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/quotes and a get/search with symbols take symbols, a comma list of items, each kind:text (one is a list of one; symbol is 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.0 or continuous:@ES, parent:ES.FUT, spread:buy:1:<OCC>,sell:1:<OCC>, series:GDP. A search row's class and symbol make its item. A bare symbol is a 400 naming its kind, and class beside symbols is a 400: class names the class of a symbol-less read (a get/search with text: absent = every class; with none, equity, or future with contracts). Every answer but a get/search with no text (JSON {rows}) and a hold read 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.missing an entry {product, symbol, timeframe, error, status} for each symbol not served beside those that were, meta.source where each came from; meta also carries timeframe, adjustment and dataset_id on bars. provider (a provider or an account handle) pins the source; else the class's link.prefer.data list leads in its order, then every other linked provider that serves the ask. Every answer names its provider.
  • When:
    • A span: from/to (UTC seconds or a YYYY-MM-DD New York date; to absent is now) on bars, and on quotes with a from, which is bid/ask history. At most limit rows (default 5,000, max 10,000): a clamped page carries meta.cursor, and the same tool with cursor alone reads the next page (once, within 60 s; else read the span again from the last start_dt). An answer past 24,000 bytes is fitted: a span is read again at the limit that fits, named in meta.fit (a tail pages back with to), and anything still over is cut into pages; follow meta.cursor alone until it is absent. A quotes span answers a row per tick, off the vendor every read: ticks are never stored.
    • As of: at (UTC seconds; a YYYY-MM-DD date is its start, New York midnight, UTC midnight on daily bars) on a bars span answers only rows knowable by then, a bar at its end, or its session's close where that is sooner (to past it is 400 lookahead; no to reads to at). A backtest-style read is at plus store_only: true.
    • Now: quotes asks the vendor every read; search answers from listings then contracts, asking the vendor only when no row matches the text exactly. Every other answer now is stored and reused unless refresh: true.
    • Live: hold: <ms> (100 to 60,000) on quotes attaches to Taji's one stream for the symbols and answers at limit rows or ms; session keeps an equity's ticks in that session. Live rows are never stored.

Bars or quotes​

  • get/bars for candles and anything compared with history (timeframe 1m to M). A running session's bars are answered but never stored; knowable is the instant each bar may be read. A spread: item is one item of symbols, its legs' net.
  • A chart's bars on /ws/market come with status frames; 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/bars is composed from every linked provider that serves its class: meta.segments and a chart's status.segments name each provider's span {provider, from_utc, to_utc}; a provider pin answers one provider's bars with none. Where two providers' bars cannot be joined the read is 409 seam {providers, at, reason}: ask again from at, or pin one provider.
  • get/quotes for 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_ts null where the vendor dates no book, its age unknown; last_exchange and last_conditions (a list, empty where none) the last trade's; halted and session the vendor's own word, null where it says none; the day figures the kernel's, never computed by you), a figure the vendor lacks null. A from read answers a row per quote tick on the same columns, a hold read 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 forming D bar (get/bars). A spread: item answers a row per leg: the leg set's net (net_bid, net_ask, net_mid, net_ts) and provider and feed on 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), quotes and search. It ranks after every linked provider, so linking one moves its reads to that provider; provider still pins the source, and a link.prefer.data list puts its sources first.
  • It is switched off with the setting data.yahoo (false), EDGAR (which serves no tool here) with data.edgar: it then answers nothing, as if unlinked.
  • Truth: read read/data/coverage on 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 in meta.source.
  • Before choosing a provider or a span: read read/data/coverage (who serves what per class; a null cell is unmeasured, never a no), data/coverage/<class> (how far back), data/freshness (how late live data arrives), data/datasets and data/cache (what this device holds).
  • commit verb/data/dump drops one dataset's stored rows and coverage (a dataset_id off data/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 409 fetch_first with gaps (each {product, provider, symbol, timeframe, from, to}) and quote_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 adjustment asked, 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 is not_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 501 not_served, skipped naming each and why. Every refusal is one body {error: <code>, reason, …}; describe {route}'s refusals names 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/bars and get/quotes take 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. A hold read answers rows: [] when nothing arrived in the window, a closed market included. data/coverage says what is served.