Get Algorithm
Retrieve detailed information about a specific trading algorithm.
Endpoint
GET /api/trading/algorithms/:id
Authentication
Requires authentication via Bearer token.
Authorization: Bearer <access_token>
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Algorithm ID |
Response
Success (200 OK)
{
"id": "507f1f77bcf86cd799439011",
"userId": "507f191e810c19729de860ea",
"name": "RSI Momentum Strategy",
"status": "active",
"active": true,
"strategyType": "momentum",
"timeframe": "15m",
"symbols": ["NSE:RELIANCE", "NSE:TCS"],
"positionSizing": {
"method": "risk_based",
"riskPercentage": 1,
"stopLossPercentage": 2
},
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"confirmationCandles": 1,
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}
]
},
"exitConditions": {
"stopLoss": {
"type": "percentage",
"value": 2
},
"takeProfit": {
"type": "risk_reward",
"ratio": 3
}
},
"riskParameters": {
"maxPositionSize": 10,
"stopLoss": 2,
"takeProfit": 6,
"maxDailyLoss": 5,
"maxOpenPositions": 3,
"riskRewardRatio": 3
},
"executionSettings": {
"mode": "paper",
"exchange": "NSE",
"orderType": "limit",
"slippage": 0.1
},
"performance": {
"totalTrades": 45,
"winningTrades": 28,
"losingTrades": 17,
"totalProfit": 18000,
"totalLoss": 10000,
"winRate": 62.22,
"profitFactor": 1.8,
"sharpeRatio": 1.5,
"maxDrawdown": 8.5,
"averageWin": 642.86,
"averageLoss": 588.24
},
"createdAt": "2024-01-10T10:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"lastExecution": {
"timestamp": "2024-01-15T10:25:00Z",
"status": "success",
"result": "No signals generated"
}
}
Errors
| Status | Code | Message |
|---|---|---|
| 401 | UNAUTHORIZED | Authentication required |
| 403 | FORBIDDEN | Access denied (not your algorithm) |
| 404 | NOT_FOUND | Algorithm not found |
Examples
Get Algorithm Details
cURL:
curl -X GET https://api.x3algo.com/api/trading/algorithms/507f1f77bcf86cd799439011 \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
JavaScript:
const algorithmId = '507f1f77bcf86cd799439011'
const response = await fetch(
`https://api.x3algo.com/api/trading/algorithms/${algorithmId}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
)
const algorithm = await response.json()
console.log('Algorithm:', algorithm.name)
console.log('Win Rate:', algorithm.performance.winRate + '%')
Python:
algorithm_id = '507f1f77bcf86cd799439011'
response = requests.get(
f'https://api.x3algo.com/api/trading/algorithms/{algorithm_id}',
headers={'Authorization': f'Bearer {access_token}'}
)
algorithm = response.json()
print(f"Algorithm: {algorithm['name']}")
print(f"Win Rate: {algorithm['performance']['winRate']}%")
Related
- List Algorithms
- Update Algorithm
- Delete Algorithm
- Get Algorithm Performance endpoint (coming soon)