Mock Trading Agent Skill
This skill provides a fully functional mock (paper) trading environment. It allows OpenClaw to simulate algorithmic trading by fetching live market data, evaluating algorithmic strategies, and updating a virtual portfolio.
Components
- -
assets/portfolio.json: A template virtual bank account containing $10,000 USD. scripts/mock_bot.py: A python script that executes a single "tick" of the trading bot. It fetches the current price, evaluates the strategy based on price history, executes mock trades, and updates the portfolio file.
Setup & Usage
When a user asks to start a mock trading session:
- 1. Initialize the Portfolio:
Copy the template portfolio to the user's working directory.
CODEBLOCK0
- 2. Run a Trading Tick:
Run the bot script. This executes a single cycle (fetch data -> evaluate -> trade -> save).
CODEBLOCK1
- 3. Automation (Heartbeat/Cron):
To run the bot continuously, add the command from Step 2 into the user's
HEARTBEAT.md file or schedule it via cron to run every 5-10 minutes.
- 4. Reporting:
Read
./my_portfolio.json to report the user's current PnL, cash balance, and trade history.
Modifying Strategies
The script currently defaults to an
SMA Crossover strategy. You can edit the python script locally to swap it with Mean Reversion, Momentum Breakout, or RSI strategies if the user requests different logic.
模拟交易代理技能
该技能提供了一个功能完整的模拟(纸面)交易环境。它允许OpenClaw通过获取实时市场数据、评估算法策略以及更新虚拟投资组合来模拟算法交易。
组件
- - assets/portfolio.json:一个包含10,000美元资金的模板虚拟银行账户。
- scripts/mock_bot.py:一个执行交易机器人单次滴答操作的Python脚本。它获取当前价格、基于价格历史评估策略、执行模拟交易并更新投资组合文件。
设置与使用
当用户要求启动模拟交易会话时:
- 1. 初始化投资组合:
将模板投资组合复制到用户的工作目录。
bash
cp {baseDir}/assets/portfolio.json ./my_portfolio.json
- 2. 运行一次交易滴答:
运行机器人脚本。这将执行一个完整周期(获取数据 -> 评估 -> 交易 -> 保存)。
bash
uv run {baseDir}/scripts/mock
bot.py --portfolio ./myportfolio.json --asset bitcoin
- 3. 自动化(心跳/Cron):
如需持续运行机器人,将步骤2中的命令添加到用户的HEARTBEAT.md文件中,或通过cron设置每5-10分钟执行一次。
- 4. 报告:
读取./my_portfolio.json文件,向用户报告当前的盈亏情况、现金余额和交易历史。
修改策略
该脚本默认使用
SMA交叉策略。如果用户要求不同的逻辑,您可以在本地编辑Python脚本,将其替换为均值回归、动量突破或RSI策略。