fix(uta,alpaca): single attached exit leg → oto, not bracket#342
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bracketorder_class requires both take_profit and stop_loss. The broker setorder_class='bracket'whenever either leg was present, so a "limit entry + stop-loss only" order was rejected at push with422 bracket orders require take_profit.limit_price— after the user had already approved it.bracket, one leg →oto(one-triggers-other), which Alpaca accepts with a single leg. Single-stop orders now place as entry + held stop leg.Test plan
AlpacaBroker.spec.ts43/43 (added 2 regressions: single leg →oto, both legs →bracket)alpaca-papervia 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 untouchedpnpm 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