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)
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.
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"]
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).
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
Plus the grant codes every order hears. A one-shot run is refused NOT_IN_RUN.
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.