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 · Options, futures & combos
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/Options, futures & combos
← PreviousInstrument rulesNext →Portfolio

Options, futures & combos

One listed contract from a description, from the same lists the Option Chain and Futures panels read. Nothing has to be open first.
PYwhile25.option(underlying, expiry, right, strike, *, settlement="pm", atm_from="options") → dict
underlying a symbol or key; expiry a date or a day of the month ("26th": the next such date); right "CALL"/"PUT" (C/P, CE/PE); strike a listed price or "ATM", "ATM+2", "ATM-2"(N listed strikes higher or lower, calls and puts alike), counted from the expiry’s forward or atm_from="spot". Never a neighbouring contract instead.
Returns
dict
instrument_key symbol underlying_key expiry settlement strike right lot_size multiplier currency, and for ATM atm_strike offset atm_from atm_price. Order quantities are in units: one lot is quantity=c["lot_size"].
One lot of the next ATM+1 call
c = while25.option("NIFTY", expiry="28th", right="CE", strike="ATM+1")
while25.buy(c["instrument_key"], c["lot_size"])
while25.subscribe(c["instrument_key"], on_tick=self.on_option)
Raises
NO_UNDERLYINGNO_OPTIONSNO_EXPIRYNO_STRIKEOFF_THE_LISTNO_PRICENOT_LISTEDTIMEOUT
PYwhile25.future(root, expiry="front") → dict
The dated contract for a root. "front" is the contract the chart’s continuous line is on now, "next" the first of a later month, "2027-03" that month. Nothing is rolled for you: the continuous line takes no order.
Returns
dict
instrument_key symbol root month last_trade lot_size multiplier currency tradeable untradeable_reason front.
Front contract, rolled by hand
c = while25.future("MNQ")
if self.bracket_id and c["instrument_key"] != self.contract:
    while25.orders.square_off(self.bracket_id)          # out of the old contract
    res = while25.buy(c["instrument_key"], 1, stop_loss=self.stop_for(c))
    self.contract, self.bracket_id = c["instrument_key"], res["order_id"]
Raises
NO_ROOTNO_FUTURESAMBIGUOUS_ROOTNO_FRONTNO_NEXTNOT_LISTEDAMBIGUOUS_MONTHTIMEOUT
PYwhile25.combo(legs, lots=1, *, order_type="MKT", product="delivery", validity=None, hours=None, name="", tag="", idempotency_key="") → dict
Two to ten option legs as one combo: one broker order on IBKR (up to 6 legs) and Alpaca (2 to 4), leg by leg and all or none on Upstox, Zerodha and XTS. Each leg’s order is lots× ratio × the contract’s lot size. order_type is every leg’s: "MKT" (no leg priced) or "LMT" (every leg priced; as one order the limit is the legs netted by ratio, a credit negative).
PYwhile25.leg(contract, side, ratio=1, price=None) → dict
An option key or the dict option() returned; "BUY"/"SELL"; lots of this leg per combo lot; its limit on a limit combo.
Returns
dict
combo_id (what cancel(), square_off() and my_position() name it by), order_ids, one_order, deployment_number. Every leg event carries ev["combo_id"]. A combo is cancelled or squared off whole; a leg’s own id is refused COMBO_LEG.
An iron condor
legs = [
    while25.leg(while25.option("SPY", "2026-11-20", "PUT",  "ATM-4"), "BUY"),
    while25.leg(while25.option("SPY", "2026-11-20", "PUT",  "ATM-2"), "SELL"),
    while25.leg(while25.option("SPY", "2026-11-20", "CALL", "ATM+2"), "SELL"),
    while25.leg(while25.option("SPY", "2026-11-20", "CALL", "ATM+4"), "BUY"),
]
c = while25.combo(legs, lots=1, name="Iron condor", tag="condor")
while25.orders.square_off(c["combo_id"])        # later: the whole condor, at market
Raises
BAD_COMBOBAD_ORDER_TYPEBAD_PRICENOT_AN_OPTIONNO_LOT_SIZEBAD_TAGBAD_NAMEINSTRUMENT_RESOLVINGINSTRUMENT_NOT_FOUNDDUPLICATE_ORDERCOMBO_REFUSEDNOT_LIVENOT_READYBUSY
Plus the grant codes every order hears. A one-shot run is refused NOT_IN_RUN.
← PreviousInstrument rulesNext →Portfolio
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.