Crypto Trader & Analyst Skill
This skill allows OpenClaw to analyze the crypto market using technical indicators and news sentiment, record its findings, and execute trades on Binance.
Dependencies
Ensure the following Python packages are installed:
pip install ccxt pandas pandas-ta requests TextBlob
Note: TextBlob is suggested for basic sentiment analysis if needed, though simple keyword matching might suffice.
Environment Variables
You must set the following environment variables for trading:
- -
BINANCE_API_KEY: Your Binance API Key. - INLINECODE2 : Your Binance API Secret.
WARNING: Never share these keys or commit them to version control.
Workflow
1. Market Analysis
Technical Analysis
Run the market data script to get current indicators for a symbol (default ETH/USDT).
python skills/crypto_trader/scripts/market_data.py --symbol ETH/USDT
Output: JSON containing RSI, MACD, close price, etc.
Sentiment Analysis
Run the sentiment script to fetch latest news headers and forum buzz.
python skills/crypto_trader/scripts/sentiment_data.py
Output: Text/JSON summary of positive/negative news.
2. Decision Making & Logging
Analyze & Record
Based on the outputs from step 1, form a hypothesis. Is the market Bullish, Bearish, or Neutral?
Before trading, you MUST save your analysis.
CODEBLOCK3
3. Execution
Trade
If the analysis supports a trade, execute it.
# Buy 0.01 ETH at Market Price
python skills/crypto_trader/scripts/trade.py --symbol ETH/USDT --side buy --amount 0.01 --type market
# Dry Run (Test without real money)
python skills/crypto_trader/scripts/trade.py --symbol ETH/USDT --side buy --amount 0.01 --dry-run
The trade script will automatically append the transaction to skills/crypto_trader/logs/trade_history.csv.
Files structure
- -
scripts/market_data.py: Fetches OHLCV and calculates indicators. - INLINECODE5 : Fetches news/forum data.
- INLINECODE6 : Appends analysis to
logs/analysis_journal.md. - INLINECODE8 : Executes trades and logs to
logs/trade_history.csv. - INLINECODE10 : Directory storing your analysis history and trade logs.
加密货币交易员与分析师技能
该技能使OpenClaw能够使用技术指标和新闻情绪分析加密货币市场,记录分析结果,并在币安上执行交易。
依赖项
请确保已安装以下Python包:
bash
pip install ccxt pandas pandas-ta requests TextBlob
注意:如果需要基本情绪分析,建议使用TextBlob,但简单的关键词匹配可能也足够。
环境变量
您必须设置以下环境变量才能进行交易:
- - BINANCEAPIKEY:您的币安API密钥。
- BINANCEAPISECRET:您的币安API密钥密码。
警告:切勿分享这些密钥或将其提交到版本控制系统中。
工作流程
1. 市场分析
技术分析
运行市场数据脚本以获取某个交易对(默认为ETH/USDT)的当前指标。
bash
python skills/cryptotrader/scripts/marketdata.py --symbol ETH/USDT
输出:包含RSI、MACD、收盘价等的JSON数据。
情绪分析
运行情绪脚本以获取最新新闻标题和论坛热度。
bash
python skills/cryptotrader/scripts/sentimentdata.py
输出:正面/负面新闻的文本/JSON摘要。
2. 决策制定与记录
分析与记录
基于步骤1的输出,形成假设。市场是看涨、看跌还是中性?
在交易之前,您必须保存您的分析。
bash
python skills/crypto_trader/scripts/logger.py 您在此处的详细分析。例如,RSI为30(超卖),新闻情绪正面。计划买入。
3. 执行
交易
如果分析支持交易,则执行交易。
bash
以市价买入0.01 ETH
python skills/crypto_trader/scripts/trade.py --symbol ETH/USDT --side buy --amount 0.01 --type market
模拟运行(不涉及真实资金测试)
python skills/crypto_trader/scripts/trade.py --symbol ETH/USDT --side buy --amount 0.01 --dry-run
交易脚本将自动将交易记录追加到skills/cryptotrader/logs/tradehistory.csv中。
文件结构
- - scripts/marketdata.py:获取OHLCV数据并计算指标。
- scripts/sentimentdata.py:获取新闻/论坛数据。
- scripts/logger.py:将分析结果追加到logs/analysisjournal.md中。
- scripts/trade.py:执行交易并将记录保存到logs/tradehistory.csv中。
- logs/:存储分析历史和交易日志的目录。