Start Algorithm
Start a trading algorithm to begin executing trades.
Endpoint
POST /api/trading/algorithms/:id/start
Authentication
Requires authentication via Bearer token.
Authorization: Bearer <access_token>
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Algorithm ID |
Body
No request body required.
Response
Success (200 OK)
{
"id": "507f1f77bcf86cd799439011",
"name": "RSI Momentum Strategy",
"status": "active",
"active": true,
"message": "Algorithm started successfully"
}
Errors
| Status | Code | Message |
|---|---|---|
| 400 | VALIDATION_ERROR | Algorithm configuration incomplete |
| 401 | UNAUTHORIZED | Authentication required |
| 403 | FORBIDDEN | Daily loss limit reached |
| 404 | NOT_FOUND | Algorithm not found |
| 422 | UNPROCESSABLE_ENTITY | Algorithm already active |
Error Response Examples
Incomplete Configuration:
{
"error": {
"message": "Algorithm configuration is incomplete",
"code": "VALIDATION_ERROR",
"status": 400,
"details": {
"missingFields": ["entryConditions", "exitConditions"]
}
}
}
Daily Loss Limit:
{
"error": {
"message": "Daily loss limit reached. Cannot start algorithm.",
"code": "FORBIDDEN",
"status": 403,
"details": {
"dailyLoss": 5000,
"limit": 5000
}
}
}
Examples
Start Algorithm
cURL:
curl -X POST https://api.x3algo.com/api/trading/algorithms/507f1f77bcf86cd799439011/start \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
JavaScript:
const algorithmId = '507f1f77bcf86cd799439011'
const response = await fetch(
`https://api.x3algo.com/api/trading/algorithms/${algorithmId}/start`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
)
const result = await response.json()
console.log(result.message)
Python:
algorithm_id = '507f1f77bcf86cd799439011'
response = requests.post(
f'https://api.x3algo.com/api/trading/algorithms/{algorithm_id}/start',
headers={'Authorization': f'Bearer {access_token}'}
)
result = response.json()
print(result['message'])
Pre-Start Validation
Before starting, the algorithm is validated for:
-
Complete Configuration
- All 5 configuration steps must be completed
- Entry conditions defined
- Exit conditions defined
- Risk parameters set
- Execution settings configured
-
Risk Limits
- Daily loss limit not exceeded
- Maximum open positions not reached
- Broker connection active (for live trading)
-
Market Hours
- Exchange is open (for live trading)
- Trading hours configured correctly
State Transitions
draft → stopped → active
stopped → active
paused → active
Notes
- Draft algorithms must be completed before starting
- Paper trading mode doesn't require broker connection
- Live trading requires active broker connection
- Algorithm will execute on the configured timeframe
- First execution may take up to one timeframe period
Related
- Stop Algorithm
- Pause Algorithm endpoint (coming soon)
- Get Algorithm
- Complete Algorithm endpoint (coming soon)