Skip to main content
Skip to main content
Version: Next 🚧

Stop Algorithm

Stop a running trading algorithm. Existing open positions will remain open.

Endpoint

POST /api/trading/algorithms/:id/stop

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": "stopped",
"active": false,
"message": "Algorithm stopped successfully"
}

Errors

StatusCodeMessage
401UNAUTHORIZEDAuthentication required
404NOT_FOUNDAlgorithm not found
422UNPROCESSABLE_ENTITYAlgorithm not active

Examples

Stop Algorithm

cURL:

curl -X POST https://api.x3algo.com/api/trading/algorithms/507f1f77bcf86cd799439011/stop \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

JavaScript:

const algorithmId = '507f1f77bcf86cd799439011'

const response = await fetch(
`https://api.x3algo.com/api/trading/algorithms/${algorithmId}/stop`,
{
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}/stop',
headers={'Authorization': f'Bearer {access_token}'}
)

result = response.json()
print(result['message'])

Behavior

When an algorithm is stopped:

  1. Signal Generation Stops

    • No new entry signals will be generated
    • Algorithm will not open new positions
  2. Existing Positions

    • Open positions remain open
    • Exit conditions continue to be monitored
    • Stop loss and take profit orders remain active
  3. Status Change

    • Status changes from active to stopped
    • active flag set to false

State Transitions

active → stopped
paused → stopped

Use Cases

Temporary Stop

Stop algorithm temporarily to:

  • Review performance
  • Adjust configuration
  • Wait for better market conditions

Emergency Stop

Stop algorithm immediately if:

  • Unexpected behavior detected
  • Market conditions change dramatically
  • Risk limits being approached

Scheduled Stop

Stop algorithm at end of trading session:

// Stop all algorithms at market close
const algorithms = await getActiveAlgorithms()

for (const algo of algorithms) {
await stopAlgorithm(algo.id)
}

Notes

  • Stopping an algorithm does not close open positions
  • To close positions, use the position management endpoints
  • Algorithm can be restarted at any time
  • Performance metrics are preserved