Skip to content

feat: Agentic Trading session type (engine implementation, default-disabled)#177

Open
jordanrburger wants to merge 1 commit into
mainfrom
feat/agentic-trading-engine
Open

feat: Agentic Trading session type (engine implementation, default-disabled)#177
jordanrburger wants to merge 1 commit into
mainfrom
feat/agentic-trading-engine

Conversation

@jordanrburger

Copy link
Copy Markdown
Collaborator

What this is

The implementation of the Agentic Trading subsystem in the engine — the follow-up to the design-only PR #171. This makes Agentic Trading a real, distributable Scout feature: any install can enable it, and it's generated by scoutctl bootstrap like every other session type.

⚠️ Optional, default-disabled, real-money. Places real brokerage orders via the robinhood-trading MCP. Ships off and does nothing until explicitly enabled. Not financial advice. See the design spec.

How it integrates (engine-native, not a vault copy)

The vault build used a dedicated launchd plist; the engine version instead uses the standard schedule dispatcher — a type: trading slot fires through the existing 5-minute tick. No new plist.

Layer Change
schedule.py SlotType.TRADING + SlotPriority.TRADING = 25; _PRIORITY_BY_TYPE entry
bootstrap.py _assemble() gains a TRADING brain (sources phases/core + phases/trading, mode: [trading]); added to both stage-5 loops; run-trading.sh_CAT1B_RUNNERS; trading.sh_CAT1_TEMPLATES; trading-config.py_CAT1_FILES_FROM_PLUGIN; config + 3 ledgers → _INSTALL_ONLY_TEMPLATES (never overwritten)
phases/trading/trading-loop.md the 6-step brain (reconcile → risk gate → manage → enter → execute → log) + hard guardrails + headless degrade-to-PENDING-APPROVAL
phases/core/git-setup.md opted into trading mode so the brain inherits the shared git/timezone/cost conventions
templates/ run-trading.sh.tmpl (guards on the master switch before any spend), scripts/trading.sh.tmpl (on/off/status), scripts/trading-config.py, config.yaml.tmpl (enabled: false + account placeholder), watchlist/decision-log/nav-history scaffolds
defaults/schedule.yaml commented-out ET-pinned trading-market-open / trading-pre-close slots (opt-in)
CHANGELOG.md [Unreleased] entry (manifests left for the release-time bump)

Two gates keep it safe

  1. Master switchconfig.yaml: enabled ships false; run-trading.sh exits before any spend when off, and the brain re-confirms in-session.
  2. Opt-in schedule — the trading slots ship commented out; a fired slot is a harmless no-op until both the slot is uncommented and the config is enabled.

Verification

  • End-to-end install into a temp vault renders all 9 artifacts; TRADING.md assembles with the loop + git-setup conventions and no briefing-phase leakage.
  • ruff check ✓ · ruff format --check ✓ · mypy ✓ (69 files) · versioning check ✓ (4 manifests in sync) · shellcheck -S error ✓ on the templates.
  • 882 tests pass (added test_install_seeds_agentic_trading_subsystem_disabled; extended the assembled-brains test to cover TRADING).

Deliberately out of scope (follow-ups)

  • No connectors.yaml entry for Robinhood (the brain manages its own MCP availability) — avoids touching connector-health vocabulary.
  • Manifest version bump is left to the normal release flow (this PR only adds to [Unreleased]).

🤖 Generated with Claude Code

Adds a fourth scheduled session type — an autonomous equity-trading loop
against an operator-configured Robinhood account via the robinhood-trading
MCP. Real money, opt-in, not financial advice; ships OFF and no-ops until
explicitly enabled.

- schedule.py: SlotType.TRADING + SlotPriority.TRADING (25); dispatches via
  the standard 5-min tick (a type: trading slot) — no new launchd plist.
- bootstrap.py: TRADING brain assembly (phases/core + phases/trading,
  mode:[trading]) wired into _assemble() + both stage-5 loops; run-trading.sh
  runner; trading.sh + trading-config.py scripts; config + ledgers seeded
  install-only (never overwritten).
- phases/trading/trading-loop.md: 6-step loop with hard guardrails (capital
  cap, single-name cap, mandatory stop, daily-loss cap, circuit breaker,
  settled-cash-only) and a graceful degrade to PENDING-APPROVAL when a
  headless session can't place an order. git-setup opted into trading mode.
- templates: run-trading.sh.tmpl (master-switch guard before any spend),
  trading.sh (on/off/status), config.yaml (enabled:false + account
  placeholder), watchlist/decision-log/nav-history scaffolds.
- defaults/schedule.yaml: commented-out ET-pinned trading slots (opt-in).
- CHANGELOG [Unreleased]; manifests left for the release-time bump.

Verified: end-to-end install renders all 9 artifacts; TRADING.md assembles
with no briefing leakage; ruff/format/mypy/version-sync green; shellcheck -S
error clean; 882 tests pass (+1 new trading install test).
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