Position from cumulative fills
| Symbol | Meaning | Units / range |
|---|---|---|
| \(buys / sells\) | Sets of filled buy and sell records on this (market, token) | list of fills |
← All stages · stage 9 of 11
Turn raw fills into a clean capital ledger — free, reserved, redeemable, realised.
After a fill, the hard part is not "what did we buy?" — it is "what is reserved against live orders, what is free, what can be redeemed when the market resolves?".
Tracks position by market and token, reserves inventory against live orders, updates avg cost and PnL, and plans split / merge / redeem actions when resolution is final.
It is the only stage that knows what capital is actually available to the next OrderIntent.
Every formula below is implemented in packages/polytraders-bots/ or packages/polytraders-runner/. Treat the worked example as the unit-test sanity check you should be able to reproduce locally.
| Symbol | Meaning | Units / range |
|---|---|---|
| \(buys / sells\) | Sets of filled buy and sell records on this (market, token) | list of fills |
| Symbol | Meaning | Units / range |
|---|---|---|
| \(price_i\) | Fill price on trade i | 0..1 |
| \(qty_i\) | Shares filled on trade i | shares |
Average cost is reset on each round-trip close so realised PnL is unambiguous on partial exits.
| Symbol | Meaning | Units / range |
|---|---|---|
| \(free_qty\) | Quantity available for new orders | shares |
| \(reserved_qty\) | Quantity locked against live orders | shares |
| \(total_qty\) | Position (filled, not yet redeemed) | shares |
Reservations are released only when the live order moves to filled, cancelled, or rejected. No reservation may leak past order lifetime.
| Symbol | Meaning | Units / range |
|---|---|---|
| \(mid\) | Current mid-price | 0..1 |
| \(avg_cost\) | Volume-weighted average cost | 0..1 |
| \(position\) | Net signed position | shares |
| Symbol | Meaning | Units / range |
|---|---|---|
| \(position\) | Net YES shares at resolution | shares |
Split / merge / redeem actions are queued by SettlementPlanner — never executed inline with trading.
Reference TypeScript implementation lives in packages/polytraders-* at the repository root. Stage owners maintain these files — read them before writing new code.
packages/polytraders-bots/src/governanceReference accounting bots: positionledger, settlementreconciler, redemptionplanner.packages/polytraders-contracts/src/ReportEnvelope.tsThe envelope that wraps every fill/redemption event for audit.packages/polytraders-mock-clob-v2/src/envelopes.jsReference envelope writer — links fills to inventory updates by correlation_id.The platform mock is the source of truth for what each stage's UI exposes. Open these alongside the code references.
GOV_*GOV — governance, accounting, replay, monitoringEXEC_*EXEC — execution, OMS, fillsHover or tap any reason code on this page (or anywhere on the site) to see its canonical short description. Full registry: /standards/reason-codes.