AI trading bots are quickly moving from niche tools to a new standard in algorithmic trading. OpenClaw, a popular open-source AI agent framework, takes this further by letting you define trading strategies in natural language and deploy them across multiple data sources and exchanges. With faster hypothesis testing and built-in parallelisation, OpenClaw agents offer a practical edge in an increasingly competitive market.
In this guide, we will walk through how to set up OpenClaw with CoinGecko API as the data intelligence layer, and build several trading strategies including cross-exchange arbitrage detection, on-chain token discovery, copy trading, and news-based sentiment trading.

How to build an OpenClaw trading Agent
To build an OpenClaw trading agent, you need a three-layer architecture. This setup consists of a data layer powered by a comprehensive crypto market data API like the CoinGecko API, an intelligence layer where the OpenClaw agent analyses and decides, and an execution layer that connects to exchanges. These three layers work together in real time.

Data Layer
CoinGecko API is a strong choice for the data layer because it covers 30M+ crypto assets across 1,700+ exchanges and 250+ blockchain networks, spanning both CEX and DEX markets. This breadth matters for trading agents because opportunities can emerge on any chain or exchange, and a larger token universe gives your agent more surface area to find profitable setups. With it, your agent can access real-time prices, onchain pool analytics, trending tokens, top onchain traders, historical OHLCV data, and curated crypto news, all through a single API.
Intelligence layer
This is the brain of your system. It houses the OpenClaw agent, along with any orchestrator or sub-agents, and determines the behaviour and scope of your trading strategies.
The agent analyses market and on-chain data, evaluates strategies, and adapts its decisions dynamically.
Execution Layer
This layer connects your agent to the market. It handles API integrations with exchanges, executes trades, and monitors open positions. This ensures that decisions made by the intelligence layer are translated into real-world actions.
Prerequisites
To build your OpenClaw trading bot, you are going to need:
- Node.js v22+
- OpenClaw installed and running with Telegram connected
- An LLM API Key. This guide uses Anthropic's Claude Sonnet 4.6.
- A CoinGecko API key. Some of the strategies in this guide use endpoints exclusive to paid plans. If you don't have a CoinGecko API key yet, you can start by signing up for a free Demo API key.
- CoinGecko CLI installed
- CoinGecko API Skill installed
- Exchange API Key. You will need this for live trading only. This guide uses paper trading throughout.
- Crypto wallet private key. Required only for live onchain trading. For security, consider using a fresh wallet with limited funds.
Note: For security purposes, it is strongly recommended that you install OpenClaw on a secondary machine, a Raspberry Pi, or a VPS / cloud instance.
How to install OpenClaw and connect it to Telegram
If you already have OpenClaw installed feel free to skip ahead to setting up CoinGecko API with your OpenClaw. Else, you should first start by installing Node.js and npm. Please read Node.js’s official documentation for the right set of commands for your environment.
Restart your shell/terminal and proceed to install OpenClaw using one of the commands below:
Proceed with the onboarding by selecting “Yes” on the following question:

OpenClaw will guide you through the initial setup steps. Select Telegram as your messaging provider and choose your preferred LLM provider. In this guide, we use Anthropic’s Claude Sonnet 4.6. You can skip the remaining configuration options for now.
You can now control your OpenClaw agent via the following URL: http://127.0.0.1:18789/
If you're using Linux, you can run openclaw tui to interact with your agent via the CLI.
To connect your agent to Telegram, create a new bot by messaging @BotFather and send it an initial message. It will reply indicating that it is not yet connected, and provide a command for OpenClaw.
Run it in your CMD or terminal, or ask OpenClaw to complete the pairing process with the given code:
You should now be able to interact with OpenClaw directly through your Telegram.

