当前位置: 首页 > Skill >

TBOT Controller

TBOT Controller

TBOT Controller

通过受控自动化接口操作 TradingBoat/TBOT(TBOT 运行时栈),实现数据库优先查询,并在收到明确请求时控制其生命周期。

1.0.0 2026.11.26 956
获取Skill文件查看使用说明
作 者:顾景 许可证: 更新时间:2026.11.26
本文目录展开

What this skill does

  • Query TBOT sqlite DB for alerts/orders/errors/portfolio (DB-first)
  • Start/stop TradingBoat/TBOT (docker compose or systemd)
  • Fetch health/status (containers, ports, basic checks) only when explicitly requested
  • Read recent logs only when explicitly requested

Safety rules

  • Default to read-only operations (status/logs) unless user explicitly requests a control action.
  • For any state-changing action (start/stop/restart/send), require explicit confirmation via the flag --run-it or environment variable RUN_IT=1. The controller will refuse execution otherwise.
  • Never print secrets (webhook keys, tokens). Redact them.

Refusal criteria (must-stop conditions)

The agent MUST stop and ask for user action if any of the following is true:

  • Runtime location is unknown and discovery cannot uniquely resolve it.
  • The TBOT database path cannot be found or opened read-only.
  • A request would start/stop/restart services or send signals without --run-it / RUN_IT=1.
  • A request implies destructive DB changes (DROP/TRUNCATE/ALTER) or “run arbitrary SQL”.

Prerequisites (first-time users)

This skill controls a separate TBOT runtime stack. The reference/runtime implementation is:

  • openclaw-on-tradingboat (TBOT runtime stack): https://github.com/PlusGenie/openclaw-on-tradingboat

This tbot-controller skill does not download or install the runtime for you. If the runtime is missing, the skill will run read-only DB helpers where possible, but status/logs/control actions will fail until the runtime exists.

Install the runtime (recommended)

  1. Clone the runtime repo:
git clone https://github.com/PlusGenie/openclaw-on-tradingboat.git
cd openclaw-on-tradingboat
  1. Ensure you can start it manually (outside this skill). For Docker Compose based installs, this typically means:
docker compose up -d
  1. Tell this skill where the runtime lives (recommended):
  • Set TBOT_COMPOSE_DIR to the folder that contains docker-compose.yml or compose.yaml.

Examples:

export TBOT_COMPOSE_DIR="$HOME/develop/github/openclaw-on-tradingboat"

Or add it to ~/.openclaw/.env / your skill env block in openclaw.json.

Configure runtime secrets (outside this skill)

  • TBOT typically uses a .env file for broker credentials and webhook keys.
  • Do not commit secrets to git.
  • If you are unsure whether the runtime is set to paper or live, this skill must refuse to execute any trade/action until you confirm which it is.

Install / script permissions

This skill is invoked via a bash entrypoint script. Ensure it is executable:

chmod +x scripts/tbot.sh

Python deps (OpenClaw-native)

This skill uses uv to run Python scripts in an isolated environment and auto-install dependencies from:

  • {baseDir}/scripts/requirements.txt

Install uv (macOS):

brew install uv

ClawHub packaging note: if you publish this skill, ensure scripts/ (including requirements.txt) is included at the root of the repo.

IMPORTANT: DB-first, discovery only for status/control

DB queries do NOT require discovery. Discovery is required only before status/logs/control actions.

OpenClaw must NOT hardcode old paths like ~/ib-gateway-docker.

Always prefer discovery output (usually pointing to openclaw-on-tradingboat).

Commands

Entry point (required)

OpenClaw MUST invoke this skill via:

bash scripts/tbot.sh <mode> <args...>

Valid modes:

  • ctl — operations control (docker/systemd)
  • json — JSON signal generation (schema-validated) and send to TBOT webhook (non-interactive)
  • status — read-only inspection (probe & discovery)

OpenClaw must never call python tbot*.py directly.

Probe & Discovery (read-only, only for status/control)

When the user says “open TBOT”, “start TBOT”, “TBOT status”, etc., OpenClaw should:

  1. Try discovery first (read-only):
bash scripts/tbot.sh status discover

This step is mandatory because the compose folder may change over time (for example migrating from ib-gateway-docker to openclaw-on-tradingboat).

  1. If discovery returns a resolved runtime, run ctl commands by injecting env vars:
  • Docker example:
MODE=docker COMPOSE_DIR="<compose_dir>" bash scripts/tbot.sh ctl status

Example expected compose folder:

~/develop/github/openclaw-on-tradingboat> 
  • systemd example:
MODE=systemd SERVICE_NAME="<service_name>" SYSTEMD_USER="<0|1>" bash scripts/tbot.sh ctl status
  1. Only if discovery cannot resolve a single runtime, ask one precise question:
  • Docker Compose: “What is the folder containing docker-compose.yml/compose.yaml? (Usually this is the tbot-runtime (example) folder.)”
  • systemd: “What is the service name (and is it --user)?”

Notes:

  • Discovery must remain read-only (no starting/stopping).
  • Use discovery output as the authoritative suggestion for MODE/COMPOSE_DIR/SERVICE_NAME.

Why this matters

If OpenClaw skips discovery, it may incorrectly report TBOT as DOWN because it is checking an obsolete compose folder.

Status (read-only, only if requested)

bash scripts/tbot.sh ctl status
bash scripts/tbot.sh ctl logs --tail 200

Note: With tbot-runtime (example), docker compose typically brings up three containers: ib-gateway-on-tradingboat (gnzsnz/ib-gateway), redis-on-tradingboat, and tbot-on-tradingboat.

Internally:

  • Docker: docker compose ps, docker compose logs --tail=200
  • systemd: systemctl --user status <service>, journalctl --user -u <service> -n 200

Control (explicit confirmation required)

bash scripts/tbot.sh ctl start --run-it
bash scripts/tbot.sh ctl stop --run-it
bash scripts/tbot.sh ctl restart --run-it

Tip: Use MODE=docker + COMPOSE_DIR pointed at tbot-runtime (example) to control the stack via docker compose.

Internally:

  • Docker: docker compose up -d, docker compose down
  • systemd: systemctl --user start <service>, systemctl --user stop <service>

JSON signal generation (generate + send)

json mode is non-interactive by design. OpenClaw MUST NOT ask the user for webhook details or trading intent if they can be inferred.

Inference rules:

  • Webhook URL default: http://127.0.0.1:5001/webhook (override with TBOT_WEBHOOK_URL)
  • Webhook key is read from the TBOT runtime .env by default (override with WEBHOOK_KEY)
  • orderRef is auto-generated when omitted
  • Natural language like close 50 NFLX implies strategy.close, contract=stock, qty=50

json mode generates a schema-valid TradingView-style payload and sends it to TBOT via webhook.

Defaults / inference rules (do not ask the user):

  • Webhook URL: default http://127.0.0.1:5001/webhook (override with TBOT_WEBHOOK_URL).
  • Webhook key: read from runtime .env (override with WEBHOOK_KEY).
  • orderRef: if not provided, auto-generate Close_<TICKER>_<QTY>_<epoch_ms>.
  • Close intent: inferred automatically; do not prompt the user.
# Example (user: “close 50 NFLX now”)
TBOT_WEBHOOK_URL="http://127.0.0.1:5001/webhook" 
WEBHOOK_KEY="WebhookReceived:123456" 
bash scripts/tbot.sh json 
  --ticker NFLX 
  --direction strategy.close 
  --contract stock 
  --metric qty=50

Guarantees:

  • Output is validated against alert_webhook_schema.json
  • Unsupported directions or metrics fail fast
  • No network calls or broker actions are performed
  • This generator is independent of the gateway container image (e.g., gnzsnz/ib-gateway).

Copy-paste JSON output (expected schema shape)

When asked to “generate a TradingView webhook JSON”, OpenClaw should output JSON exactly like this shape:

{
  "timestamp": 1710000000000,
  "ticker": "ES1!",
  "currency": "USD",
  "timeframe": "5",
  "clientId": 1,
  "key": "WebhookReceived:123456",
  "contract": "future",
  "orderRef": "Long#1",
  "direction": "strategy.entrylong",
  "exchange": "CME",
  "lastTradeDateOrContractMonth": "202603",
  "multiplier": "50",
  "metrics": [
    {"name": "entry.limit", "value": 0},
    {"name": "entry.stop", "value": 0},
    {"name": "exit.limit", "value": 0},
    {"name": "exit.stop", "value": 0},
    {"name": "qty", "value": 1},
    {"name": "price", "value": 5032.25}
  ]
}

Tip (local-first / zero-config examples): it’s OK to use a placeholder key value in docs. For real TradingView → TBOT delivery, set it to your actual shared secret (TVWB key).

DB inspection (read-only, primary)

  • Preferred (via this skill, DB-first):
    • bash scripts/tbot.sh status db --table orders --format summary --limit 100
    • bash scripts/tbot.sh status db --table alerts --format summary --limit 100
    • bash scripts/tbot.sh status db --table errors --format summary --limit 100
    • bash scripts/tbot.sh status db --table tbot --format summary --limit 100
    • Use --format json to return raw JSON.
  • Portfolio/positions are derived from TBOTORDERS (same as /orders/data in UI).

Read-only helpers (DB-first)

  • Portfolio snapshot:
    • bash scripts/tbot.sh status portfolio --format summary
  • Errors tail (with grouping):
    • bash scripts/tbot.sh status errors --format summary --limit 200
    • bash scripts/tbot.sh status errors --group --limit 200
  • Health checks (HTTP):
    • bash scripts/tbot.sh status health --base-url http://127.0.0.1:5001

Example output (--format summary, orders):

Totals:
- Market value: 284,103.16
- Unrealized PnL: 134,585.15
- Realized PnL: 0.00

TBOT_TIME        | ORD_TIME                | TICKER | TV_Close | ACTION | TYPE | QTY | LIMIT | STOP | ORDERID | ORDERREF  | STATUS    | POS | MRKVAL     | AVGF     | UnrealPnL  | RealPnL
----------------+-------------------------+--------+----------+--------+------+-----+-------+------+---------+-----------+-----------+-----+------------+----------+------------+--------
2026-02-05 20:06 | 2026-02-05 20:06:12.345 | TSLA   | 399.4796 | BUY    | LMT  | 455 | 0     | 0    | 12345   | Ptf_TSLA  | Portfolio | 455 | 181,763.22 | 187.9038 | 96,266.98  | 0
  • DB path resolution (first match wins):
    • --db-path /path/to/tbot_sqlite3
    • TBOT_DB_PATH=/path/to/tbot_sqlite3
    • TBOT_DB_OFFICE=/path/to/tbot_sqlite3
  • DB location notes:
    • Inside the container, TBOT may create the DB at /home/tbot/tbot_sqlite3 if no volume is set.
    • Recommended: bind-mount ./runtime/database to /home/tbot/database and set TBOT_DB_OFFICE=/home/tbot/database/tbot_sqlite3.
    • With the bind-mount, the host path is:
      • tbot-runtime (example)/runtime/database/tbot_sqlite3
  • After updating tbot-runtime (example)/docker-compose.yml, restart TBOT:
    • MODE=docker COMPOSE_DIR="/path/to/your/tbot-runtime" bash scripts/tbot.sh ctl restart --run-it
  • Container note:
    • The tbot container may not include sqlite3 CLI; read the DB on the host (preferred) via bind-mount.
  • Fallback (manual):
    • sqlite3 <path> "SELECT ..."

Known gaps & intended fixes (tracked)

  • Discovery can miss running docker compose stacks; use DB-first commands for portfolio instead of discovery.
  • Add explicit subcommands (planned): errors --tail (limit), health (HTTP checks for /orders/data + /tbot/data).
  • Add a single-line summary mode (planned): totals + top 3 positions + biggest losing position.

Data signal: TradingView-style webhook JSON generator

Required fields

This skill generates JSON with fields used by TBOT/TradingBoat style alerts:

  • timestamp (ms since epoch)
  • ticker (e.g., AAPL, ES1!)
  • currency (e.g., USD)
  • timeframe (e.g., 1, 5, 1D)
  • clientId (integer; IBKR client ID)
  • key (TVWB shared key)
  • contract (e.g., stock, forex, crypto, future)
  • orderRef (string identifier)
  • direction (e.g., strategy.entrylong, strategy.entryshort, strategy.exitlong, strategy.exitshort, strategy.close, strategy.close_all)
  • exchange, lastTradeDateOrContractMonth, multiplier (mostly for futures)
  • metrics (array of {name, value})

Example payload

(Uses a placeholder key value for copy-paste. Replace with your real TVWB shared key in production.)

{
  "timestamp": 1710000000000,
  "ticker": "ES1!",
  "currency": "USD",
  "timeframe": "5",
  "clientId": 1,
  "key": "WebhookReceived:123456",
  "contract": "future",
  "orderRef": "Long#1",
  "direction": "strategy.entrylong",
  "exchange": "CME",
  "lastTradeDateOrContractMonth": "202603",
  "multiplier": "50",
  "metrics": [
    {"name": "entry.limit", "value": 0},
    {"name": "entry.stop", "value": 0},
    {"name": "exit.limit", "value": 0},
    {"name": "exit.stop", "value": 0},
    {"name": "qty", "value": 1},
    {"name": "price", "value": 5032.25}
  ]
}

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,004
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,002
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,001
PHP集成RabbitMQ实现消息队列的完整步骤

使用 php-amqplib 库,通过建立连接、声明交换机与队列并绑定,即可在 PHP 中实现消息的发送与消费。

2026.05.24 1,001
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
Skill 文件
  • SKILL.md
    • What this skill does
    • Safety rules
    • Refusal criteria (must-stop conditions)
    • Prerequisites (first-time users)
      • Install the runtime (recommended)
      • Configure runtime secrets (outside this skill)
    • Install / script permissions
      • Python deps (OpenClaw-native)
    • IMPORTANT: DB-first, discovery only for status/control
    • Commands
      • Entry point (required)
      • Probe & Discovery (read-only, only for status/control)
      • Why this matters
      • Status (read-only, only if requested)
      • Control (explicit confirmation required)
      • JSON signal generation (generate + send)
        • Copy-paste JSON output (expected schema shape)
      • DB inspection (read-only, primary)
      • Read-only helpers (DB-first)
      • Known gaps & intended fixes (tracked)
    • Data signal: TradingView-style webhook JSON generator
      • Required fields
      • Example payload
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期