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

List Backtests

Retrieve a paginated list of the authenticated user's backtests.

Endpoint

GET /api/backtests

Authentication

Requires authentication via Bearer token.

Authorization: Bearer <access_token>

Request

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page (max: 100)
algorithmIdstring-Filter by algorithm ID
statusstring-Filter by status: running, completed, failed
sortstringcreatedAtSort field: createdAt, completedAt
orderstringdescSort order: asc, desc

Example Request

GET /api/backtests?algorithmId=507f1f77bcf86cd799439011&status=completed&page=1&limit=10

Response

Success (200 OK)

{
"data": [
{
"id": "507f1f77bcf86cd799439013",
"algorithmId": "507f1f77bcf86cd799439011",
"algorithmName": "RSI Momentum Strategy",
"status": "completed",
"startDate": "2024-01-01T00:00:00Z",
"endDate": "2024-01-31T23:59:59Z",
"initialBalance": 100000,
"finalBalance": 115000,
"results": {
"totalTrades": 45,
"winRate": 62.22,
"netProfit": 15000,
"profitFactor": 6.0,
"sharpeRatio": 1.8,
"maxDrawdown": 5.2
},
"createdAt": "2024-01-15T11:00:00Z",
"completedAt": "2024-01-15T11:05:00Z"
},
{
"id": "507f1f77bcf86cd799439014",
"algorithmId": "507f1f77bcf86cd799439011",
"algorithmName": "RSI Momentum Strategy",
"status": "running",
"progress": 65,
"startDate": "2023-01-01T00:00:00Z",
"endDate": "2023-12-31T23:59:59Z",
"initialBalance": 100000,
"createdAt": "2024-01-15T12:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 2,
"totalPages": 1
}
}

Examples

Get All Backtests

cURL:

curl -X GET "https://api.x3algo.com/api/backtests" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

JavaScript:

const response = await fetch('https://api.x3algo.com/api/backtests', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
})

const { data: backtests, pagination } = await response.json()
console.log(`Found ${pagination.total} backtests`)

Python:

response = requests.get(
'https://api.x3algo.com/api/backtests',
headers={'Authorization': f'Bearer {access_token}'}
)

data = response.json()
backtests = data['data']
print(f"Found {data['pagination']['total']} backtests")

Filter by Algorithm

JavaScript:

const algorithmId = '507f1f77bcf86cd799439011'

const response = await fetch(
`https://api.x3algo.com/api/backtests?algorithmId=${algorithmId}&status=completed`,
{
headers: { 'Authorization': `Bearer ${accessToken}` }
}
)

const { data: backtests } = await response.json()

// Find best performing backtest
const best = backtests.reduce((max, bt) =>
bt.results.profitFactor > max.results.profitFactor ? bt : max
)

console.log('Best Backtest:', best.id)
console.log('Profit Factor:', best.results.profitFactor)

Get Recent Backtests

JavaScript:

const response = await fetch(
'https://api.x3algo.com/api/backtests?sort=createdAt&order=desc&limit=5',
{
headers: { 'Authorization': `Bearer ${accessToken}` }
}
)

const { data: recentBacktests } = await response.json()

for (const bt of recentBacktests) {
console.log(`${bt.algorithmName}: ${bt.status} (${bt.progress || 100}%)`)
}