Strategies only — and enforced, not advisory: in any other kind (Indicator, App, Monitor, analysis) every order call raises OrderRightsError before a byte leaves the process, and the engine independently refuses a live grant for a non-Strategy. Every call routes through the same OrderInterface the platform itself uses, so risk rules, pre-trade checks and the OMS apply identically — there is deliberately no separate path for Python.
Place one order. Blocks until the engine answers; a refusal raises. while25.orders.place is the same call.
Parameters
sidestrrequired
"BUY" or "SELL", any capitals.
quantity / amountDecimal | int | str | floatrequired
Exactly one. amount is cash in the quote currency, sized by the engine at a live price; market or limit only, no bracket. Figures are exact: a float only when exact to 9 fraction digits (0.1 + 0.2 is refused, never rounded).
order_typestroptionaldefault "MKT"
MKT · LMT · STP · STP LMT · MIT · LIT · TRAIL, the order ticket’s names written exactly so (no other spelling is accepted). MOO MOC LOO LOC are refused (use validity="opg"/"cls" where the broker takes the auction as a validity).
Absent means no price; a stated one must be above 0.
productstroptionaldefault "delivery"
delivery intraday margin normal, as the broker takes them.
validitystr | Noneoptionaldefault None
day gtc ioc fok opg cls, whichever the broker takes for the instrument; gtt for a stop-limit Zerodha holds. Left out: the broker’s normal one. A held entry with "day" is withdrawn at the close of its session.
hoursstr | Noneoptionaldefault None
"eth": extended hours too (US stocks, ETFs, SPX-class index options). "rth" is refused.
stop_loss makes it a bracket: the engine holds the stop and arms it when the entry fills, sized to the fills. take_profit adds a resting limit; alone it is refused. Entry types: MKT, LMT, STP LMT, STP.
A trailing stop’s distance. Held by the engine: trail_amount only. Held by the broker: amount or percent, plus an optional limit offset. On a bracket: trail_amount only.
reduce_onlybooloptionaldefault False
A stop, if-touched or trailing order that protects a position you hold: retired when it is gone, never larger than it, never withdrawn by time.
held_bystr | Noneoptionaldefault None
"local" (the engine holds the stop; works while the app runs) or "broker"(sent as the broker’s own stop; works with the app closed, where the broker holds that type). Not on a market or limit order.
tag / idempotency_keystroptionaldefault ""
tag (at most 20 characters) rides on every event of the order. One idempotency_key per trading intent: a repeat is refused DUPLICATE_ORDER; left empty, one is minted per call.
Response
order_idstrrequired
The engine’s id, for its whole life; what cancel, modify and square_off take.
The stop is required, the take-profit optional. The stop’s own id is order_id + "-SL" once the entry has filled: move it with modify(stop_id, trigger_price=...) or take it off with cancel(stop_id); the position stays. A broker-held bracket’s exits are -T and -S.
Only this module’s orders. modify: absent means unchanged, at least one must be stated; the outcome arrives as a MODIFY or MODIFY_REJECT event. A combo is cancelled whole by its combo_id.
PYwhile25.square_off(bracket_id) → dict
Leave a bracket (or a combo) at a time you pick: exits off first, then what it holds closed at market. Answers {"ok": True, "square_off_id": ..., "bracket_id": ...}; progress arrives as SQUARE_OFF events (WITHDRAWING SENT DONE REFUSED STOPPED INTERRUPTED). A plain sell beside a bracket closes nothing of it.
A bracket, a time exit, and a timeout retried safely
import while25
from while25 import While25Error
def place_once(call, key):
try:
return call(key)
except While25Error as e:
if e.code != "TIMEOUT": # a refusal: nothing was placed
raise
return call(key) # the same key: a first attempt that went# through answers DUPLICATE_ORDER, never a second order
res = place_once(lambda k: while25.bracket("FUT:US:MNQ:202612", "BUY", 1,
stop_loss=20950, take_profit=21100,
tag="breakout", idempotency_key=k),
"breakout-2026-10-25-1")
...
while25.orders.square_off(res["order_id"]) # at 15:55: exits off, then closed at market
Order events — @on.order(tag=) / @on.fill(tag=)
eventstrrequired
NEW FILL CANCEL REJECT MODIFY MODIFY_REJECT CANCEL_REJECT HELD NOTICE SQUARE_OFF. A held stop: HELD when set, MODIFY when moved (by you or from the chart), CANCEL with a reason when it ends without firing, then NEW and FILL under the same id when it fires.
"broker", "local" or None; the rest set only where they apply.
order_id / instrument_key / symbol / side / order_type / status / tag / reason / timestamp_msrequired
No paper trading from Python
An order needs the live grant a human gives in the Deploy window. Without one every order is refused NO_LIVE_GRANT; nothing is simulated. Evaluate a strategy by running its logic over history_span() bars in the script; no orders are placed.
Prefer a bracket to a naked entry
A bracket is engine-owned, persisted and restored at boot; it survives the script’s process dying. A stop managed in Python does not.
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.