How to Set Up CoinGecko API With OpenClaw Trading Agent
CoinGecko API offers several ways to connect with OpenClaw, including MCP servers, REST API, x402 pay-per-use endpoints, and the command-line interface (CLI). For trading agents, the CLI is the recommended approach because it outputs machine-readable JSON, supports real-time WebSocket streaming, and is significantly more token-efficient than MCP for bulk data operations.
First, start by installing the CoinGecko CLI:
Alternatively, ask your agent to install it on your behalf.
Once installed, the agent can already interact with the CLI on its own. The CLI is designed with built-in help flags, dry-run modes, and structured JSON outputs that make it naturally agent-friendly. However, for more advanced use cases where the CLI commands alone may not cover the full scope of CoinGecko API's 80+ endpoints, you can install the CoinGecko API Agent Skill. This teaches the agent the full API surface, enabling it to write custom scripts that interact with CoinGecko API directly for highly customized workflows.
To do so, run the following command from your CLI, or ask OpenClaw to run it for you via Telegram.
This will install the Skill under the following path: ~/.openclaw/workspace/skills/coingecko-api. Keep this structure in mind, as this is where we will later define and extend our own custom skills.
Finally, since CoinGecko requires authentication, you will need to save your API key before using the CLI. Run cg auth in your terminal or command prompt and paste in your API key.
How to set up trading API access
To enable our bot to execute trades on our behalf, it will need access to a cryptocurrency exchange and potentially a wallet as well.
To securely provide the agent with the necessary credentials, we will create a .env file to store all sensitive information, such as exchange API keys and private wallet addresses:
Use clear, descriptive variable names so the agent can easily understand what each credential is for:
OpenClaw will read these variables to authenticate with your exchange and execute trades. Ensure that your API Key is properly scoped and does not include dangerous permissions such as withdrawals.
As a best practice, consider restricting API access to your machine’s IP. To confirm that the connection is working, we can ask OpenClaw to fetch our account balance.
We will later create detailed instructions for how we want our agent to trade on our behalf, including clear rules on when to use live funds versus paper trading.
How to Detect Cross-Exchange Crypto Arbitrage Opportunities with OpenClaw
To detect cross-exchange arbitrage opportunities, your agent needs a real-time benchmark price to compare against individual exchange prices. CoinGecko API's WebSocket streaming provides an aggregated market benchmark drawn from thousands of exchanges, giving your agent an accurate snapshot of where the market actually is at any given moment, rather than relying on a single exchange's price in isolation.
Arbitrage windows are typically short-lived and highly competitive, which is why real-time streaming matters more than polling here.
To enable our agent to identify arbitrage opportunities, we need to provide it with clear, configurable settings for our arbitrage bot. This includes important information such as whether to run the bot in paper_trading or live mode, as well as the amount to spend per trade.
Under ~/.openclaw/workspace, create a new file called strategies.yaml. This is where we’re going to store some key configurable variables for our trading strategies.
Settings defined under the general section apply to all types of bots, while settings under the arbitrage section are specific to our arbitrage bot only. The agent can edit these parameters for you.
Next, we need to tell our agent how to use this configuration. We can do so by creating a new skill. Create a new markdown file under ~/.openclaw/workspace/skills/arbitrage/SKILL.md.
This will serve as the core set of instructions for our arbitrage agent, defining exactly how it should behave, make decisions, and execute trades on our behalf.
This skill teaches our agent to use CoinGecko’s websocket API in order to capitalize on real-time arbitrage opportunities.
Before OpenClaw can run the arbitrage agent, we must first ensure it is fully aware of the project environment and all key details specific to our setup and folder structure. This reduces unnecessary back-and-forth and makes each run more efficient and cost-effective.
Edit your ~/.openclaw/workspace/TOOLS.md file to include the following information:
The final part defines how the agent should apply the Skill in practice. This is important because, depending on the model used, your agent may choose to interact directly with the CLI or call API endpoints on its own. While flexible, this approach can be highly token-intensive, as it relies on continuous LLM usage.
To avoid unnecessary token consumption for tasks that can be handled more efficiently, we give the agent the option to decide how to execute each request.
Now simply ask your agent to execute the skill.

