Build an AI trading agent
An agent is only as good as what its tools return. Feed it computed state instead of raw data and the context goes to the decision: every ticker × every signal, queryable by the model itself.
The recipe
1. Give the model the market
One config block installs the MCP server in Claude, ChatGPT, Cursor, or any MCP runtime. Scans, tickers, series, news, and webhooks become tools the model calls itself.
{
"mcpServers": {
"tickerbot": {
"command": "npx",
"args": ["-y", "@tickerbot/mcp-server"],
"env": { "TICKERBOT_API_KEY": "tb_live_…" }
}
}
}2. Ask in English
The agent compiles the question into tool calls on its own — one prompt, one scan, computed answers back.
You: which large caps went oversold this week while holding their 200-day?
Agent → tickerbot_scan({ q: "rsi_14 < 30 AND above_sma_200
AND market_cap > 1e10" })
← { count: 7, results: [ { ticker, price, rsi_14, … } × 7 ] }
Agent: Seven names match — here's the list, and what stands out…3. Write the agent loop
For a headless agent: market state from Tickerbot, decisions from the model, execution through your broker's API as a separate tool you control.
// Each cycle: state → decision → (maybe) action. Execution stays
// behind YOUR broker tool — Tickerbot's tools are read-only market state.
const tools = [...tickerbotTools, brokerTool, portfolioTool]
async function cycle() {
const decision = await model.run({
system: AGENT_POLICY, // your rules: sizing, risk, approvals
prompt: 'Review current positions and the watchlist. Act if warranted.',
tools,
})
log(decision) // every action auditable
}
setInterval(cycle, 5 * 60 * 1000)That separation — execution behind your own broker tool, every action logged — is what makes an agent auditable.
4. Let the market interrupt
Subscribe the conditions the agent cares about and wake it on the webhook instead of polling. The market becomes the scheduler.
curl -s -X POST https://api.tickerbot.io/v2/scan/subscribe \
-H "Authorization: Bearer $TICKERBOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "q": "rsi_14 < 30 AND above_sma_200 AND market_cap > 1e10",
"target_url": "https://your-agent.example.com/wake" }'
# handler: app.post('/wake', () => cycle())Endpoints used
| Endpoint | Role in this build |
|---|---|
MCP: @tickerbot/mcp-server | Every endpoint as a native tool call: Claude, ChatGPT, Cursor, any runtime |
GET /docs/agents | Copy-paste tool definitions for Claude, OpenAI, and MCP, auto-generated |
POST /v2/scan | The agent’s workhorse: any question over the whole market, one call |
POST /v2/scan/subscribe | Event-driven agents: wake on state change instead of polling |