While25 - Programmable Trading Platform
Home
SDK
BlogCardsSupportDownload
While25

A programmable trading platform.

Download While25Book a call

Order managementRisk managementChartsAI assistantCompare

Python SDKSDKDownload

AboutBlogWhile CardsCareersSupportContact

Interactive BrokersAlpacaZerodhaUpstoxAll brokers

TermsPrivacyLicenceRiskAIAcceptable useNotices

While25 is software. It is not a broker, dealer, exchange or investment adviser, and nothing on this site is a recommendation to buy or sell any instrument. Orders you place route to your own brokerage account; While25 never holds funds or securities.

Trading carries risk of loss, including losses greater than your deposit on leveraged products. Backtests and simulations do not predict future returns. Broker and exchange names are trademarks of their owners. We plan to add Coinbase, Binance and Robinhood; you cannot connect them yet.

© 2026 While25

while25
Start here
  • Quickstart
  • Writing a module
Declaring
  • Module types
  • Subscriptions
  • Inputs
  • Plots & style
Calling
  • Market data
  • Instrument rules
  • Options, futures & combos
  • Portfolio
  • Orders
  • Chart
  • Panels & UI
  • Workspace
  • Context
  • Errors
Contents · Orders
Start here
  • Quickstart
  • Writing a module
Declaring
  • Module types
  • Subscriptions
  • Inputs
  • Plots & style
Calling
  • Market data
  • Instrument rules
  • Options, futures & combos
  • Portfolio
  • Orders
  • Chart
  • Panels & UI
  • Workspace
  • Context
  • Errors
SDK/Calling/Orders
← PreviousPortfolioNext →Chart

Orders

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.
PYwhile25.place(instrument_key, side, quantity=None, *, amount=None, order_type="MKT", price=None, trigger_price=None, reduce_only=False, held_by=None, product="delivery", validity=None, hours=None, tag="", idempotency_key="", take_profit=None, stop_loss=None, trail_amount=None, trail_percent=0.0, trail_limit_offset=None, symbol="", disclosed_quantity=None, is_amo=False, slice=False, group="", group_id="", parent_order_id="", linked_order_id="") → dict
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).
price / trigger_pricefigure | Noneoptionaldefault None
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 / take_profitfigure | Noneoptionaldefault None
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.
trail_amount / trail_percent / trail_limit_offsetfigureoptionaldefault None
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.
broker_order_ids / latency_mslist[str] / intrequired
 
paperboolrequired
Always False: there is no paper execution from Python. An undeployed module’s orders are refused NO_LIVE_GRANT.
Raises
NO_LIVE_GRANTBAD_ORDER_TYPEBAD_PRODUCTBAD_VALIDITYBAD_HOURSBAD_TAGBAD_NOTIONALBAD_GROUPBAD_REDUCE_ONLYBAD_HELD_BYBROKER_HELD_UNSUPPORTEDBAD_TRAILDUPLICATE_ORDERTIMEOUTBUSYNOT_READY
Plus every risk-gate refusal, the same way. See Errors for the full table.
PYwhile25.buy(instrument_key, quantity=None, **kw) · while25.sell(instrument_key, quantity=None, **kw)
place() with the side filled in.
PYwhile25.bracket(instrument_key, side, quantity=None, *, stop_loss, take_profit=None, **kw) → dict
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.
PYwhile25.cancel(order_id) → dict · while25.modify(order_id, *, quantity=None, price=None, trigger_price=None, trail_amount=None, trail_percent=None, trail_limit_offset=None) → dict
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.
quantity / filled_quantity / pending_quantityDecimalrequired
Always stated.
price / average_price / last_fill_quantity / last_fill_price / trigger_priceDecimal | Nonerequired
None on anything that is not a fill or has no level.
held_by / combo_id / square_off_id / close_order_idstr | Nonerequired
"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.
← PreviousPortfolioNext →Chart
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.