Skip to content

feat(options): compare scenario grids in OptionsLab - #2318

Open
he-yufeng wants to merge 1 commit into
HKUDS:mainfrom
he-yufeng:feat/options-scenario-comparison-g12
Open

he-yufeng wants to merge 1 commit into
HKUDS:mainfrom
he-yufeng:feat/options-scenario-comparison-g12

Conversation

@he-yufeng

Copy link
Copy Markdown
Collaborator

Summary

  • Add POST /options/strategy-compare as a thin HTTP adapter over the accepted OptionsStrategyCompareTool used by Agent and MCP.
  • Let OptionsLab compare any two saved strategies on one completed request, with raw and baseline-relative spot × IV grids supplied by the backend.
  • Cover request ordering, stale responses, label normalization, the disclosed 201-point comparison limit, localization and documentation.

Why

Related: #2202

Saved alternatives already share expiry curves and return metrics, but the Web UI has no way to inspect how two strategies differ across the same spot and volatility grid. This adds the roadmap's Web comparison view without reimplementing payoff mathematics in TypeScript or ranking strategies.

Changes

  • Validate and delegate comparison requests to OptionsStrategyCompareTool, preserving strategy order and baseline_index semantics.
  • Add an on-demand OptionsLab comparison that keeps every saved strategy selectable in pairs, aborts superseded requests and ignores stale grids.
  • Trim labels to match backend grid keys, cap only the comparison grid at 201 points with an explicit notice, and reuse the existing scenario matrix for raw and delta values.
  • Add localized copy and update the Options Lab capability documentation.

No live broker, order, payment, wallet, credential, deployment or real market-data path is changed.

Test Plan

Validation on the original candidate and an independent replay from 6ed378dee5a6e6eb87df796a6546c8ca972a8281:

  • Backend route, payoff and comparison suites: 67 passed.
  • Frontend options, chart and export suites: 147 passed.
  • Production frontend build: passed.
  • Ruff lint, git diff --check, repository grep gates and private-files gate: passed.
  • Regression-first checks: missing route returns 404; missing component, 501-point handling and label normalization fail before their fixes.
  • Full backend pytest suite: not run; the 67 tests above are the related options surface.
  • Live browser and real API manual test: not run. Tests use loopback FastAPI, synthetic calculations and mocked frontend transport.

Ruff format and Black report existing whole-file formatting debt on both the unmodified baseline and this candidate, so no unrelated reformatting is included.

Checklist

  • No changes to protected areas (src/agent/, src/session/, src/providers/).
  • No credentials, private paths or secret values added.
  • Code follows the contribution guide and uses the existing backend numerical owner.
  • User-facing behavior and limitations are documented.

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
@he-yufeng

Copy link
Copy Markdown
Collaborator Author

@warren618 Could you review the shared-grid boundary and the pair-at-a-time UI choice?

The route delegates directly to the comparison tool merged in #2199. OptionsLab already permits the current strategy plus five alternatives, so the component compares any selected pair in original input order and maps baseline_index accordingly, rather than silently truncating the list to four. The other two boundaries are explicit: only the comparison grid is capped at 201 points because the tool differs from options_payoff's 501-point limit, and labels are trimmed to match backend grid keys.

The completed-snapshot behavior is covered by page-level tests, and an independent replay passed 67 backend tests, 147 frontend tests and the production build. Does the pair-at-a-time interaction fit the intended Web comparison contract?

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant