Skip to Content
While25SDK docs
Writing modules

Your first module

A module is a Python class; While25 runs it and renders what it produces. The package is the API.

The Python SDK for the While25 trading platform.

Write strategies, indicators, monitors and apps as classes. Declare what wakes them; While25 runs them and renders what they produce.

pip install while25

The SDK has no dependencies. You can write and unit-test a strategy on a plain Python install and run it in the platform unchanged — which is the point: until pip install while25 worked, nobody could develop without the platform.


A strategy

import while25
from while25 import Strategy, on

class MeanReversion(Strategy):
    id      = "mean_reversion"
    label   = "Mean Reversion"
    version = "1.0.0"

    @on.tick("EQ:US:AAPL")
    def on_tick(self, ctx, tick):
        while25.log(f"last {tick['ltp']}")

The package is the API. Inside a running module, while25.log, while25.candles, while25.buy, while25.subscribe, while25.ui.push and the rest act on the module the platform is running — there is one module per process, so nothing has to be passed around. The ctx a handler receives is the same object, kept for the explicit style and for tests. Shorten the name yourself if you like: import while25 as w25. While a module runs, dir(while25.orders) (or .data, .portfolio, .market, .chart, .viz, .ai) lists that name's calls.

A tick carries symbol, ltp, bid, ask, timestamp_ms and as_of (when While25 last saw data for the instrument). bid, ask and timestamp_ms are None when the venue has not sent them — never 0. IBKR delivers bid and ask as separate updates, so one side is routinely absent on a given tick; test for None before comparing.

Four kinds, one shape. They differ only in what they may emit and how the platform presents them — not in what wakes them:

KindFor
StrategySomething that trades
IndicatorSomething drawn on the chart
MonitorSomething that watches and notifies
AppSomething with its own panel: a strategy's desk is one

On this page