[request.* and input.*]

Multi-symbol/timeframe requests, fundamental mocks, footprint, and input parameter resolution.

request.* and input.*

Abstract

Two namespaces couple scripts to the host environment: input.* declares parameters (with defaults and UI metadata), and request.* pulls data from other symbols, timeframes, or fundamental/economic sources. PYNE implements both as builtins with explicit extension points—data_feed, data_provider, and _input_overrides—so the same script can run offline with mocks or online with real market data.

Conceptual model

Interface surface

input.* (InputBuiltinsMixin)

BuiltinPurpose
inputGeneric defval + title/tooltip/inline/group/confirm/active
input.bool / int / float / string / colorTyped scalars
input.price / source / time / timeframe / session / symbolDomain inputs
input.enum / input.text_areaEnumerations and multiline text

Runtime value: each call returns the resolved value (override if title matches, else default). Metadata is appended to _input_declarations for settings panels and LSP-adjacent hosts.

Overrides live on the evaluator as _input_overrides: dict[title, value].

request.* (RequestBuiltinsMixin)

BuiltinRole
request.securityOther symbol / timeframe expression
request.security_lower_tfLower-TF array expansion
request.dividends / earnings / splitsCorporate actions
request.financial / economic / quandlFundamentals / external series
request.currency_rateFX conversion helper
request.seedDeterministic pseudo-series
request.footprintVolume footprint object (v6 surface)

request.security(symbol, timeframe, expression, …)

Resolution order (simplified):

  1. Normalize symbol (series → last element) and timeframe.
  2. Try data_feed.fetch_latest_ohlcv / ticker.
  3. Try data_provider.fetch.
  4. Fall back to mock synthetic prices so evaluation continues offline.

Expression may be a simple series name (close) or more complex forms depending on handler paths; production hosts should supply real data for multi-asset accuracy.

Footprint (FootprintBuiltinsMixin)

Types Footprint and VolumeRow expose buy/sell volume, delta, VAH/VAL/POC rows, and per-row imbalance helpers—aligned with the v6 footprint surface inventory.

Internals

PathRole
src/pynescript/ast/evaluator/builtins/input.pyInput handlers + declarations
src/pynescript/ast/evaluator/builtins/request.pyrequest.* + footprint types
src/pynescript/ast/evaluator/base.pyInjects data_feed / data_provider into context
backend/runtime.pyresolve_request_sources wiring from chart bars
tests/test_request_data_feed.py, test_datafeed*.pyFeed contracts

Invariants & edge cases

  1. Inputs are pure values at runtime. Titles matter only for override keys and UI metadata—not for Pine type identity.
  2. Mocks are intentional. Silent mock fallback is not a hard error; production must validate feed wiring.
  3. Dynamic symbols. List/series symbols resolve to the latest element—supports loops constructing ticker ids.
  4. Lower TF. request.security_lower_tf returns array-like structures; length scales with simulated lower-TF density when mocking.
  5. Compile mode. input.* defaults lower into numeric compile; live request.security is interpret-centric—do not assume multi-asset compile coverage.

Worked examples

Parameterized length

//@version=5
indicator("len")
len = input.int(14, "Length", minval=1)
plot(ta.sma(close, len))

Host:

ev._input_overrides = {"Length": 21}

Multi-timeframe close

htf = request.security(syminfo.tickerid, "D", close)
plot(htf)

With Runtime.run(..., data_provider=...), daily closes come from the provider; without it, mocks apply.

Failure modes

SymptomCause
Always ~100 mock pricesNo feed/provider; or fetch exceptions swallowed
Input override ignoredTitle string mismatch (including empty title)
Footprint fields zerorequest.footprint without configured footprint data
Lookahead surprisesHost data alignment / gaps—not automatic TV replay guarantees

See also