← 返回 Skills 市场
davidm413

bybit-order-book

作者 davidm413 · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
1331
总下载
2
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install bybit-order-book
功能描述
Download, process, and backtest ByBit derivatives historical order book data. Use this skill when the user wants to: (1) download historical order book snapshots from ByBit's derivatives history-data page using Selenium automation, (2) process/unzip ob500 JSONL files and filter to depth 50, (3) run any of 10 order-book-based trading strategies (Order Book Imbalance, Breakout, False Breakout, Scalping, Momentum, Reversal, Spoofing Detection, Optimal Execution, Market Making, Latency Arbitrage) against the data, or (4) generate full backtest performance reports with PnL, Sharpe ratio, win rate, max drawdown, and strategy comparison. Triggers on: "bybit order book", "order book backtest", "download bybit data", "ob500", "order book imbalance", "spoofing detection strategy", "market making backtest", "crypto order book", "depth of book backtest", "bybit historical data".
使用说明 (SKILL.md)

ByBit Order Book Backtester

End-to-end pipeline: download → process → backtest → report.

Dependencies

pip install undetected-chromedriver selenium pandas numpy pyarrow --break-system-packages

Chrome/Chromium must be installed for Selenium.

Workflow

The pipeline has 3 stages. Run them sequentially, or skip to later stages if data is already available.

Stage 1: Download Order Book Data

Prompt the user for:

  • Symbol (default: BTCUSDT)
  • Date range (default: last 30 days)

Run scripts/download_orderbook.py:

python scripts/download_orderbook.py \
  --symbol BTCUSDT \
  --start 2024-06-01 --end 2024-06-30 \
  --output ./data/raw

