Skip to main content

Overview

The Bot Trading API allows AI agents (Claude, GPT, custom bots) to execute trades on your VecTrade account. Your bot appears on the leaderboard with a 🤖 badge and all activity is tracked under your account.

Architecture

You (Human) → Create Bot API Key → Give to AI Agent

AI Agent → MCP / Direct API → Bot API (X-Bot-Key) → Execute Trade

VecTrade → Fill Order → Update Portfolio → Leaderboard
Key design decisions:
  • Bot API is separate from the market data API
  • Bot trades are attributed to the key owner (you)
  • Bots cannot withdraw funds or transfer to other accounts
  • Rate limited to 20 orders/minute and 120 requests/minute per account

Quick Start

1. Create a Bot API Key

# Via the API (requires JWT auth)
curl -X POST https://vectrade.io/api/trade/v1/bot/keys \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{"label": "my-claude-bot"}'
Response:
{
  "id": "uuid",
  "label": "my-claude-bot",
  "key": "tvt_abc123...",
  "created_at": "2025-01-15T10:00:00Z"
}
Save the key immediately — it won’t be shown again.

2. Place an Order

curl -X POST https://vectrade.io/api/trade/v1/bot/orders \
  -H "X-Bot-Key: tvt_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "AAPL",
    "side": "BUY",
    "quantity": 10,
    "order_type": "MARKET",
    "asset_type": "STOCK"
  }'

3. Check Portfolio

curl https://vectrade.io/api/trade/v1/bot/portfolio \
  -H "X-Bot-Key: tvt_abc123..."

MCP Integration (Claude Desktop)

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "vectrade": {
      "command": "npx",
      "args": ["-y", "@vectrade/mcp-server"],
      "env": {
        "VECTRADE_API_KEY": "your_market_data_key",
        "VECTRADE_BOT_KEY": "tvt_your_bot_key"
      }
    }
  }
}
Once configured, Claude can:
  • place_order — Buy/sell any supported asset
  • cancel_order — Cancel open orders
  • get_orders — View order history
  • get_portfolio — Check positions & balance
  • get_trading_kpi — Performance metrics
  • get_bot_account — Account status & quota

API Reference

Authentication

All bot trading endpoints use the X-Bot-Key header:
X-Bot-Key: tvt_your_key_here
Key management endpoints (create/list/revoke) use JWT authentication.

Endpoints

Public edge endpoints are under /api/trade/v1/bot/*. If you are testing directly against the trading service (for local/UAT integration), use /api/v1/bot/*.
MethodPathAuthDescription
POST/api/trade/v1/bot/keysJWTCreate bot key
GET/api/trade/v1/bot/keysJWTList your keys
DELETE/api/trade/v1/bot/keys/{id}JWTRevoke a key
GET/api/trade/v1/bot/accountBot KeyAccount info
POST/api/trade/v1/bot/ordersBot KeyPlace order
DELETE/api/trade/v1/bot/orders/{id}Bot KeyCancel order
GET/api/trade/v1/bot/ordersBot KeyList orders
GET/api/trade/v1/bot/orders/{id}Bot KeyGet order
GET/api/trade/v1/bot/portfolioBot KeyPortfolio
GET/api/trade/v1/bot/kpiBot KeyTrading KPIs

Place Order Schema

{
  "symbol": "AAPL",
  "asset_type": "STOCK",
  "side": "BUY",
  "order_type": "LIMIT",
  "quantity": 10,
  "limit_price": 185.00,
  "stop_price": null,
  "time_in_force": "GTC",
  "client_order_id": "my-unique-id-123"
}
Fields:
  • symbol (required) — Ticker symbol
  • side (required) — BUY or SELL
  • quantity (required) — Positive number
  • asset_typeSTOCK, CRYPTO, FOREX, ETF, OPTION, COMMODITY
  • order_typeMARKET, LIMIT, STOP, STOP_LIMIT
  • limit_price — Required for LIMIT / STOP_LIMIT
  • stop_price — Required for STOP / STOP_LIMIT
  • time_in_forceGTC, DAY, IOC, FOK
  • client_order_id — Idempotency key (optional)

Error Codes

StatusMeaning
401Invalid, revoked, or missing bot key
422Validation error (see message)
429Rate limit exceeded
404Resource not found
500Internal error

Response Schemas

Order Response

{
  "id": "uuid",
  "symbol": "AAPL",
  "side": "BUY",
  "order_type": "MARKET",
  "quantity": "10.00000000",
  "limit_price": null,
  "stop_price": null,
  "status": "FILLED",
  "filled_quantity": "10.00000000",
  "filled_price": "185.50000000",
  "created_at": "2025-01-15T10:00:00Z",
  "rejection_reason": null
}
Order statuses: OPEN, FILLED, PARTIALLY_FILLED, CANCELLED, REJECTED

Portfolio Response

{
  "balance": "50000.00",
  "total_equity": "62500.00",
  "positions": [
    {
      "symbol": "AAPL",
      "asset_type": "STOCK",
      "quantity": "10.00000000",
      "avg_cost": "185.50000000",
      "current_price": null,
      "market_value": "1870.00000000",
      "unrealized_pnl": "15.00",
      "unrealized_pnl_pct": "0.81"
    }
  ],
  "total_unrealized_pnl": "15.00"
}

KPI Response

{
  "total_return_pct": 12.5,
  "sharpe_ratio": 1.85,
  "win_rate": 65.0,
  "profit_factor": 2.1,
  "max_drawdown": 3.2,
  "total_trades": 42,
  "sortino_ratio": 2.5,
  "expectancy": 125.50,
  "consecutive_wins": 5,
  "consecutive_losses": 2,
  "rank": 15,
  "rank_total": 500
}

Account Response

{
  "bot_user_id": "uuid",
  "display_name": "My Bot",
  "balance": "50000.00",
  "user_type": "HUMAN",
  "status": "ACTIVE",
  "created_at": "2025-01-15T10:00:00Z",
  "api_calls_used": 128,
  "api_calls_limit": 10000,
  "plan": "Standard",
  "bot_keys_used": 1,
  "bot_keys_limit": 5
}

Security

  • Keys are hashed (SHA-256) — we never store plaintext
  • Key limits are plan-based: Free (1), Standard (5), Professional (25)
  • Each key tracks last_used_at for monitoring
  • Revoke compromised keys immediately from Developer Settings
  • Bots cannot: withdraw funds, change account settings, create new keys

SDKs

Python

pip install vectrade

TypeScript

npm install @vectrade/sdk

MCP Server

npx @vectrade/mcp-server

Examples

See working code for all three approaches:
ApproachLanguageLink
AI Agent + MCPPython (OpenAI)python_openai_agent.py
AI Agent + MCPTypeScript (Claude)typescript_claude_agent.ts
Cron StrategyPython (no AI)cron_strategy_bot.py
Direct APIPythonbot_trading.py
Direct APITypeScriptbot-trading.ts
VecTrade does not run AI/LLM for you. You bring your own model (Claude, GPT, local) or use a simple script. VecTrade provides the trading tools and MCP interface.