feat(trade): --take-profit / --stop-loss perp flags#63
Open
psmiratisu wants to merge 1 commit into
Open
Conversation
Forward TP/SL trigger prices to the planner. With a size (--size/--amount-usdc) they attach to the opening order; alone they attach to an existing position. Each accepts an optional --*-limit companion to rest a limit on trigger instead of a market close. Maps to the backend's takeProfitPrice / stopLossPrice (+ *LimitPrice); the proxy forwards them verbatim. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Adds
--take-profit/--stop-loss(plus--take-profit-limit/--stop-loss-limit) toacp tradefor Hyperliquid perps. Companion to trading-agent #74, which added native TP/SL trigger orders to the planner.How it works
The CLI stays a pure signer — it just forwards the trigger prices in the flat trade body; the planner builds and the wallet signs the resulting order action (a single signature).
Two modes, driven by whether a size is present:
--size/--amount-usdc→ TP/SL bundle onto the opening order (planner uses HL'snormalTpsl).positionTpsl, sized from the live position).Market close by default; pass
--take-profit-limit/--stop-loss-limitto rest a limit on trigger instead.Field mapping
commander camelCases the flags; the body uses the backend's names:
--take-profittakeProfittakeProfitPrice--take-profit-limittakeProfitLimittakeProfitLimitPrice--stop-lossstopLossstopLossPrice--stop-loss-limitstopLossLimitstopLossLimitPriceThe flags live directly on the
tradecommand (no parent/child duplication), so they're free of theoptsWithGlobals()swallow issue.Test
npm run typecheckclean. Verified the flags register (acp trade --help) and that commander produces the exact camelCase keys thefwd()calls map from.Rollout
Needs trading-agent #74 merged/deployed to take effect. agentic-commerce-be needs no change — its trade proxy forwards the request body verbatim (no DTO / allow-list), so these fields pass straight through.
🤖 Generated with Claude Code
Note
Medium Risk
Touches live perp order parameters; behavior depends on trading-agent deployment, though the CLI only forwards fields and does not implement trigger logic.
Overview
Adds Hyperliquid perp take-profit and stop-loss to
acp tradevia four new flags:--take-profit,--take-profit-limit,--stop-loss, and--stop-loss-limit. Help text documents that triggers can bundle with--size/--amount-usdcon entry or apply alone to an existing position, with optional limit prices instead of market closes.runTradeforwards commander’s camelCase options to the trade plan body astakeProfitPrice,takeProfitLimitPrice,stopLossPrice, andstopLossLimitPricefor the trading-agent planner; the CLI still only signs what the backend returns.Reviewed by Cursor Bugbot for commit f9a103b. Bugbot is set up for automated code reviews on this repo. Configure here.