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 · Portfolio
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/Portfolio
← PreviousOptions, futures & combosNext →Orders

Portfolio

Never cached. Figures are exact: Decimal, money as while25.Money (value, currency). A figure nobody stated is None, never 0.
PYwhile25.portfolio.position(symbol) → dict | None
The account’s position, other strategies’ and manual trades included; None when flat. Several products combine exactly: quantity summed, pnl only in one currency, average_price only on one side; rows keeps each broker row.
Keys
symbol / instrument_key / productstrrequired
 
quantityDecimalrequired
Signed.
average_price / last_priceDecimal | Nonerequired
Fees included where the broker sends them per fill.
pnlMoney | Nonerequired
Unrealised.
PYwhile25.portfolio.positions() → list[dict]
Every position of the account, one broker row each.
PYwhile25.portfolio.my_position(key) → dict | None · while25.portfolio.my_positions() → list[dict]
What this module holds, changed only by its own orders and kept across a Stop and an app restart. Keys: quantity (its part, outside brackets and combos), average_price, last_price, pnl, account_quantity (None until the broker’s first report), brackets (bracket_id group_label side product quantity_held entry_average last_price pnl broker_held waiting_for_entry), combos. NOT_READY means ask again, never flat.
PYwhile25.orders.mine(instrument_key=None) → list[dict]
Its working orders and the stops the engine holds for it: order_id instrument_key symbol side order_type product validity hours quantity filled_quantity price trigger_price status held_by tag bracket_id group_label role. A read: on_stop may call it.
PYwhile25.portfolio.funds() → dict | None
{"margin_used": Money, "margin_available": Money, "assets": [...]}, or None when the broker has not stated them (Upstox outside its service hours). Write if f is None:, never .get("margin_available", 0). funds_unavailable_reason() gives the broker’s words. There is no cash figure.
PYwhile25.portfolio.day_pnl() · realised_pnl() · unrealised_pnl() → Money | None
Account-level, from the broker’s own account line; never a sum over positions.
PYwhile25.portfolio.snapshot() → dict
The raw answer the calls above read from.
Two strategies, one account
The engine keeps each strategy’s part apart; the broker nets them. Size an exit from my_position(), never position(). A coin held outright is never sold short: a sell beyond the part is refused SELL_EXCEEDS_PART. Where the venue takes its fee from the holding (Alpaca), one strategy at a time trades a coin: a second one’s order is refused LONG_ONLY_ONE_STRATEGY. Both arrive as a REJECT event after the call returned.
Raises
NOT_READYNO_ENGINE
← PreviousOptions, futures & combosNext →Orders
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.