feat: add options scaffold backtests and realtime triage updates#629
Conversation
There was a problem hiding this comment.
Pull request overview
Adds strategy scaffolding and richer options backtest artifacts (trade logs, equity curves, exit reasons), plus accompanying API/service/test/doc updates and some realtime triage + websocket/TUI improvements.
Changes:
- Introduces
internal/strategyscaffoldfor stock + options paper strategy scaffolds and an options backtest/validation summary helper. - Extends options discovery backtests to return full artifacts (trades/equity curve) and annotates closing option trades with
exit_reason. - Updates backtest service/API and various UI/TUI websocket surfaces/tests (reconnect re-subscribe, new
pipeline_healthlabel), plus RSS triage JSON-wrapper prompting.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/pages/realtime-page.test.tsx | Uses config-driven API base URL in assertions; adds websocket reconnect re-subscribe test. |
| web/src/pages/pipeline-run-page.test.tsx | Adds websocket reconnect re-subscribe test for active run page. |
| web/src/hooks/use-websocket-client.test.tsx | Adds regression coverage for reconnect + resubscribe behavior. |
| web/src/components/dashboard/activity-feed.tsx | Adds human label for pipeline_health websocket event type. |
| web/src/components/dashboard/activity-feed.test.tsx | Verifies pipeline_health label renders in UI feed. |
| internal/strategyscaffold/strategyscaffold.go | New stock/options scaffold constructors and options backtest summary wrapper. |
| internal/strategyscaffold/strategyscaffold_test.go | Tests scaffold validation + synthetic options backtest produces artifacts. |
| internal/strategyscaffold/README.md | Documents scaffold usage and limitations. |
| internal/service/backtest.go | Adds options_rules execution path, persistence refactor helpers. |
| internal/service/backtest_scaffold_test.go | Validates service behavior for options_rules backtests and persistence. |
| internal/repository/postgres/polymarket_account.go | Filters out unsupported polymarket trade sides before insert. |
| internal/repository/postgres/polymarket_account_test.go | Adds coverage for filtering and side normalization edge cases. |
| internal/domain/trade.go | Adds exit_reason field to persisted trade JSON. |
| internal/discovery/options/sweep.go | Returns full artifacts, emits option trades/equity curve, adds exit reasons and additional signal values. |
| internal/discovery/options/sweep_test.go | Ensures options sweep returns trades/equity and force-closes with exit_reason=final_bar. |
| internal/discovery/options/validator.go | Adjusts to new artifacts return type. |
| internal/data/rss/triage.go | Switches prompt to require a top-level { "results": [...] } JSON object for batch mode. |
| internal/data/rss/triage_test.go | Confirms wrapper prompting and parsing behavior. |
| internal/cli/tui/model.go | Formats pipeline_health websocket events with human-friendly label. |
| internal/cli/tui/model_test.go | Adds test for pipeline_health event label in activity feed. |
| internal/api/strategy_handlers.go | Validates rules_engine and options_rules payloads using parsers. |
| internal/api/server_test.go | Adds coverage for accepting/rejecting rules/options scaffold configs. |
| internal/api/backtest_handlers_test.go | Adds coverage that options artifacts (including exit reasons) are returned/persisted. |
| docs/reference/api.md | Removes /ws from public endpoint list. |
| docs/design/backend/websocket-server.md | Updates websocket lifecycle docs to reflect authenticated upgrade options. |
| docs/design/api-design.md | Notes /ws authentication mechanisms. |
| docker-compose.yml | Adds host.docker.internal mapping via host-gateway. |
| cmd/tradingagent/runtime_test.go | Updates expected schema gate versions; removes parallelism. |
| cmd/tradingagent/docker_compose_prod_test.go | Updates expected postgres/redis compose image/snippet strings. |
| README.md | Updates websocket endpoint documentation to reflect authenticated upgrade. |
| .hermes/plans/2026-04-20_165747-hermes-integration.md | Adds Hermes integration proposal doc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for _, indicator := range data.IndicatorSnapshotFromBars(bars) { | ||
| values[indicator.Name] = indicator.Value | ||
| } |
There was a problem hiding this comment.
buildOptionSignalValues calls data.IndicatorSnapshotFromBars(bars) for every bar and every variant, and IndicatorSnapshotFromBars recomputes multiple full indicator series from scratch. Because runOptionsBacktest passes an ever-growing bars[:i+1] window, this is O(n^2) per variant and can become a bottleneck as bar counts/variation counts grow. Consider precomputing indicator snapshots once per bar (or maintaining rolling indicator state) and reusing them inside the loop.
| optionsConfig, err := rules.ParseOptions(optionsRulesRaw) | ||
| if err != nil { | ||
| return nil, &ServiceError{Status: 400, Message: "invalid options_rules config: " + err.Error()} | ||
| } | ||
| if optionsConfig == nil { |
There was a problem hiding this comment.
In runOptionsRulesBacktest, options_rules is parsed into optionsConfig but the backtest execution does not use it (the function later calls strategyscaffold.RunOptionsPaperBacktest, which generates/uses its own scaffolded config). This means persisted backtests may not reflect the strategy’s saved options_rules. Consider running the synthetic options backtest directly against optionsConfig (or adjusting the scaffold helper to accept/use the parsed optionsConfig) and remove the now-misleading _ = optionsConfig.
| allBars, svcErr := svc.loadHistoricalBars(ctx, strategy.Ticker, domain.MarketTypeStock, config) | ||
| if svcErr != nil { | ||
| return nil, svcErr | ||
| } |
There was a problem hiding this comment.
Historical bars are downloaded using strategy.Ticker for options_rules backtests. Since options_rules has its own Underlying field, this can backtest the wrong underlying if the Strategy.Ticker and options_rules.underlying diverge. Prefer using optionsConfig.Underlying (after parsing) as the ticker passed to loadHistoricalBars / downstream backtest execution.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
…ignal snapshots Agent-Logs-Url: https://github.com/PatrickFanella/augr/sessions/d2f3bbbb-6f01-4308-8a6e-0e2fce1e8655 Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
…rage Agent-Logs-Url: https://github.com/PatrickFanella/augr/sessions/d2f3bbbb-6f01-4308-8a6e-0e2fce1e8655 Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Implemented the thread feedback in |
Summary
Testing