Agent Configuration
Each agent is configured at creation time via the Hub API. This page covers all configuration options.
Creating an Agent
POST /api/agents
Authorization: Bearer <token>
Content-Type: application/json
{
"symbol": "BTC/USDT",
"strategy_name": "momentum_breakout",
"interval_seconds": 1,
"live_mode": false,
"risk_params": {
"max_position_usd": 1000,
"stop_loss_pct": 2.0,
"take_profit_pct": 4.0,
"leverage": 1
}
}
Configuration Fields
| Field | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Trading pair (e.g., BTC/USDT, ETH/USDT) |
strategy_name | string | Yes | Algorithm name from Strategy Catalog |
interval_seconds | int | No | Tick interval in seconds (default: 1) |
live_mode | bool | No | false = paper trading, true = live execution |
risk_params | object | No | Risk management configuration (see below) |
Risk Parameters
The risk_params JSONB field controls position sizing and risk management:
| Parameter | Type | Description |
|---|---|---|
max_position_usd | float | Maximum position size in USD |
stop_loss_pct | float | Stop-loss percentage (e.g., 2.0 = 2%) |
take_profit_pct | float | Take-profit percentage (e.g., 4.0 = 4%) |
leverage | int | Leverage multiplier (1-125x) |
Dynamic TP/SL
When the LLM supervisor is enabled, it can dynamically adjust stop-loss and take-profit levels based on:
- ATR-based stop-loss calculation
- Automated risk:reward ratio
- Market condition changes
The supervisor runs on a configurable cycle (every N ticks on open positions).
LLM Configuration
The LLM provider is configured via secrets (environment variables or encrypted DB storage):
| Secret Key | Purpose |
|---|---|
LLM_PROVIDER | Provider name: openai, anthropic, deepseek, gemini |
LLM_MODEL | Model name (e.g., gpt-4o, claude-3-opus, deepseek-chat) |
OPENAI_API_KEY | OpenAI API key |
ANTHROPIC_API_KEY | Anthropic API key |
DEEPSEEK_API_KEY | DeepSeek API key |
GEMINI_API_KEY | Google Gemini API key |
LLM Planning Cycle
- Agent collects market data (candles, indicators, price history)
- LLM analyzes the data and selects the best strategy
- LLM defines lookback period, threshold, and max loss percentage
- Strategy runs on the selected parameters
- LLM reasoning is captured for audit trail
Execution Modes
Paper Trading (Default)
live_mode: false- Positions tracked in-memory
- No real orders placed
- Full P&L simulation
Live Trading
live_mode: true- Requires
HASHKEY_API_KEYandHASHKEY_SECRET - Orders placed on HashKey Global exchange
- Set
HASHKEY_SANDBOX: truefor sandbox testing
Per-Agent Secrets
Override user-level secrets for specific agents:
POST /api/agents/{id}/secrets
Authorization: Bearer <token>
Content-Type: application/json
{
"key_name": "OPENAI_API_KEY",
"encrypted_value": "<AES-encrypted-value>"
}
Secret resolution order (first match wins):
- Ephemeral override (per-request, never stored)
- Agent-specific override (encrypted in DB)
- User-level secret (encrypted in DB)
- Process
.envfallback
Agent Lifecycle
| Status | Description |
|---|---|
creating | Docker container being provisioned |
running | Trading loop active |
stopped | Manually stopped, container preserved |
error | Failed to start or crashed |
Management Commands
# List all agents
GET /api/agents
# Get agent details
GET /api/agents/{id}
# Stop an agent
POST /api/agents/{id}/stop
# Delete an agent (removes container)
DELETE /api/agents/{id}
Log Levels
Agent logs use structured levels for filtering:
| Level | When |
|---|---|
init | Agent startup and config loading |
llm | LLM planning/supervisor calls |
start | Trading loop started |
tick | Each price tick processed |
action | Position opened or closed |
sl_tp | Stop-loss or take-profit triggered |
stop | Agent stopped |
error | Error occurred |
warn | Warning condition |
supervisor | LLM supervisor adjustment |
