Build AI Trading Agents with Bitquery Base Chain Data
BalanceUpdates sunsets 10 August 2026Queries on this page that use BalanceUpdates will stop working on 10 August 2026. Migrate to the Balances and Holders cubes, which return the current balance directly instead of summing deltas.
See the migration mapping for the query-by-query translation.
In this section, we will explore how to use Bitquery APIs and real-time streams to build AI-enabled trading agents for the Base blockchain.
For ready-made Bitquery-backed OpenClaw skills (installable via ClawHub—for example real-time BTC, USD charts, Pump.fun, Polymarket, and Solana stablecoin streams), see bitquery/openclaw-skills-master and the ClawHub CLI docs. This page focuses on a custom Base trading agent you build with Bitquery APIs directly.
Your AI Trading Agent's Mission:
You are a specialized trading agent operating on the Base blockchain, you will optimize an existing portfolio by analyzing and trading trending tokens using Bitquery data. Your primary goal is to identify profitable tokens in the Base ecosystem, assess wallet balances, and execute calculated swap decisions to enhance portfolio value.
prompt = (
f"Analyze the following Base chain token:\n"
f"Name: {token_data['name']}\n"
f"Symbol: {token_data['symbol']}\n"
f"Market Cap: {token_data['market_cap']}\n"
f"Liquidity (USD): {token_data['liquidity_usd']}\n"
f"Volatility: {token_data['volatility']}\n"
f"Top Holder Concentration (%): {token_data['holder_concentration']}\n"
f"Current Price: {token_data['current_price']}\n"
f"Trading Volume (24h): {token_data['trading_volume']}\n"
"\nBased on this data and Base ecosystem considerations, decide whether to 'Buy', 'Sell', 'Hold', or 'Avoid'. Only reply with one word: Buy, Sell, Hold, or Avoid."
)
Trading Decision Process
This is a rough draft of what an AI agent can do using Base chain on-chain and off-chain data. For live DEX prices grouped by theme, browse DEXrabbit Categories — for example AI Agents or Base Meme Coins.
- Use trending data to identify promising Base tokens with potential profit.
- For each trending token, retrieve detailed information to evaluate its market cap, liquidity, volatility, and security.
- Check the wallet balance to understand the available assets and decide on a safe percentage to invest.
- Execute swaps to acquire trending tokens on Base DEXs (Uniswap V3, PancakeSwap), ensuring the chosen amount.
- Continuously monitor token performance and adjust holdings to maximize profits. For this you can use Bitquery Real-time Streams to monitor Base token prices, new token creation and other activities with sub-second latency.