360 Secure SkillHub
360 安全技能中心

Mock Trading

该 Skill 提供纸面交易模拟环境:先把虚拟资金组合模板复制到工作目录,再运行 Python 脚本完成单个交易周期,获取实时行情、按 SMA 交叉等策略评估并执行模拟买卖、更新组合文件;随后读取组合汇报盈亏、现金余额与交易记录,也可通过计划任务周期性运行。

yadavabhijeet4
yadavabhijeet4
热度 54.25
最近更新 2026-05-11 17:30:39
分类:自动化依赖:代码执行 / 第三方 API / 读写文件应用场景:自动化脚本 / 财务 / 市场分析 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add mock-trading
Metadata
name
mock-trading-agent
description
Simulate cryptocurrency trading using algorithmic strategies (SMA Crossover, Mean Reversion) without risking real capital. Use when the user wants to start a paper trading simulation, test a trading bot, or monitor a mock portfolio.

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.

    cp {baseDir}/assets/portfolio.json ./my_portfolio.json
    
  2. Run a Trading Tick: Run the bot script. This executes a single cycle (fetch data -> evaluate -> trade -> save).

    uv run {baseDir}/scripts/mock_bot.py --portfolio ./my_portfolio.json --asset bitcoin
    
  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.