Skip to content

fix(uta,alpaca): single attached exit leg → oto, not bracket#342

Merged
luokerenx4 merged 1 commit into
masterfrom
UTA-issue
Jun 14, 2026
Merged

fix(uta,alpaca): single attached exit leg → oto, not bracket#342
luokerenx4 merged 1 commit into
masterfrom
UTA-issue

Conversation

@luokerenx4

Copy link
Copy Markdown
Contributor

Summary

  • Alpaca's bracket order_class requires both take_profit and stop_loss. The broker set order_class='bracket' whenever either leg was present, so a "limit entry + stop-loss only" order was rejected at push with 422 bracket orders require take_profit.limit_price — after the user had already approved it.
  • Fix routes by leg count: two legs → bracket, one leg → oto (one-triggers-other), which Alpaca accepts with a single leg. Single-stop orders now place as entry + held stop leg.
  • Broader "catch venue constraints at stage time, not after push" work tracked separately in ANG-108.

Test plan

  • AlpacaBroker.spec.ts 43/43 (added 2 regressions: single leg → oto, both legs → bracket)
  • Verified end-to-end on alpaca-paper via the original failing path (place → approve): FCX 1@$50 + SL$45 now submits as entry+stop instead of 422; cancel left the account flat, real orders untouched
  • pnpm test (full suite — not re-run; change is isolated to AlpacaBroker + its spec)

Boundary touch

Touches the trading execution path (UTA broker order placement, Alpaca). No auth / credential / migration changes.

🤖 Generated with Claude Code

Alpaca's `bracket` order_class REQUIRES both take_profit AND stop_loss; a
single leg sent under `bracket` is rejected at push with
`422 bracket orders require take_profit.limit_price`. The broker
unconditionally set order_class='bracket' whenever either leg was present,
so a "limit entry + stop-loss, no take-profit" order always 422'd after
the user approved it.

Route by leg count: two legs → bracket, one leg → oto (one-triggers-other),
which Alpaca accepts with either leg alone. Single-stop orders now place
as an entry + held stop leg.

Verified end-to-end on alpaca-paper via the original failing path
(place → approve): FCX 1@$50 + SL$45 now submits as entry+stop instead
of 422.

Broader stage-time broker-aware validation tracked in ANG-108.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Building Building Preview, Comment Jun 14, 2026 9:45am

Request Review

@luokerenx4 luokerenx4 merged commit 9882c56 into master Jun 14, 2026
4 of 5 checks passed
Manzueti added a commit to Manzueti/OpenAlice that referenced this pull request Jun 14, 2026
fix(uta,alpaca): single attached exit leg → oto, not bracket
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