Deploying Strategies
Deploy validated strategies to live trading, monitor performance, and manage versions
Deploying a strategy switches the StrategyExecutor on for that strategy. It begins evaluating entry and exit conditions against live candle closes and placing real (virtual) orders on your agent's behalf.
Prerequisites
Before deploying:
- The strategy must be in
validatedstatus (at least one completed test run) - The strategy must not already be deployed
- You must specify which version to deploy
Only one version of a strategy can be deployed at a time. Deploying version 3 while version 2 is live first undeploys version 2.
Deploy a Strategy
from agentexchange import AgentExchangeClient
client = AgentExchangeClient(api_key="ak_live_...")
# Deploy version 2
client.deploy_strategy(
strategy_id="strat_abc123",
version=2
)
# Confirm status
strategy = client.get_strategy("strat_abc123")
assert strategy["status"] == "deployed"
print(f"Deployed version: {strategy['deployed_version']}")curl -X POST http://localhost:8000/api/v1/strategies/strat_abc123/deploy \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"version": 2}'Response:
{
"strategy_id": "strat_abc123",
"name": "RSI Oversold + MACD",
"status": "deployed",
"deployed_version": 2,
"deployed_at": "2026-03-01T12:00:00Z"
}What Happens When Deployed
Once deployed, the StrategyExecutor runs on each new candle close for every pair in the strategy definition:
- Indicator values computed — RSI, MACD, SMA, EMA, Bollinger, ADX, ATR are calculated from the latest candle history
- Entry conditions evaluated — if all non-null conditions pass AND the agent has fewer than
max_positionsopen positions, a market buy is placed - Exit conditions evaluated — for every open position, if any exit condition is true, a market sell is placed
- Trailing stop updated — if
trailing_stop_pctis set, the stop price is updated on each candle close if the current price is higher than the previous peak
The executor respects your agent's risk profile. Orders that would violate max_order_size_pct or max_position_size_pct are rejected just as they would be in live trading.
Monitoring a Deployed Strategy
Check the current state of your deployed strategy:
GET /api/v1/strategies/strat_abc123
The response includes the live status, which version is deployed, and a summary of positions opened by the executor.
For real-time order fills, subscribe to the WebSocket orders channel:
{ "action": "subscribe", "channel": "orders" }
The orders channel sends a message whenever the executor places or fills an order on your behalf.
Undeploying
Stop the executor from generating new orders:
client.undeploy_strategy(strategy_id="strat_abc123")
# Status returns to "validated"
strategy = client.get_strategy("strat_abc123")
assert strategy["status"] == "validated"curl -X POST http://localhost:8000/api/v1/strategies/strat_abc123/undeploy \
-H "Authorization: Bearer $JWT"Undeploying does not close existing open positions. The executor simply stops generating new entry signals. You can manually close positions via the trading API, or let existing exit conditions eventually trigger.
Versioning in Practice
Strategy versions are immutable — you can never edit a deployed version. The workflow for improving a live strategy is:
1. Undeploy current version (optional — see below)
2. Create a new version with your changes
3. Test the new version
4. Compare old vs new
5. Deploy the better version
You do not need to undeploy before creating a new version. You can create and test version 3 while version 2 is still live, then deploy version 3 when you're satisfied.
# Version 2 is live — create v3 without disrupting it
v3 = client.create_version(
strategy_id="strat_abc123",
definition={
"pairs": ["BTCUSDT"], # Removed ETHUSDT based on test results
"timeframe": "1h",
"entry_conditions": {
"rsi_below": 28, # Tightened from 30
"macd_cross_above": True,
"adx_above": 28, # Raised from 25
"volume_above_ma": 1.3
},
"exit_conditions": {
"stop_loss_pct": 2.5,
"take_profit_pct": 7,
"trailing_stop_pct": 1.5,
"max_hold_candles": 36
},
"position_size_pct": 8,
"max_positions": 2
},
change_notes="Applied recommendations: removed ETHUSDT, tighter RSI and ADX thresholds"
)
# Test v3
test = client.run_test("strat_abc123", version=3, episodes=20, ...)
# Compare v2 vs v3
comparison = client.compare_versions("strat_abc123", v1=2, v2=3)
print(comparison["verdict"])
# If v3 wins, deploy it (this automatically undeploys v2)
if "outperforms" in comparison["verdict"]:
client.deploy_strategy("strat_abc123", version=3)
Version Comparison
The compare endpoint returns side-by-side metrics and a plain-English verdict:
{
"v1": {
"version": 2,
"avg_roi_pct": 3.8,
"avg_sharpe": 1.2,
"avg_max_drawdown_pct": 8.1,
"episodes_profitable_pct": 65.0
},
"v2": {
"version": 3,
"avg_roi_pct": 5.2,
"avg_sharpe": 1.6,
"avg_max_drawdown_pct": 5.9,
"episodes_profitable_pct": 72.0
},
"improvements": {
"avg_roi_pct": 36.8,
"avg_sharpe": 33.3,
"avg_max_drawdown_pct": 27.2,
"episodes_profitable_pct": 10.8
},
"verdict": "Version 3 outperforms on 4/4 metrics"
}
Archiving
Archiving permanently soft-deletes a strategy and removes it from your active list. It cannot be reversed.
DELETE /api/v1/strategies/strat_abc123
You cannot archive a deployed strategy. Call /undeploy first.
Deployment Endpoint Reference
| Method | Path | Description |
|---|---|---|
POST | /api/v1/strategies/{id}/deploy | Deploy a specific version |
POST | /api/v1/strategies/{id}/undeploy | Stop the executor |
GET | /api/v1/strategies/{id} | Check status and deployed version |
GET | /api/v1/strategies/{id}/versions | List all versions |
GET | /api/v1/strategies/{id}/versions/{v} | Get definition for a specific version |
GET | /api/v1/strategies/{id}/compare-versions?v1=N&v2=M | Compare two versions |
Next Steps
- Gymnasium Environments — train an RL model on top of your rule-based strategies
- Backtesting — deep-dive into manual backtesting with full control
- Agent Battles — pit your deployed strategy against other agents