close-trade
Scannednpx machina-cli add skill hugoguerrap/crypto-claude-desk/close-trade --openclawClose Trade & Post-Mortem
Close trade $ARGUMENTS and run a post-mortem analysis.
Workflow
Step 1: Close the Trade
Delegate using the Task tool with subagent_type: general-purpose and model: opus:
"You are the portfolio-manager agent. Read agents/portfolio-manager.md for your decision framework. Close trade $ARGUMENTS. If a price is specified after 'at', use that as exit price. Otherwise, get the current market price using get_exchange_prices() from crypto-exchange MCP. Call close_trade(trade_id='...', exit_price=..., close_reason='...') from crypto-learning-db MCP. PnL, portfolio balance, and stats are updated automatically. Do NOT use the Edit tool."
Step 2: Post-Mortem Analysis
After the trade is closed, delegate using the Task tool with subagent_type: general-purpose and model: opus:
"You are the learning-agent. Read agents/learning-agent.md for your analysis framework. Run a post-mortem analysis on the recently closed trade $ARGUMENTS. Call query_trades(status='closed', limit=1) from crypto-learning-db to get the trade data. Read any related reports from data/reports/. Analyze what worked, what didn't, and provide specific recommendations for improvement. Do NOT use the Edit tool."
Step 3: Validate Predictions & Update Patterns
After the post-mortem, delegate using the Task tool with subagent_type: general-purpose and model: opus:
"You are the learning-agent. Validate all predictions for trade $ARGUMENTS. Call query_predictions(trade_id='...') from crypto-learning-db to find all predictions tied to this trade. Compare each prediction against the actual outcome. Call validate_prediction() for each one with a detailed NL evaluation of how close the prediction was and what we can learn. Then call upsert_pattern() to update the pattern library with the setup from this trade. Do NOT use the Edit tool."
Step 4: Present Results
Show:
- Trade closure summary (entry, exit, PnL)
- Post-mortem analysis
- Prediction accuracy (how many correct vs incorrect, with evaluations)
- Pattern identified (win rate, recommendation)
- Lessons learned
Source
git clone https://github.com/hugoguerrap/crypto-claude-desk/blob/main/skills/close-trade/SKILL.mdView on GitHub Overview
This skill closes an open trade and immediately runs a post-mortem analysis to capture learnings and performance metrics. It updates PnL, portfolio balance, and related stats, then feeds insights back into the pattern library to improve future decisions. You can specify an exit price with at or rely on the current market price if omitted.
How This Skill Works
The skill delegates three tasks via the Task tool to specialized subagents: a portfolio-manager to close the trade using an exit_price or the current market price fetched by get_exchange_prices, and to call close_trade with trade_id, exit_price, and a close_reason. Next, a learning-agent runs a post-mortem analysis on the recently closed trade, consulting data from data/reports and querying the closed trade data. Finally, the learning-agent validates all predictions against the actual outcome and upserts patterns into the library, then presents a consolidated results report.
When to Use It
- You know the exit price and want to close now
- You want automatic PnL, balance, and stats updates after closing
- You need a post-mortem analysis to learn from the trade
- You want to validate predictions against the actual outcome
- You want to update the pattern library after a trade
Quick Start
- Step 1: Close the Trade using the Portfolio Manager with exit_price if provided
- Step 2: Run the Post-Mortem Analysis via the learning-agent
- Step 3: Validate predictions and upsert patterns
Best Practices
- Always provide an exit_price when you have a target; otherwise let the system fetch the current price
- Include a clear close_reason to aid future analyses
- Verify that PnL, portfolio balance, and stats are updated after closing
- Run the post-mortem promptly to capture timely learnings
- Ensure related reports and trade data are accessible to the post-mortem
Example Use Cases
- /close-trade trade_001 at 98500
- /close-trade trade_002
- /close-trade trade_003 at 102300
- /close-trade trade_010
- /close-trade trade_042 at 97050