Key details:

  • Downloads from https://www.bybit.com/derivatives/en/history-data
  • Automatically chunks into 7-day windows (ByBit's limit)
  • Uses undetected-chromedriver for Cloudflare bypass
  • Outputs: ZIP files in ./data/raw/ named {date}_{symbol}_ob500.data.zip
  • For data format details: see references/bybit_data_format.md

If Selenium fails (Cloudflare blocks, UI changes): Instruct the user to manually download from the ByBit page and place ZIPs in ./data/raw/.

Stage 2: Process & Filter to Depth 50

Run scripts/process_orderbook.py:

python scripts/process_orderbook.py \
  --input ./data/raw \
  --output ./data/processed \
  --depth 50 \
  --sample-interval 1s

What it does:

  • Reads JSONL from ZIPs (each line = full 500-level L2 snapshot)
  • Filters to top 50 bid/ask levels
  • Computes derived features: mid_price, spread, volume_imbalance, microprice
  • Optionally downsamples (e.g., 1s, 5s, 1min) — recommended for faster backtests
  • Outputs: Parquet files in ./data/processed/

Without downsampling: ~860K snapshots/day, ~300 MB Parquet per day per symbol. With 1s downsampling: ~86K snapshots/day, ~5 MB per day — much more practical.

Stage 3: Backtest Strategies

Run scripts/backtest.py:

# Run all 10 strategies
python scripts/backtest.py \
  --input ./data/processed/BTCUSDT_ob50.parquet \
  --output ./reports

# Run specific strategies
python scripts/backtest.py \
  --input ./data/processed/BTCUSDT_ob50.parquet \
  --strategies imbalance,breakout,market_making \
  --output ./reports

# Quick test with limited rows
python scripts/backtest.py \
  --input ./data/processed/BTCUSDT_ob50.parquet \
  --max-rows 100000 \
  --output ./reports

Strategy keys: imbalance, breakout, false_breakout, scalping, momentum, reversal, spoofing, optimal_execution, market_making, latency_arb

Outputs in ./reports/:

  • {SYMBOL}_backtest_report.json — Full results with equity curves
  • {SYMBOL}_backtest_report.md — Comparison table and detailed metrics

Report metrics per strategy: total trades, winners/losers, win rate, cumulative PnL, Sharpe ratio, max drawdown (absolute and %), avg PnL per trade, avg hold time, profit factor, best/worst trade, equity curve.

For strategy logic and tunable parameters: see references/strategies.md

Customization

To modify strategy parameters, edit the __init__ method of any strategy class in scripts/backtest.py. Each strategy's self.params dict contains all tunables.

To add a new strategy:

  1. Subclass Strategy in scripts/backtest.py
  2. Implement on_snapshot(self, row, idx, df) with entry/exit logic
  3. Register in STRATEGY_MAP

Troubleshooting

Selenium can't load ByBit page: ByBit uses Cloudflare. Ensure undetected-chromedriver is up to date. Try --no-headless to debug visually. Fall back to manual download.

Out of memory on processing: Use --sample-interval 1s or larger. Process one day at a time.

No trades generated: Strategy thresholds may be too tight for the data period. Relax parameters (lower thresholds, shorter lookbacks) in references/strategies.md.

安全使用建议
This skill appears to do what it says: scrape ByBit's public history-data page, parse ob500 JSONL files, and run backtests. Before installing/using it: (1) be aware it uses undetected-chromedriver to bypass Cloudflare — this can violate ByBit's terms of service and is intentionally evasive behavior (use at your own risk); (2) run pip installs inside a virtualenv or container rather than with --break-system-packages; (3) Chrome/Chromium must be present and the driver may download binaries; (4) downloads and processed Parquet files can be large — ensure sufficient disk and memory or use aggressive downsampling; (5) review the scripts yourself (they are included) and run them in an isolated environment (VM/container) if you are concerned. There are no requests for API keys or secrets in the skill, and no signs of hidden exfiltration, but exercise caution around bot-evasion tooling and legal/TOS implications.
功能分析
Type: OpenClaw Skill Name: bybit-order-book Version: 1.0.0 The skill's core functionality (downloading, processing, and backtesting ByBit order book data) appears legitimate. However, the `SKILL.md` file instructs the AI agent to install Python dependencies using `pip install ... --break-system-packages`. This flag bypasses Python environment isolation, allowing packages to be installed directly into the system's Python environment. While not clear evidence of intentional malicious behavior like data exfiltration or persistence, it is a high-risk practice that could lead to system instability, dependency conflicts, or unintended modifications, thus classifying the skill as suspicious.
能力评估
Purpose & Capability
Name and description match the provided scripts: download_orderbook.py uses Selenium/undetected-chromedriver to fetch ByBit history-data, process_orderbook.py parses ZIP/JSONL and filters to depth 50, and backtest.py runs multiple strategies and generates reports. No unrelated credentials, binaries, or config paths are requested.
Instruction Scope
SKILL.md instructs the agent/user to install Selenium-related Python packages and to run the three pipeline scripts. The instructions focus on downloading from ByBit and local processing; they do not ask to read unrelated system files or exfiltrate data. Note: the pipeline explicitly uses undetected-chromedriver to bypass Cloudflare — functionally expected for this scraper but has operational and TOS implications.
Install Mechanism
No registry install spec is present (instruction-only), but SKILL.md instructs pip installing undetected-chromedriver, selenium, pandas, numpy, pyarrow using the flag --break-system-packages. This is a user-side install recommendation (no automatic external arbitrary archive downloads in the manifest). The use of undetected-chromedriver is the primary risk vector (it manages browser driver binaries and is intended to evade bot protections).
Credentials
The skill requires no environment variables, no credentials, and no config paths. All requested resources (Chrome/Chromium, Python libs, disk space) match the stated functionality. There are no requests for unrelated secrets or tokens.
Persistence & Privilege
The skill is not always-enabled, does not request persistent system-wide privileges, and does not modify other skills. It is an instruction-driven, on-demand tool that runs locally and stores data in user-specified directories.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install bybit-order-book
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /bybit-order-book 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
bybit-orderbook-backtester v1.0.0 - Initial release with end-to-end pipeline: download ByBit derivatives order book data, process & filter order book snapshots, backtest 10 built-in trading strategies, and generate full performance reports. - Supports automated & manual data download, top-50 depth filtering, and optional downsampling for efficient processing. - Includes 10 strategies: Order Book Imbalance, Breakout, False Breakout, Scalping, Momentum, Reversal, Spoofing Detection, Optimal Execution, Market Making, Latency Arbitrage. - Generates detailed backtest reports: PnL, Sharpe ratio, win rate, drawdowns, equity curves, and strategy comparisons. - Extensible by editing strategy parameters or adding new strategies in `scripts/backtest.py`.
元数据
Slug bybit-order-book
版本 1.0.0
许可证
累计安装 1
当前安装数 1
历史版本数 1
常见问题

bybit-order-book 是什么?

Download, process, and backtest ByBit derivatives historical order book data. Use this skill when the user wants to: (1) download historical order book snapshots from ByBit's derivatives history-data page using Selenium automation, (2) process/unzip ob500 JSONL files and filter to depth 50, (3) run any of 10 order-book-based trading strategies (Order Book Imbalance, Breakout, False Breakout, Scalping, Momentum, Reversal, Spoofing Detection, Optimal Execution, Market Making, Latency Arbitrage) against the data, or (4) generate full backtest performance reports with PnL, Sharpe ratio, win rate, max drawdown, and strategy comparison. Triggers on: "bybit order book", "order book backtest", "download bybit data", "ob500", "order book imbalance", "spoofing detection strategy", "market making backtest", "crypto order book", "depth of book backtest", "bybit historical data". 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1331 次。

如何安装 bybit-order-book?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install bybit-order-book」即可一键安装,无需额外配置。

bybit-order-book 是免费的吗?

是的,bybit-order-book 完全免费(开源免费),可自由下载、安装和使用。

bybit-order-book 支持哪些平台?

bybit-order-book 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 bybit-order-book?

由 davidm413(@davidm413)开发并维护,当前版本 v1.0.0。

💬 留言讨论