Skip to content

feat: add options scaffold backtests and realtime triage updates#629

Merged
PatrickFanella merged 5 commits into
mainfrom
feat/embedding-triage-phase2
Apr 22, 2026
Merged

feat: add options scaffold backtests and realtime triage updates#629
PatrickFanella merged 5 commits into
mainfrom
feat/embedding-triage-phase2

Conversation

@PatrickFanella
Copy link
Copy Markdown
Owner

Summary

  • add stock/options strategy scaffold support and richer options backtest artifacts
  • add API and service coverage for persisted options trade logs, equity curves, and exit reasons
  • include related realtime triage, TUI, docs, compose, and repo test updates already present in the worktree

Testing

  • go test ./...

Copilot AI review requested due to automatic review settings April 22, 2026 03:16
@github-actions github-actions Bot added the size:xl Extra large effort label Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/strategyscaffold for 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_health label), 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.

Comment thread internal/strategyscaffold/strategyscaffold.go Outdated
Comment thread internal/discovery/options/sweep.go Outdated
Comment thread internal/discovery/options/sweep.go Outdated
Comment on lines +523 to +525
for _, indicator := range data.IndicatorSnapshotFromBars(bars) {
values[indicator.Name] = indicator.Value
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +193
optionsConfig, err := rules.ParseOptions(optionsRulesRaw)
if err != nil {
return nil, &ServiceError{Status: 400, Message: "invalid options_rules config: " + err.Error()}
}
if optionsConfig == nil {
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread internal/service/backtest.go Outdated
Comment on lines +197 to +200
allBars, svcErr := svc.loadHistoricalBars(ctx, strategy.Ticker, domain.MarketTypeStock, config)
if svcErr != nil {
return nil, svcErr
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
PatrickFanella and others added 2 commits April 21, 2026 22:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@PatrickFanella
Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits April 22, 2026 03:35
…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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

@copilot apply changes based on the comments in this thread

Implemented the thread feedback in 96bd250 (core fixes) and d81685b (follow-up test clarity): options_rules config + underlying are now honored in options backtests, indicator snapshots are precomputed for sweep efficiency, and coverage was added/updated for the new behavior.

@PatrickFanella PatrickFanella merged commit b4dfdf2 into main Apr 22, 2026
1 check passed
@PatrickFanella PatrickFanella deleted the feat/embedding-triage-phase2 branch April 22, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:xl Extra large effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants