Results and strategy

UI-side event normalization, trade pairing, metrics, equity curve, and ResultsPanel export pipeline.

This page

Results and strategy

Results UI turns opaque engine payloads into operator-consumable tables, metrics, and files. It is a pure-ish viewer layer over lastRun + bars.

Results overlay with strategy stats, equity curve, and closed trades

Abstract

ModuleRole
results/events.tsNormalize heterogeneous event shapes; markers; equity series
results/strategy.tsShared walker walkStrategyEvents → trades, stats, positions, stream; CSV
results/positions.tsPyramiding-aware position cycles (avg-entry parity with the pyne broker, per-fill P&L)
ui/ResultsModal.tsxTabs, Events Stream/Open⇄Close switcher, export, jump-to-time
ui/StrategyReport.tsxStats cards (return %, bars-held, fills), equity curve, trades table, CSV
ui/StatusBar.tsxCompact trade summary

Conceptual model

Diagram

Rendering…

Event normalization

Engines may emit Pro API parity fields (kind, bar_time, direction, ohlc) or legacy UI fields (type, time, dir, price). Normalizer:

  • Unifies time/price/dir/id
  • Optionally fills price from bars when OHLC present/empty
  • Can include order-like events for the Events tab

Trade pairing algorithm

Sketch (buildStrategyReport):

  1. Sort by time.
  2. On entry-like kind → open map by id.
  3. On exit/close-like → match id, else sole open trade.
  4. PnL = Δprice × long/short sign.
  5. Aggregate win rate, profit factor, max DD on cumulative PnL.

Not modeled: fees, funding, partial fills, portfolio multi-symbol—viewer honesty.

ResultsPanel tabs

TabData source
EventsnormalizedEventsStream (chronological) or Open⇄Close (position cycles via results/positions.ts) view
Strategyreport.trades + report.stats (single column: stats → equity → trades)
Plotsseries / plots summary
Metricsmeta + context + stats subset
RawJSON.stringify(lastRun)

Interactions: copy, export, scrollToTime on trade rows. Scriptlogs / Debug Pins also jump the chart (jumpToDebugPin) when bar time/index is present — see Debugging.

Equity

buildEquityCurve feeds chart equity pane when runner/strategy path requests it—derived series, not engine-native unless also provided.

Export (ADR-013)

ArtifactFunction
axis-run-*.jsonFull payload
axis-trades-*.csvtradesToCsv
ClipboardCSV when permitted

Invariants

  1. Results recompute from lastRun reactively; they do not re-query engines.
  2. Changing bars without re-run can change normalization fills—re-run after Load.
  3. lastRun not rehydrated from localStorage (session artifact).
  4. Infinite profit factor when no losses but profits exist—display must tolerate non-finite.

Failure modes

SymptomAXIS explanation
Events > 0, trades = 0Unpaired or missing prices
CSV disabledNo closed trades
Jump no-opsManager unmounted / invalid time

Internals cross-links

Operator narrative: Strategy and results.
Architecture: ADR-013.

See also