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, and liquidity data across 20+ exchanges (via Hive's CCXT upstream) and scaffold a complete trading-monitor bot in TypeScript or Python. The recipe combines get_funding_rates, get_arbitrage_spot_perp, and get_arbitrage_cross_exchange — Hive's curated arbitrage tools — into a single polling loop that emits alerts when a profitable arb opens. The grounded fetched_at timestamps mean the bot reasons over real exchange state, not training-cutoff prices.

Client: Claude Code · Use case: Trading bot

Hive tools used

  • get_funding_ratesFunding rates across 20+ perp exchanges (Binance, Bybit, OKX, Hyperliquid, dYdX, etc.) with normalized intervals.
  • get_arbitrage_spot_perpSpot-perp basis arbitrage opportunities, sorted by edge × liquidity.
  • get_arbitrage_cross_exchangeCross-exchange spot price discrepancies with depth-aware liquidity calculations.
  • analyze_coinSynthesized coin briefing — used to filter the universe before running arb scans.

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's get_arbitrage_cross_exchange every 30 seconds and logs opportunities with edge over 0.3%." Claude writes the polling loop, hits the Hive REST endpoint with proper auth, and parses the structured response.

  4. Add filter logic

    Layer in safety checks — minimum liquidity, blacklist of recently-relisted tokens, max position size per opportunity. Claude knows the Hive response envelope (because tool descriptions are self-documenting via tools/list) and writes the filters correctly on the first try.

  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 every tool response 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.

Sample synthesized output

I'll scaffold this in TypeScript with three files:

1. src/hive.ts — typed wrapper around Hive's REST endpoint
2. src/monitor.ts — 30-second polling loop calling get_arbitrage_cross_exchange
3. src/discord.ts — webhook alerter with rate-limit handling

Key logic in monitor.ts:
- Filter: edge > 0.3%, liquidity > $50K, both legs healthy (per Hive's market_health flag)
- De-dupe: don't alert on the same arb pair within 5 minutes
- Log every poll with fetched_at timestamp for backtesting

I've written the scaffold and a 24-hour paper-trading harness. Run with `bun run monitor` after setting HIVE_API_KEY and DISCORD_WEBHOOK in .env. Want me to add Telegram support or wire in funding-rate arbs as a second detector?

Related glossary terms

Related recipes

See also