A module is a class; the base class decides its kind. The folders are what the runtime re-registers at every start: indicators/, strategies/, monitors/, apps/.
indicators/zscore.py
# indicators/zscore.py
import while25
from while25 import Indicator, Plot, Level
from while25.inputs import Int
class ZScore(Indicator):
id = "zscore"
label = "Z-Score"
overlay = False # its own pane, below price
inputs = [Int("length", default=20, minimum=2, maximum=500)]
plots = [Plot("z", color="#e0a34a")]
levels = [Level(2.0, style="dashed"), Level(-2.0, style="dashed")]
warmup = lambda params: int(params.get("length", 20))
def compute(self, ctx):
n = int(while25.params.get("length", 20))
rows = while25.bars # the chart's own series, oldest first
if len(rows) < n:
return None
close, out = [float(r["close"]) for r in rows], []
for i in range(len(close)):
if i < n - 1:
out.append(float("nan")) # warm-up renders as a gap
continue
w = close[i - n + 1:i + 1]
mean = sum(w) / n
sd = (sum((x - mean) ** 2 for x in w) / n) ** 0.5
out.append(0.0 if sd == 0 else (close[i] - mean) / sd)
self.times = [int(r["time"]) for r in rows] # one per value
return {"z": out}
Folder
Kind
indicators/name.py
Indicator
strategies/name.py
Strategy
monitors/name.py
Monitor
apps/name.py
App — a custom panel; one that imports a Strategy class trades
name.py
Analysis — a one-off script, read-only
An indicator receives its series
while25.bars is the chart’s own series, oldest first, replaced whole every pass; while25.forming the unclosed bar or None; while25.future_times the projected grid. candles(source="live") inside compute() raises LIVE_IN_COMPUTE. warmup (an int, or a callable of the params) says how many bars you need; a short chart then reports “warming up” instead of drawing nothing.
You can predict past the last bar
self.times may run PAST the newest candle: values dated onto while25.future_times render to the right of price. A value dated at a time the chart has no bar for is not drawn.
The package is the API
Inside a running module every call is package-level: while25.candles, while25.buy, while25.subscribe, while25.ui.push, while25.log. There is one module per process, so nothing needs passing around. The ctx a handler receives is that same object — use it when you want the explicit style, or bind a fake with while25.use(fake) in a test. Shorten the name yourself if you like: import while25 as w25.
Everything is synchronous
Each module owns its own process, so a blocking call costs nothing anyone else can see. There is no event loop to yield to — never write async def or await.
The SDK itself has no dependencies, so you can write and unit-test a module on a plain Python install before it ever touches the platform. numpy and pandas are available in the runtime. Get the desktop app to run it — Python runs beside the engine, which a browser cannot host.