How to Build Your Own AI Trading Agent
From zero to autonomous AI trading in under an hour. No coding required.
Powered by OpenClaw — Open Source Autonomous AI Agents
Setting Up Your Machine
You need a computer that stays on 24/7. Your AI agent will be running around the clock, watching the markets and making trades. If the computer goes to sleep, the agent goes to sleep. Think of it like hiring an employee — they need a desk that's always available.
Crypto markets never close. They trade 24 hours a day, 7 days a week, 365 days a year. Your agent needs to be awake for all of it. A laptop you close at night won't work. You need something that just sits there, plugged in, running quietly.
- Operating system: macOS, Linux, or Windows (with WSL enabled)
- RAM: At least 4 GB
- Internet: Stable connection (speed doesn't matter much — even slow WiFi is fine)
- Terminal access: Built-in on Mac (Terminal app) and Linux. On Windows, install WSL first.
Install two things: Node.js (the engine that runs OpenClaw) and OpenClaw itself (the framework that powers your agent). Think of Node.js as the engine, and OpenClaw as the car.
OpenClaw is built with JavaScript, and Node.js is what lets JavaScript run on your computer (outside of a web browser). Without Node.js, OpenClaw can't run. It's like needing to install Java before playing Minecraft.
Open the Terminal app (search "Terminal" in Spotlight), then type these commands one at a time, pressing Enter after each:
# Step 2a: Install Homebrew (Mac's package manager — like an app store for developers)
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Step 2b: Install Node.js (the engine that runs OpenClaw)
$ brew install node
# Step 2c: Install OpenClaw (the AI agent framework)
$ npm install -g openclaw
# Step 2d: Make sure it worked
$ openclaw --version
# Step 2a: Install Node.js
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
$ sudo apt-get install -y nodejs
# Step 2b: Install OpenClaw
$ npm install -g openclaw
# Step 2c: Make sure it worked
$ openclaw --version
A version number printed on screen, something like:
openclaw v1.x.x
If you see that, congratulations — OpenClaw is installed and ready to go.
- "command not found" — Close your terminal and open a new one. Sometimes the terminal needs a restart to recognise new programs.
- "permission denied" or "EACCES" — Try adding
sudobefore the command:sudo npm install -g openclaw. It will ask for your password. - Old version of Node.js — Run
node --version. You need v18 or higher. If it's older, reinstall Node.js using the steps above. - Homebrew won't install — Make sure you have Xcode Command Line Tools. Run
xcode-select --installfirst.
Your agent needs a brain. That brain is a large language model (LLM) like Claude, GPT, or Gemini. You don't run the AI on your computer — you rent access to it through an API. An API key is like a password that lets your agent talk to the AI.
The AI is what makes your agent intelligent. Without it, OpenClaw is just an empty framework with nothing powering it. The API key is how you pay for and connect to that intelligence. Think of it like a phone plan — you need a SIM card (the API key) to make calls (use the AI).
We recommend Anthropic's Claude because it's the best AI for autonomous agents. It follows instructions precisely and rarely makes dangerous mistakes.
- Go to console.anthropic.com in your web browser
- Click "Sign Up" and create an account (email + password)
- Once logged in, look for API Keys in the left sidebar
- Click "Create Key"
- Give it a name like "OpenClaw Trading Agent"
- Copy the key immediately. It starts with
sk-ant-...and you will only see it once. Paste it somewhere safe (a notes app, a password manager).
- OpenAI (GPT-4) — Go to platform.openai.com, sign up, navigate to API Keys. Key starts with
sk-... - Google (Gemini) — Go to aistudio.google.com, click "Get API Key". Free tier available.
- Moonshot (Kimi) — A cheap alternative for routine tasks. Good as a fallback model to save money.
A long string of letters and numbers that looks something like this:
sk-ant-api03-aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890...
Keep this key safe. Don't share it publicly. Anyone who has it can use your API account and rack up charges.
Creating Your Agent
Boot up the OpenClaw gateway. This is the "control centre" for all your agents. It runs in the background on your computer and handles everything — talking to the AI, managing your agents, scheduling tasks, and more.
# Start OpenClaw for the first time
$ openclaw start
The first time you run this, OpenClaw will walk you through a setup wizard. It will ask you:
- Choose your AI provider — Select "Anthropic" (or whichever provider you got a key for in Step 3)
- Paste your API key — Paste the key you copied earlier
- Name your assistant — Give it any name you like. "Atlas", "Jarvis", "Nova", whatever feels right. This is just a display name.
A message confirming the gateway is running, usually at http://localhost:18789. You can open that URL in your web browser to see the OpenClaw dashboard — a chat interface where you can talk to your agent directly.
- "Port already in use" — Another program is using port 18789. Try
openclaw start --port 18790 - Gateway won't start — Check that Node.js is installed correctly:
node --version - API key rejected — Make sure you copied the full key. Go back to your AI provider's dashboard and create a new one if needed.
Create an agent. This is your AI employee. It gets its own name, its own workspace folder, its own memory, and its own set of instructions. You can create as many agents as you want later, but let's start with one.
# Create your main agent
$ openclaw agent create --name "atlas"
You can name it anything. "atlas", "jarvis", "nova", or your own name. This is your main agent — it manages everything. Later you'll add specialist sub-agents under it.
- Creates a workspace folder for your agent — this is where it stores files, notes, and research
- Creates a sessions folder — where it keeps memory of past conversations
- Registers the agent in your OpenClaw configuration file so the system knows it exists
OpenClaw will tell you exactly where these folders are when you create the agent. Write down the workspace path — you'll need it in the next step.
The SOUL.md file is the single most important thing you'll create. It's your agent's instruction manual, personality, and rulebook all in one. It's written in plain English — no code, no programming. Just clear instructions about who the agent is and what it should do.
Your agent reads this file every single time it wakes up. It's the first thing it looks at before making any decision.
Without a SOUL file, your agent is a genius with no direction. It can do anything, but it doesn't know what you want it to do. The SOUL file is how you shape its behaviour. The more specific and detailed you are, the better it performs.
Navigate to your agent's workspace folder (OpenClaw told you where it is in Step 5). Create a new file called SOUL.md using any text editor — TextEdit on Mac, Notepad on Windows, VS Code, or even the terminal.
Here are three ways to write it:
- Option A: Write it yourself in any text editor (recommended — you know your goals best)
- Option B: Ask ChatGPT or Claude: "Write me an OpenClaw SOUL.md file for a crypto trading bot that trades on Hyperliquid"
- Option C: Copy the example below and modify it to fit your needs
# ATLAS — AI Trading Assistant
You are ATLAS, an AI trading assistant specializing in Hyperliquid
perpetual futures.
## Your Mission
Trade cryptocurrency perpetual futures on Hyperliquid. Make
profitable trades while managing risk carefully.
## Rules
- Always use stop losses on every trade. No exceptions.
- Never risk more than 5% of the account on a single trade.
- Focus on BTC, ETH, and SOL — the most liquid assets.
- Use 5-10x leverage maximum.
- Send me a Telegram update after every trade.
## How You Work
1. Check market data every 5 minutes
2. Look for trading opportunities (momentum, funding rate
extremes, breakouts)
3. Enter trades with clear reasoning
4. Set stop loss and take profit immediately
5. Log every trade with your reasoning
## Personality
You are calm, analytical, and disciplined. You never chase
trades or get emotional.
- Be specific. "5-10x leverage" is much better than "moderate leverage". Numbers beat vague words.
- Include what NOT to do. "Never trade meme coins" or "Never hold a position for more than 24 hours" are just as important as positive instructions.
- Start simple. You can always add more rules later. A 10-line SOUL file that works is better than a 200-line one that confuses the agent.
- Use plain English. Write like you're explaining to a smart new employee on their first day. No jargon needed.
- Test and refine. Your SOUL file will evolve over time. Watch how your agent behaves and adjust the instructions.
Teaching It
Your agent is smart, but it's blind without tools. Right now it can think, but it can't see the internet, search for information, or read websites. In this step, you give it the ability to search the web.
To trade well, your agent needs to research markets, read news, study exchange documentation, and stay informed. Without web access, it can only work with what it already knows — and AI knowledge has a cutoff date. Web search keeps it current.
- Go to brave.com/search/api in your browser
- Sign up for the free tier (gives you 2,000 searches per month — more than enough to start)
- Once signed up, you'll see your API key. Copy it.
Then add it to OpenClaw:
# Give your agent the ability to search the web
$ openclaw tool add brave-search --api-key "YOUR_BRAVE_API_KEY"
A confirmation message that the tool was added. Now your agent can search the web, read articles, and research anything autonomously.
Tell your agent to go study. Send it a message telling it to research the exchange, trading strategies, and everything it needs to know. It will then work autonomously — searching the web, reading documents, and taking notes — for hours if needed.
Would you hire a trader who knows nothing about the market they're trading? Of course not. This step gives your agent real expertise. It will read the actual Hyperliquid documentation, understand how funding rates work, learn about liquidation mechanics, and build genuine knowledge.
Send your agent a research task. You can do this from the dashboard (the web interface) or the terminal:
$ openclaw agent --agent atlas --message "Research Hyperliquid. Learn how the
exchange works, how funding rates are calculated, what liquidation
mechanics look like, and what trading strategies work best. Save
your findings to LEARNINGS.md."
Your agent will autonomously:
- Search the web for Hyperliquid documentation, guides, and tutorials
- Read official docs, blog posts, and community resources
- Take detailed notes on everything it learns
- Save a comprehensive
LEARNINGS.mdfile in its workspace - Build genuine expertise that it will use when making trading decisions
You can literally walk away. Go make coffee. Watch TV. Come back in an hour or two and your agent will have built a comprehensive knowledge base from scratch.
Connecting to Markets
Create an account on Hyperliquid — the exchange where your agent will trade. Hyperliquid is a decentralised perpetual futures exchange. It's fast, cheap, and has no KYC (identity verification) for trading.
- Go to app.hyperliquid.xyz in your web browser
- Click "Connect Wallet" and connect a crypto wallet (MetaMask, Rabby, or any EVM wallet)
- Deposit USDC to your Hyperliquid account. Start small — $100 to $500 is fine for testing.
- Go to Settings (gear icon) → API → Create API Key
- Copy and save both the API key and the API secret. You will need both.
Two things saved somewhere safe:
- API Key — looks like a long string of letters and numbers
- API Secret — another long string. Keep this secret. Never share it.
If you're new to crypto: a wallet is like a bank account for cryptocurrency. MetaMask is the most popular one. It's a free browser extension you install in Chrome or Firefox. Go to metamask.io, install it, and create a wallet. It takes 2 minutes. Write down your "seed phrase" (12 words) and keep it safe — it's the master key to your money.
Give your agent secure access to your Hyperliquid API keys so it can place trades on your behalf. This is like giving your employee the company credit card — but with strict limits.
# Add your Hyperliquid credentials to OpenClaw
$ openclaw onboard --auth-choice hyperliquid-api-key
# Follow the prompts:
# 1. Paste your API key
# 2. Paste your API secret
Your API keys are:
- Stored locally on YOUR computer, in an encrypted file
- Never sent to OpenClaw's servers (there are no OpenClaw servers — it's all local)
- Never shared with the AI model itself. The agent uses them through a secure tool, but never sees the raw keys.
OpenClaw is open source. You can verify all of this yourself by reading the code.
auth-profiles.json on your machine. The main config file (openclaw.json) just has metadata about the profile — not the actual keys. This separation is a security feature.
Get notifications on your phone for every trade your agent makes. You want to know when it opens a position, closes a trade, hits a stop loss, or has any issue. Telegram is the easiest way to set this up.
You should never let an agent trade without monitoring. Even though it's autonomous, you still want to know what it's doing — especially in the beginning. Think of it like a baby monitor. The agent is working independently, but you want to be able to glance at your phone and know everything is fine.
- Open Telegram on your phone (download it from the app store if you don't have it)
- Search for @BotFather (it's an official Telegram bot that creates other bots)
- Send it the message:
/newbot - Follow the prompts: give your bot a name (e.g., "Atlas Trading Bot") and a username (e.g., "atlas_trades_bot")
- BotFather will give you a Bot Token. Copy it. It looks like:
1234567890:ABCDefGHijKLMnoPQRSTUvwxyz - To get your Chat ID: search for @userinfobot on Telegram and send it any message. It will reply with your ID number.
Open your agent's SOUL.md file and add this section at the bottom:
## Notifications
Send all trade updates to Telegram.
Bot Token: YOUR_BOT_TOKEN_HERE
Chat ID: YOUR_CHAT_ID_HERE
Notify me about:
- Every trade opened (with reasoning)
- Every trade closed (with P&L)
- Stop losses triggered
- Any errors or issues
- Daily P&L summary
Once your agent starts trading (next steps), you'll get Telegram messages on your phone for every action it takes. It's incredibly satisfying to watch your AI agent send you trade updates in real time.
Going Live
Paper trading means testing with real market data but fake money. Your agent watches the real markets, makes real decisions, places trades on the testnet — but nothing is at risk. It's a dress rehearsal before the real show.
You wouldn't hire a pilot who's never flown a simulator. Paper trading lets you verify that your agent's strategy works, that it follows your SOUL file rules, and that everything is connected properly — all without risking a single dollar.
# Start a paper trading session
$ openclaw agent --agent atlas --message "Start paper trading.
You have $1,000 simulated balance. Trade for the next 3 hours.
Log every trade with your reasoning. Send Telegram updates."
- Your agent starts watching the market
- It analyses charts, funding rates, and momentum
- When it spots an opportunity, it opens a position (on testnet)
- You get Telegram notifications for every trade
- After the session, check the trade log to see how it did
Switch from paper trading to real trading. This is the moment your agent starts using real money on the real exchange. Take a deep breath.
Update your SOUL.md file with live trading parameters:
## Trading Mode
LIVE TRADING — real money, real consequences.
Starting balance: $500
Max position size: $100
Max leverage: 5x
Max number of open positions: 2
Daily loss limit: $50 (stop trading if you lose this much in a day)
Then start your agent:
$ openclaw agent --agent atlas --message "Begin live trading. Follow
all rules in your SOUL. Be disciplined. This is real money."
That's it. Your AI agent is now live, trading 24/7 on Hyperliquid. It will:
- Monitor the market continuously
- Open and close trades based on its analysis
- Manage risk according to your SOUL file rules
- Send you Telegram updates for every action
- Log everything for you to review later
- Start small. $100–$500. You can always add more later.
- Monitor closely at first. Check Telegram updates regularly for the first few days.
- Set a daily loss limit. Tell your agent to stop trading if it loses X amount in a day.
- You can stop it anytime. Just close the terminal or send a message telling it to stop.
Once your first agent is working well, you can create more agents with different strategies, run competitions between them, and scale up your operation. This is what we did in the video — 15 different bots, each with a different personality and strategy, all running simultaneously on one Mac Mini.
# Create specialist sub-agents under your main agent
$ openclaw agent create --name "hyper" # Hyperliquid trading specialist
$ openclaw agent create --name "scout" # Market research specialist
$ openclaw agent create --name "scalper" # Quick in-and-out trader
$ openclaw agent create --name "funding-arb" # Funding rate arbitrage
# Write a unique SOUL.md for each one, then start them all
- Scalper — Makes many small trades per day, targeting 0.1-0.5% per trade
- Trend Follower — Only trades in the direction of the major trend, holds positions for hours or days
- Funding Rate Arbitrage — Exploits extreme funding rates to collect payments from other traders
- Whale Follower — Monitors large wallet activity and follows the moves of big players
- Researcher — Doesn't trade at all. Instead, it researches market conditions and sends you reports
- News Trader — Watches for breaking news and makes rapid trades on major announcements
You can schedule your agents to do things automatically on a repeating schedule:
# Check markets every 5 minutes
$ openclaw cron add --agent atlas --cron "*/5 * * * *" --message "Check the
market and decide if any action is needed."
# Send a daily P&L summary every evening at 8pm
$ openclaw cron add --agent atlas --cron "0 20 * * *" --message "Send a
daily summary of all trades and P&L to Telegram."
# See all scheduled tasks
$ openclaw cron list
Key Files
| File | What It Does |
|---|---|
SOUL.md | Your agent's personality, rules, and instructions. The most important file. |
TRADE_STATE.md | Current open positions, balances, and live P&L. |
TRADE_LOG.jsonl | Complete history of every trade made, with timestamps and reasoning. |
LEARNINGS.md | Research notes the agent has compiled from studying the market. |
openclaw.json | System configuration. Where OpenClaw stores settings for agents, tools, and models. |
auth-profiles.json | Encrypted file where API keys and secrets are stored securely. |
Key Commands
| Command | What It Does |
|---|---|
openclaw start | Start the OpenClaw gateway (the control centre) |
openclaw agent create --name "X" | Create a new agent with the name X |
openclaw agent --agent X --message "..." | Send a message to agent X |
openclaw cron add --agent X --cron "..." --message "..." | Schedule a recurring task for agent X |
openclaw cron list | View all scheduled tasks |
openclaw tool add <tool> --api-key "..." | Add a new tool (like web search) |
openclaw --version | Check which version of OpenClaw you have |
Estimated Costs
| Item | Cost | Notes |
|---|---|---|
| Mac Mini | $299–$599 | One-time purchase. Lasts for years. |
| Cloud VPS (alternative) | $5–$20/month | No hardware to buy. Cancel anytime. |
| AI API (Anthropic Claude) | $3–$50/month | Depends on how active your agents are. |
| Brave Search API | Free | Free tier: 2,000 searches/month. |
| Hyperliquid | Free | No platform fees. Just trading fees (very low). |
| Total to start | ~$10–$30/month | If you already have a computer. |