Build a price-monitoring trading bot in Claude Code

Claude Code is Anthropic's terminal-native coding agent. With Hive's MCP installed via 'claude mcp add', Claude Code can read live price, funding-rate, order-book, and liquidity data across supported exchanges and DEX pools, then scaffold a complete trading-monitor bot in TypeScript or Python. The recipe combines get_funding_rates, get_orderbook, get_ticker, and get_pool_info into a polling loop that computes spreads in your own code. The grounded fetched_at timestamps mean the bot reasons over real exchange state, not training-cutoff prices.

Client: Claude Code · Workflow: Trading bot

Hive tools used

  • get_funding_ratesFunding rates across 20+ perp exchanges (Binance, Bybit, OKX, Hyperliquid, dYdX, etc.) with normalized intervals.
  • get_orderbookExchange order-book snapshots for spread and depth calculations.
  • get_tickerExchange ticker data for last price, bid, ask, volume, and timestamp checks.
  • get_pool_infoDEX pool liquidity and pricing context for on-chain legs.

Steps

  1. Install Hive in Claude Code

    Run the claude mcp add command from any project root. The --scope user flag installs Hive globally; --scope project commits the config to the repo's .mcp.json so teammates inherit it.

    claude mcp add --transport http hive https://mcp.hiveintelligence.xyz/mcp \
      --header "Authorization: Bearer YOUR_HIVE_API_KEY" \
      --scope user
  2. Bootstrap the bot project

    In a new project directory, run "claude code" and ask Claude to scaffold a Node.js project with TypeScript, dotenv, and an HTTP client. Claude generates package.json, tsconfig, and the entry file.

  3. Wire in Hive tool calls

    Ask Claude to "add a function that calls Hive get_orderbook and get_ticker every 30 seconds, compares Binance and OKX BTC/USDT spreads, and logs opportunities over 0.3% after a liquidity check." Claude writes the polling loop, hits the Hive REST endpoint with proper auth, and parses the structured responses.

  4. Add filter logic

    Layer in safety checks — minimum liquidity, blacklist of recently-relisted tokens, max position size per opportunity. Claude knows the Hive execution contract and tool schemas because they are self-documenting through tools/list.

  5. Test with paper trading

    Ask Claude to write a paper-trading harness that simulates fills based on Hive's reported liquidity. Run it for 24-48 hours before considering live capital. The fetched_at timestamps in Hive execution metadata are the audit trail for backtests.

  6. Add alerting and deploy

    Wire Discord or Telegram webhooks for opportunities passing your edge × liquidity threshold. Deploy as a long-running process via PM2, Fly.io, or Railway. Claude can write the deployment manifest in the same session.

Example prompt

Scaffold a Node.js trading monitor that uses Hive to detect cross-exchange spot arbs over 0.3% edge with at least $50K liquidity. Alert to Discord. Use TypeScript.

Example output shape

Example output shape:

I'll scaffold this in TypeScript with three files:

1. src/hive.ts - typed wrapper around Hive's REST endpoint
2. src/monitor.ts - polling loop calling get_orderbook, get_ticker, and get_funding_rates
3. src/discord.ts - webhook alerter with rate-limit handling

Key logic in monitor.ts:
- Compute: bid/ask spread by venue, funding-rate spread, and estimated executable depth
- Filter: edge threshold, minimum liquidity, and fresh fetched_at timestamps
- De-dupe: avoid alerting on the same pair too often

Run the scaffold in paper-trading mode first. Only connect live execution after adding venue-specific risk limits, error handling, and position sizing.

Related glossary terms

Related recipes

See also