Skip to content

[web] Positions view: per-tranche MTM, stop distance, bracket status, freshness and attestation chips #701

Description

@eaitbrahim

Context (verified)

  • positions stores one row per tranche: qty, entry_fill, entry_fee, initial_stop, partial-exit accumulators (realized_qty/realized_proceeds/realized_fees), bracket_order_id, status (keel/data/db.py).
  • The agent computes mark-to-market equity per cycle (agent._mark_to_market_equity, keel/agent/agent.py:404) — the last mark per product needs exposing, not recomputing client-side.
  • Freshness already has a human-readable entry-gate vocabulary: missing / behind / unconfirmed (keel/data/freshness.py:151-262, entry_bar_ready) — currently buried in Status rows.
  • asset_attestations (v6) and instrument_attestations (v10) tables exist with screen_exceptions; the quarterly-expiry semantics match the pinned-quarterly-snapshot decision recorded on keel-broker-alpaca Phase B: equities paper profile, attestation semantics, runbook #370.

Today Positions is a table inside Status. Alpaca's Positions page (avg entry, current price, market value, unrealized P&L, per-row close) is the skeleton — minus its one-click close, which is refused.

Scope

  1. Positions view (Portfolio section): rows grouped by product, one disclosure per tranche:
    • entry fill and entry fee, current price, unrealized P&L (server-computed off the agent's mark, Field wire contract), realized-to-date on partial exits
    • initial-stop distance (% and price), bracket status (resting / filled / cleared)
  2. Freshness chip per product rendering the real entry_bar_ready verdict (missing/behind/unconfirmed) — the gate outcome, not just data age. Finer than any broker's "as of" stamp.
  3. Attestation chip per product: Attested: Q2-2026 · Purif: 0.38%RE-ATTESTATION REQUIRED (warn state) when the quarterly filing window expires or a ratio breaches. Reads the existing attestation tables; forward-compatible with keel-broker-alpaca Phase B: equities paper profile, attestation semantics, runbook #370's XBRL screening fields, which render in the same chip when present.

Refusals

  • No close button. Ever. Exits degrade to typed-phrase friction, never a table-row tap — a panic tap must never be the last line of defense.
  • Zero client-side math.

Acceptance

  • MTM P&L reconciles with the equity figure driving the drawdown rails (same mark, one source of truth).
  • Chips render warn states correctly on synthetic expired/breached attestations.
  • No monetary JSON numbers; sortable columns declared server-side.

Depends on #698 (mark source) and the Orders view payload patterns (Sprint 1, third).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complianceShariah/compliance screening or policy (Compliance & rails)featureNew capability (groups under Features)toolingDev/release tooling (Docs, CI & tooling)

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions