Use Cases & Practical
OpenClaw Trading Bot: Automate Crypto & Stocks (2026)
11 min read · Updated 2026-03-08
By DoneClaw Team · We run managed OpenClaw deployments and write from hands-on production experience.
Most trading bots are either too simple (just price alerts) or too complex (quant-level infrastructure). OpenClaw sits in the sweet spot: an AI agent smart enough to analyze markets, execute multi-step strategies, and explain its reasoning — all accessible through a Telegram or Discord message. Connect your bot to Telegram for mobile alerts. This guide shows you how to build a trading assistant that actually works, from basic price monitoring to sophisticated strategy execution.
What OpenClaw Can Do for Trading
Let's be clear about what's realistic.
- **OpenClaw excels at:** Real-time price monitoring and intelligent alerts, portfolio tracking across multiple exchanges, market analysis and research summaries, news sentiment analysis, strategy backtesting conversations, order execution via exchange APIs, multi-timeframe technical analysis, and risk management alerts.
- **OpenClaw is NOT:** A high-frequency trading system (latency too high), a guaranteed money printer (no AI is), or a replacement for understanding markets.
Architecture Overview
OpenClaw acts as the brain — it receives market data, applies your strategy rules, and communicates with you through your preferred messaging app. See our API integrations guide for connecting external services.
You (Telegram/Discord)
|
OpenClaw Agent
|
+-- Exchange APIs (Binance, Coinbase, Interactive Brokers)
+-- Market Data (CoinGecko, Yahoo Finance, Alpha Vantage)
+-- News Sources (CryptoPanic, Finviz, RSS feeds)
+-- Custom Skills (technical analysis, portfolio tracker)Step 1: Set Up the Foundation
**Prerequisites:** OpenClaw installed and running (setup guide), a messaging channel configured (Telegram or Discord), and exchange API keys (read-only to start — we'll add trading permissions later).
**Configure Your Agent for Trading:** Update your SOUL.md with trading context so your agent knows how to behave when discussing markets. Include instructions like always showing current prices with precise numbers, flagging unusual volume spikes, never giving financial advice, confirming orders before executing, and tracking portfolio P&L daily.
**Store Your API Keys:** Use the openclaw config command to set environment variables for your exchange and data provider keys. Start with Binance (read-only), CoinGecko (free, no key needed for basic), and Alpha Vantage (free tier: 25 requests/day).
## Trading Assistant Behavior
- Always include the current price when discussing any asset
- Use precise numbers — never round prices for crypto
- Include percentage changes (24h, 7d) when reporting prices
- Flag unusual volume spikes immediately
- Never give financial advice — present data and analysis, let me decide
- When I say "buy" or "sell", confirm the exact order before executing
- Always show risk/reward ratio before any trade suggestion
- Track my portfolio and report P&L daily
# Binance (read-only first)
openclaw config set env.BINANCE_API_KEY your_key
openclaw config set env.BINANCE_API_SECRET your_secret
# CoinGecko (free, no key needed for basic)
# Alpha Vantage (free tier: 25 requests/day)
openclaw config set env.ALPHA_VANTAGE_KEY your_keyStep 2: Market Monitoring Skill
Create a custom skill that fetches market data. The price script fetches real-time data from CoinGecko including current price, 24h/7d/30d changes, market cap, volume, all-time high, and daily high/low. The portfolio script tracks your holdings across multiple assets and calculates total value with 24h change percentages.
Once set up, you can ask your agent natural language questions like 'What's the price of Bitcoin?' or 'Show my portfolio' and it runs these scripts automatically.
mkdir -p ~/clawd/skills/market-data
// ~/clawd/skills/market-data/scripts/price.js
const https = require('https');
function fetchJSON(url) {
return new Promise((resolve, reject) => {
https.get(url, { headers: { 'User-Agent': 'OpenClaw-Trading/1.0' } }, res => {
let data = '';
res.on('data', c => data += c);
res.on('end', () => resolve(JSON.parse(data)));
}).on('error', reject);
});
}
async function main() {
const symbol = process.argv[2] || 'bitcoin';
const url = `https://api.coingecko.com/api/v3/coins/${symbol}?localization=false&tickers=false&community_data=false&developer_data=false`;
const data = await fetchJSON(url);
const price = data.market_data;
console.log(JSON.stringify({
name: data.name,
symbol: data.symbol.toUpperCase(),
price_usd: price.current_price.usd,
change_24h: price.price_change_percentage_24h?.toFixed(2) + '%',
change_7d: price.price_change_percentage_7d?.toFixed(2) + '%',
change_30d: price.price_change_percentage_30d?.toFixed(2) + '%',
market_cap: price.market_cap.usd,
volume_24h: price.total_volume.usd,
ath: price.ath.usd,
ath_change: price.ath_change_percentage.usd?.toFixed(2) + '%',
high_24h: price.high_24h.usd,
low_24h: price.low_24h.usd,
}, null, 2));
}
main().catch(e => { console.error(e.message); process.exit(1); });
// ~/clawd/skills/market-data/scripts/portfolio.js
const https = require('https');
// Define your portfolio
const PORTFOLIO = [
{ symbol: 'bitcoin', amount: 0.5 },
{ symbol: 'ethereum', amount: 5.0 },
{ symbol: 'solana', amount: 50 },
];
async function main() {
const ids = PORTFOLIO.map(p => p.symbol).join(',');
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids}&vs_currencies=usd&include_24hr_change=true`;
const res = await new Promise((resolve, reject) => {
https.get(url, r => { let d = ''; r.on('data', c => d += c); r.on('end', () => resolve(JSON.parse(d))); }).on('error', reject);
});
let totalValue = 0;
const holdings = PORTFOLIO.map(p => {
const price = res[p.symbol]?.usd || 0;
const change = res[p.symbol]?.usd_24h_change || 0;
const value = price * p.amount;
totalValue += value;
return {
asset: p.symbol,
amount: p.amount,
price: price,
value: value.toFixed(2),
change_24h: change.toFixed(2) + '%',
};
});
console.log(JSON.stringify({ holdings, totalValue: totalValue.toFixed(2) }, null, 2));
}
main().catch(e => { console.error(e.message); process.exit(1); });Step 3: Automated Alerts with Cron Jobs
Set up cron jobs for monitoring. You can configure price alerts that run every 30 minutes and only notify you when something notable happens, a morning market briefing at 8 AM with BTC, ETH, SOL prices and crypto news, and a weekly portfolio review every Monday with full performance analysis and rebalancing suggestions.
# Price alert every 30 minutes
openclaw cron add \
--name "Market check" \
--cron "*/30 * * * *" \
--tz "Asia/Hong_Kong" \
--message "Run the portfolio tracker script (node ~/clawd/skills/market-data/scripts/portfolio.js). Compare to yesterday's values. Only message me if: (1) any asset moved more than 5% in 24h, (2) total portfolio changed more than 3%, or (3) BTC crossed a round number ($90k, $95k, $100k, etc). If nothing notable, stay silent."
# Morning market briefing
openclaw cron add \
--name "Morning market brief" \
--cron "0 8 * * *" \
--tz "Asia/Hong_Kong" \
--message "Give me a morning market briefing: BTC, ETH, SOL prices and 24h changes. Check crypto news for anything major. Check Fear & Greed index. Keep it brief — 5 lines max."
# Weekly portfolio review
openclaw cron add \
--name "Weekly portfolio review" \
--cron "0 9 * * 1" \
--tz "Asia/Hong_Kong" \
--message "Full weekly portfolio review: all holdings, 7-day performance, total P&L. Compare to S&P 500 performance. Highlight best and worst performers. Suggest any rebalancing needed based on my target allocation."Step 4: News and Sentiment Analysis
OpenClaw can monitor news sources and analyze sentiment. Set up a breaking news monitor that runs every 15 minutes to search for regulatory changes, major exchange issues, significant project updates, or market-moving events — and stays silent when nothing important happens.
Once set up, you just chat naturally. Ask questions like 'What's happening with ETH today?' or 'Should I be worried about that SEC news?' or 'Compare BTC performance this week vs last month' or 'What's the RSI on SOL right now?' and your agent searches, analyzes, and responds conversationally.
# Breaking news monitor (every 15 min)
openclaw cron add \
--name "Crypto news monitor" \
--cron "*/15 * * * *" \
--message "Search web for breaking crypto news in the last 15 minutes. Only alert me about: regulatory changes, major exchange issues, significant project updates for BTC/ETH/SOL, or market-moving events. Ignore routine news. If nothing important, stay silent."Get your own AI agent today
Persistent memory, channel integrations, unlimited usage. DoneClaw deploys and manages your OpenClaw instance so you just chat.
Get StartedStep 5: Trade Execution (Advanced)
Warning: Automated trading carries real financial risk. Start with paper trading. Use read-only API keys until you're confident.
**Binance Order Execution:** The trade script below handles HMAC-SHA256 signature generation and places market orders on Binance. It accepts symbol, side (BUY/SELL), and quantity as command-line arguments.
**Safety Rails in SOUL.md:** Always add strict trade execution rules to your agent's configuration. Never execute a trade without explicit confirmation. Set maximum single trade limits. Only trade pre-approved assets. Log every trade with timestamp and reasoning.
// ~/clawd/skills/market-data/scripts/trade.js
const crypto = require('crypto');
const https = require('https');
const API_KEY = process.env.BINANCE_API_KEY;
const API_SECRET = process.env.BINANCE_API_SECRET;
function sign(queryString) {
return crypto.createHmac('sha256', API_SECRET).update(queryString).digest('hex');
}
async function placeOrder(symbol, side, quantity, type = 'MARKET') {
const timestamp = Date.now();
const params = `symbol=${symbol}&side=${side}&type=${type}&quantity=${quantity}×tamp=${timestamp}`;
const signature = sign(params);
return new Promise((resolve, reject) => {
const options = {
hostname: 'api.binance.com',
path: `/api/v3/order?${params}&signature=${signature}`,
method: 'POST',
headers: { 'X-MBX-APIKEY': API_KEY },
};
const req = https.request(options, res => {
let data = '';
res.on('data', c => data += c);
res.on('end', () => resolve(JSON.parse(data)));
});
req.on('error', reject);
req.end();
});
}
// Usage: node trade.js BTCUSDT BUY 0.001
const [symbol, side, qty] = process.argv.slice(2);
if (!symbol || !side || !qty) {
console.log('Usage: node trade.js SYMBOL SIDE QUANTITY');
process.exit(1);
}
placeOrder(symbol, side, qty)
.then(r => console.log(JSON.stringify(r, null, 2)))
.catch(e => console.error(e));
## Trade Execution Rules
- NEVER execute a trade without my explicit confirmation
- Always show: asset, side (buy/sell), quantity, estimated cost, current price
- Wait for me to reply "confirm" or "yes" before executing
- Maximum single trade: $500 (reject anything larger)
- Only trade assets I've pre-approved: BTC, ETH, SOL
- Log every trade to memory/trades.md with timestamp and reasoningStep 6: Technical Analysis
OpenClaw can calculate and interpret common indicators. The technical analysis script fetches OHLCV candle data from Binance and calculates SMA (20 and 50 period), RSI (14 period), trend direction, overbought/oversold signals, 24h volume, and 20-day support and resistance levels.
With this script in place, you can ask natural language questions like 'What's the RSI on BTC?' or 'Is ETH overbought right now?' or 'Where's support and resistance for SOL?'
// ~/clawd/skills/market-data/scripts/ta.js
// Fetch OHLCV data and calculate basic indicators
async function getCandles(symbol, interval = '1d', limit = 100) {
const url = `https://api.binance.com/api/v3/klines?symbol=${symbol}&interval=${interval}&limit=${limit}`;
const res = await fetch(url);
const data = await res.json();
return data.map(c => ({
time: new Date(c[0]).toISOString(),
open: parseFloat(c[1]),
high: parseFloat(c[2]),
low: parseFloat(c[3]),
close: parseFloat(c[4]),
volume: parseFloat(c[5]),
}));
}
function sma(data, period) {
const closes = data.map(d => d.close);
const result = [];
for (let i = period - 1; i < closes.length; i++) {
const sum = closes.slice(i - period + 1, i + 1).reduce((a, b) => a + b, 0);
result.push(sum / period);
}
return result;
}
function rsi(data, period = 14) {
const closes = data.map(d => d.close);
const changes = [];
for (let i = 1; i < closes.length; i++) {
changes.push(closes[i] - closes[i - 1]);
}
let avgGain = 0, avgLoss = 0;
for (let i = 0; i < period; i++) {
if (changes[i] > 0) avgGain += changes[i];
else avgLoss -= changes[i];
}
avgGain /= period;
avgLoss /= period;
const rs = avgLoss === 0 ? 100 : avgGain / avgLoss;
return 100 - (100 / (1 + rs));
}
async function main() {
const symbol = process.argv[2] || 'BTCUSDT';
const candles = await getCandles(symbol);
const sma20 = sma(candles, 20);
const sma50 = sma(candles, 50);
const currentRSI = rsi(candles);
const currentPrice = candles[candles.length - 1].close;
const analysis = {
symbol,
price: currentPrice,
sma20: sma20[sma20.length - 1]?.toFixed(2),
sma50: sma50[sma50.length - 1]?.toFixed(2),
rsi: currentRSI?.toFixed(1),
trend: currentPrice > sma50[sma50.length - 1] ? 'BULLISH' : 'BEARISH',
signal: currentRSI > 70 ? 'OVERBOUGHT' : currentRSI < 30 ? 'OVERSOLD' : 'NEUTRAL',
volume_24h: candles[candles.length - 1].volume,
support: Math.min(...candles.slice(-20).map(c => c.low)).toFixed(2),
resistance: Math.max(...candles.slice(-20).map(c => c.high)).toFixed(2),
};
console.log(JSON.stringify(analysis, null, 2));
}
main();Strategy Templates
Here are ready-to-use strategy templates you can configure with OpenClaw cron jobs.
**DCA (Dollar Cost Averaging) Bot:** Automatically buy a fixed dollar amount of BTC every Monday at 9 AM. The agent logs each purchase with date, price, amount, and running total invested.
**Dip Buyer:** Monitor every 30 minutes for significant dips (more than 8% in 24h) in BTC, ETH, or SOL. The agent presents the data including RSI but does not suggest buying — it lets you decide.
**Whale Watching:** Monitor large cryptocurrency transactions every 15 minutes. Only alert on transactions over $10M, including the amount, source and destination (exchange vs unknown wallet), and potential implications.
# Buy $50 of BTC every Monday at 9 AM
openclaw cron add \
--name "BTC DCA" \
--cron "0 9 * * 1" \
--message "It's DCA day. Current BTC price: [check]. Buy $50 worth of BTC on Binance. Log the purchase with date, price, amount, and running total invested."
# Alert on significant dips
openclaw cron add \
--name "Dip alert" \
--cron "*/30 * * * *" \
--message "Check if BTC, ETH, or SOL dropped more than 8% in 24h. If yes, alert me with the current price, how much it dropped, and whether RSI is oversold. Don't suggest buying — just present the data."
# Monitor large transactions
openclaw cron add \
--name "Whale monitor" \
--cron "*/15 * * * *" \
--message "Search for any crypto whale alerts or large BTC/ETH transactions in the last 15 minutes (check whale-alert.io or similar). Only alert if transaction is over $10M. Include: amount, from/to (exchange vs unknown wallet), and what it might mean."Portfolio Tracking in Memory
OpenClaw's persistent memory is perfect for trade journaling. Your agent automatically maintains a portfolio file in memory that tracks current holdings with average cost basis and current value, a chronological trade log with entry prices and profit percentages, and monthly P&L summaries.
Your agent updates this automatically after every trade and references it when you ask about performance.
Risk Management
**Position Sizing:** Add risk rules to your SOUL.md to enforce discipline. Key rules include never risking more than 2% of portfolio on a single trade, maximum 3 open positions at once, always setting a stop-loss with every trade, alerting when any single position exceeds 30% of portfolio, and tracking correlation to avoid over-concentration in one sector.
**Stop-Loss Monitoring:** Set up a cron job that checks every 5 minutes if any holdings have hit their stop-loss levels stored in your portfolio file. This is time-sensitive — if a stop-loss is triggered, the agent alerts you immediately with the asset, current price, stop-loss level, and loss amount.
openclaw cron add \
--name "Stop loss check" \
--cron "*/5 * * * *" \
--message "Check if any of my holdings hit their stop-loss levels (stored in memory/portfolio.md). If yes, alert me IMMEDIATELY with the asset, current price, stop-loss level, and loss amount. This is time-sensitive."What's Next?
Now that you have a trading assistant set up, consider these next steps to enhance your setup.
- Set up automated monitoring for your first cron jobs.
- Secure your server — you're handling financial API keys now.
- Use Ollama for local models if you want analysis to stay completely private.
- Join the OpenClaw Discord to share trading strategies with other users.
Conclusion
OpenClaw gives you an AI trading assistant that sits between oversimplified price alert bots and complex quant infrastructure. It monitors markets, analyzes news sentiment, calculates technical indicators, and executes trades through your exchange APIs — all accessible through a simple Telegram or Discord message. Start with read-only API keys and price monitoring, then gradually add automated alerts, technical analysis, and trade execution as you build confidence. The key advantage is persistent memory: your agent remembers your portfolio, trade history, strategy preferences, and risk rules across every session, compounding its usefulness over time.
Skip the setup? DoneClaw deploys OpenClaw for you — $29/mo with 7-day free trial, zero configuration.
Get your own AI agent today
Persistent memory, channel integrations, unlimited usage. DoneClaw deploys and manages your OpenClaw instance so you just chat.
Get StartedFrequently asked questions
Can OpenClaw do high-frequency trading?
No. Response latency of 2-5 seconds makes it unsuitable for HFT. OpenClaw is designed for swing trading, dollar cost averaging, and market monitoring — not millisecond execution. For strategies that operate on minutes or hours rather than milliseconds, it works well.
Which exchanges does OpenClaw support for trading?
Any exchange with a REST API works with OpenClaw. This includes Binance, Coinbase, Kraken, Interactive Brokers, and Alpaca (for stocks). You write simple API wrapper scripts for each exchange, and the agent calls them through custom skills.
Is it safe to give OpenClaw my exchange API keys?
Use read-only keys for monitoring first. Only add trade permissions when you are confident in your setup. Keys are stored on your own server, not shared with anyone. Add IP whitelisting on the exchange side for extra security.
How much does it cost to run an OpenClaw trading bot?
The VPS costs $5-10 per month and AI API costs run approximately $5-15 per month for moderate use. This is significantly cheaper than commercial trading bot subscriptions, which often charge $30-100 per month or more.
Can OpenClaw trade stocks and forex, or just crypto?
OpenClaw can trade stocks through Alpaca (commission-free API) or Interactive Brokers API, and forex through brokers with REST APIs. The architecture is the same — you swap the exchange API wrapper script for the appropriate broker. The market monitoring, technical analysis, and alert systems work identically across asset classes.