Skip to Content
While25SDK docs
Market data

Live market data

Turn prices on while a module runs, for symbols known only at run time.

A module is its own subscriber, like a chart or a watchlist row. When it starts, While25 takes a subscription per instrument it declared (@on.tick, @on.bar) that lasts exactly as long as the module runs — whoever else holds the same instrument — and stopping the module releases them. What While25 cannot give (over the plan's limit on live instruments, SUB_CAP; no vendor for the key, NO_VENUE; a bar interval or session it cannot serve, BAD_INTERVAL / BAD_HOURS) does not stop the module: it runs with the keys it did get, and the refusal shows as a warning on it (Live strategies shows it as its last error).

while25.subscribe("EQ:US:QQQ")           # ask for one more at runtime; True, or
                                        # SubscriptionError with the refusal code
while25.subscribe("EQ:US:QQQ", on_tick=self.on_qqq)   # ...and call on_qqq per tick
while25.unsubscribe("EQ:US:QQQ")         # its prices, and the calls, end together
while25.market.is_open("EQ:US:SPY")      # True / False / None (cannot be placed)

A key turned on at runtime gets its live prices exactly as a declared one does. Without on_tick= nothing is called for them — quote(key) reads the latest. With it, every tick calls that method, as an @on.tick line would:

  • on_tick= takes one of the strategy's own methods (self.on_bank). A plain function, a lambda or another object's method raises TypeError, and nothing is subscribed: the tick calls its handler by name on the strategy.
  • Subscribing the same key again with another method replaces the first. unsubscribe(key), the strategy's stop or a halt ends the calls.
  • A key both declared in an @on.tick line and named at runtime with the same method is called once per tick, never twice.
  • It works from on_start (the usual place for a symbol a setting named), from any handler, and from run().
  • SubscriptionError is raised only for what While25 refuses at once: code NOT_RUNNING (the module is stopping or stopped) or BAD_REQUEST (not a key). While25's own refusals — over the plan's limit, no vendor for the key — come back as a warning on the module (Live strategies shows it as its last error) while it keeps running with the keys it did get; the call itself returned True. False means the platform could not be reached.

Every tick and quote carries as_of — While25's arrival time — so a script can tell a fresh price from a stale one instead of guessing. A quote's open, high, low, prev_close and volume are None until the engine has actually seen them (a vendor that sends them as separate ticks leaves each unknown until its own tick lands) — never a 0 standing in for a price. historical(..., start=) is honoured back to the history floor (2012); a clamped start is logged as a warning.