Once an opportunity is found, the agent will ping you on Telegram.

Note: Cross-exchange arbitrage opportunities are typically captured within milliseconds by institutional market makers running co-located servers, which means the spread is often competed away before most agents can execute. Thus, this approach is best used as a learning tool rather than a live trading strategy.
How to Use OpenClaw to Discover Trending Onchain Tokens Early
Discovering early-stage onchain tokens requires scanning DEX pools across multiple networks, filtering out honeypots and low-liquidity traps, and analysing promising candidates in real time. CoinGecko API covers 30M+ onchain tokens across 250+ blockchain networks, and its Pools Megafilter endpoint lets your agent programmatically screen millions of pools using 25+ filter conditions including safety and quality checks that would take hours to apply manually.
Start by adding a new section called onchain_discovery inside ~/.openclaw/workspace/config/strategies.yaml
Feel free to adjust these parameters to suit your trading style, or encourage your agent to experiment with different values until a winning strategy is found.
Next, we need to define how the agent should interpret and execute this strategy. Add a new Skill under ~/.openclaw/workspace/skills/onchain-disc/SKILL.md:
Once the configuration and the skill are in place, simply ask your agent to start the on-chain discovery:

The agent will run in the background and alert us on Telegram whenever a buying opportunity is identified or a stop-loss or take-profit is reached.
We can also query the PNL at any moment:

To enable live trading, add a wallet private key to the .env file and ask your agent to switch the mode to live. For security, consider using a fresh wallet. Always test your strategy thoroughly and start with small, incremental amounts.
How to Build an OpenClaw Crypto Copy Trading Agent with Onchain Data
Building a copy trading agent starts with identifying which traders are consistently profitable and worth following. CoinGecko API's Top Token Traders endpoint surfaces the highest-performing wallets for any given token, returning wallet addresses, PnL data, buy/sell counts, and volume, which gives your agent the raw signal it needs to evaluate and rank traders. Because CoinGecko covers on-chain data across 250+ blockchain networks, your agent isn't limited to popular chains and can find opportunities on less crowded networks where fewer traders are competing.
We’ll also extend the strategy to scan trending token pools, ensuring the agent isn’t limited to a single asset and can continuously discover new traders across emerging opportunities.
Start by adding a new copy_trading section under ~/.openclaw/workspace/config/strategies.yaml:
Now, let’s define a new Skill under ~./openclaw/workspace/skills/copy-trader/SKILL.md:
This skill teaches our agent how to discover promising traders, analyse their results, and recommend the best trader for us to copy. The approach above ensures the agent always checks in and confirms before executing the copy-trading.
As before, simply ask your agent to start the strategy:

To start copying, select one of the 5 top traders recommended:

How to Build a Crypto News-Based Trading Agent With OpenClaw
A news-based crypto trading agent needs a reliable, structured source of market news rather than scraping the open internet. CoinGecko API's News endpoint delivers curated headlines from 100+ trusted crypto news sources in 30+ languages, with each article tagged to related coins, making it straightforward for your agent to connect news events to specific tokens and inform trading decisions.
Let’s define configuration options for this bot by adding a new news_trading section under ~/.openclaw/workspace/config/strategies.yaml
As before, we’ll need to define a new Skill that teaches our agent how to listen to news feeds and interpret the output. Under ~/.openclaw/workspace/skills/news-trader/SKILL.md add your desired instructions, or use the skill template below:
Start the agent as before, specifying which trading strategy to execute:

How to Backtest and Automate Crypto Trading Strategies With OpenClaw
Using OpenClaw alongside the CoinGecko CLI can fully automate the backtesting workflow. The CLI is particularly well-suited here because it pulls bulk historical data in a single terminal command, and the agent can write scripts to process the output rather than reading every data point through the LLM context window. This keeps token consumption low and focused on reasoning rather than data ingestion, which both improves performance and reduces operating costs.
Add a new section to our main configuration file:
Now let’s define the backtesting skill, under ~/.openclaw/workspace/skills/backtesting/SKILL.md
To get started, simply describe what kind of strategy you are interested in backtesting. You can also leverage the agent's own knowledge in creating a test case if you don’t have one in mind.

