Skip to main content
Skip to main content
Version: 1.0 (Current)

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

ParameterTypeRequiredDescription
idstringYesAlgorithm 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

StatusCodeMessage
400VALIDATION_ERRORAlgorithm configuration incomplete
401UNAUTHORIZEDAuthentication required
403FORBIDDENDaily loss limit reached
404NOT_FOUNDAlgorithm not found
422UNPROCESSABLE_ENTITYAlgorithm 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:

  1. Complete Configuration

    • All 5 configuration steps must be completed
    • Entry conditions defined
    • Exit conditions defined
    • Risk parameters set
    • Execution settings configured
  2. Risk Limits

    • Daily loss limit not exceeded
    • Maximum open positions not reached
    • Broker connection active (for live trading)
  3. 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