The agent will recommend tweaks and will be on stand-by for future runs. Once a winning strategy is identified, the agent will confirm whether you’re ready to test this strategy with live market data in paper_trading mode:

What Are the Risks of AI Crypto Trading Agents?
AI crypto trading agents are powerful tools, but they carry real risks that you should understand before deploying any strategy with real capital.
-
AI hallucination and context drift: AI agents can and will make mistakes. They may misinterpret your intent, poison their own context window over long sessions, or confidently execute a flawed strategy. Overconfidence is also part of this problem – the fact that an AI is making decisions does not make those decisions correct. Always run your agent under close supervision, especially during early iterations.
-
Not all models are the same: Smaller models can hit context limits quickly, which degrades decision quality. Larger models are more capable but cost more to operate. Choose a model that balances accuracy with your budget, and monitor token consumption as strategies grow in complexity.
-
Security Risk: You are sharing API keys and potentially wallet access with your agent. Never grant withdrawal permissions. Restrict API access to your machine's IP where possible. Always start with paper trading and handle credentials with extreme care.
Disclaimer: This article is for educational purposes only and does not constitute financial or trading advice. Cryptocurrency trading involves significant risk of loss. Always do your own research and never trade with funds you cannot afford to lose.
Quick Start: Clone the Trading Agent Repo
If you want to get started quickly without building each strategy from scratch, you can clone the companion Github repository. It contains the full workspace structure, including all four trading strategy Skills (arbitrage, onchain discovery, copy trading, news trading), the backtesting configuration, and the CoinGecko API Skill, ready to configure with your own API keys.
Make sure all the Prerequisites above are installed.
- Clone this repo: git clone https://github.com/CyberPunkMetalHead/traderclaw-agentic-trading
- Configure your openclaw: openclaw configure
- Add your exchange and wallet credentials under: ~/.openclaw/credentials/.env
- Authenticate with the coingecko CLI: cg auth login
- Open Telegram and talk to your agent in natural language.
To extend its capabilities, add a new skill under skills.
Note that the agentic capabilities are as good as the model you’re using. The smaller the model, the more issues you’re likely to encounter.
Conclusion
By combining CoinGecko API as the data layer, OpenClaw as the AI decision engine, and your exchange APIs as the execution layer, you now have a complete architecture for building intelligent crypto trading agents.
What makes this setup particularly extensible is CoinGecko API's breadth. With coverage across 30M+ tokens, 1,700+ exchanges, and 250+ blockchain networks, your agent has a vast token universe to scan for opportunities, whether that's cross-exchange arbitrage, early-stage on-chain tokens, or news-driven price movements. Adding a new strategy is as simple as creating a new Skill and pointing it at the relevant CoinGecko endpoints.
To get started, you can sign up for a free CoinGecko API Demo key and clone the companion Github repository to have a working foundation within minutes.
When you are ready to unlock the more advanced strategies covered in this guide, consider upgrading to a paid API plan to gain access to exclusive endpoints such as the on-chain Pools Megafilter, Top Token Traders, and sub-second WebSocket streaming, enabling you to build more powerful trading strategies.
Alternatively, if you are not ready to commit to a subscription, you can also power your agent using CoinGecko's x402 pay-per-use endpoints, which allow your AI agents to call CoinGecko API on demand and pay for each request directly with USDC on the Base or Solana network.
Subscribe to the CoinGecko Daily Newsletter!


Ethereum Mainnet
Base Mainnet
BNB Smart Chain
Arbitrum
Avalanche
Fantom
Flare
Gnosis
Linea
Optimism
Polygon
Polygon zkEVM
Scroll
Stellar
Story
Syscoin
Telos
X Layer
Xai