@backtest-kit/sidekick

中文文档
23.7.0发布于 2026/10/29MITES Module近 30 天下载 2979

The easiest way to create a new Backtest Kit trading bot project. Like create-react-app, but for algorithmic trading with LLM integration and technical analysis.

原始使用文档
文档目录7 节
  1. Init vs. Sidekick — pick your level of control
  2. The strategy it scaffolds
  3. Generated project structure
  4. CLI options & dependencies
  5. 🔗 Links
  6. 🤝 Contribute
  7. 📜 License

🧿 @backtest-kit/sidekick

The fastest way to start a backtest-kit trading bot — but the full-control one. Scaffolds a complete multi-timeframe crypto strategy where every wire (exchange, frames, risk, actions, runner) is editable source in your project: a 4H trend filter + 15m signal generator in Pine Script, partial profit taking, breakeven trailing stops, and risk validation.

screenshot

Ask DeepWiki npm License

📚 Docs · 🌟 Reference implementation · 🐙 GitHub

npx -y @backtest-kit/sidekick my-trading-bot
cd my-trading-bot && npm start

Init vs. Sidekick — pick your level of control

@backtest-kit/cli --init keeps the boilerplate inside the CLI; your repo holds only strategy files. Sidekick is the "eject": it writes the entire wiring — exchange adapter, frames, risk rules, actions, bootstrap, runner — as plain, editable source in your project, with no CLI in the loop and nothing hidden. Choose Sidekick when you want to read and own every line, not just the strategy.

What you get out of the box: a working multi-timeframe Pine Script strategy (4H trend + 15m signals), SL/TP distance risk validation, partial profit taking + breakeven trailing stops, cache utilities and debug scripts, a CLAUDE.md for AI-assisted iteration, and environment config.

  • 🚀 Zero config — one command, no setup.
  • 📊 Multi-timeframe — 4H trend filter (RSI+MACD+ADX) + 15m entries (EMA crossover + volume spike + momentum).
  • 📜 Pine Script v5 — strategies run locally via @backtest-kit/pinets, no TradingView.
  • 🛡️ Risk management — SL/TP distance validation, 33/33/34 partial profit, breakeven trailing.
  • 🔄 Full lifecycle — scheduled/opened/closed/cancelled event logging.
  • 🔌 Binance via CCXT — OHLCV, order-book depth, tick-precise formatting.
  • 🕐 Historical frames — bull, sharp-drop, and sideways periods predefined.
  • 🎨 Web dashboard — @backtest-kit/ui charting.
  • 💾 Crash-safe storage — atomic persistence for backtest and live.

The strategy it scaffolds

4H trend filter (timeframe_4h.pine)

Classifies the market regime from three indicators:

RegimeCondition
AllowLongADX > 25, MACD histogram > 0, DI+ > DI−, RSI > 50
AllowShortADX > 25, MACD histogram < 0, DI− > DI+, RSI < 50
AllowBothStrong trend, no clear bull/bear regime
NoTradesADX ≤ 25 (weak trend)
15m signal generator (timeframe_15m.pine)

EMA crossover confirmed by volume and momentum:

  • Long — EMA(5) crosses above EMA(13), RSI 40–65, price above EMA(50), volume spike (>1.5× MA), positive momentum.
  • Short — EMA(5) crosses below EMA(13), RSI 35–60, price below EMA(50), volume spike, negative momentum.
  • SL/TP — static 2% / 3% from entry. Signal expiry — 5 bars.
Risk filters & position management

Risk filters: reject signals with SL distance < 0.2% or TP distance < 0.2% (slippage protection); enforce trend alignment (longs rejected in a bear regime, shorts in a bull regime).

Position management: partial profit taking scales out at three levels — 33% at TP3, 33% at TP2, 34% at TP1; when breakeven is reached, the trailing stop is lowered by 3 points.

Backtest frames
FramePeriodMarket note
February2024Feb 1–29, 2024Bull run
October2025Oct 1–31, 2025Sharp drop Oct 9–11
November2025Nov 1–30, 2025Sideways with downtrend
December2025Dec 1–31, 2025Sideways, no clear direction

Generated project structure

Everything below lands as editable source in your project — this is the package's deliverable.

Full tree
my-trading-bot/
├── src/
│   ├── index.mjs                  # Entry point — loads config, logic, bootstrap
│   ├── main/bootstrap.mjs         # Mode dispatcher (backtest / paper / live)
│   ├── config/
│   │   ├── setup.mjs              # Logger, storage, notifications, UI server
│   │   ├── validate.mjs          # Schema validation for all enums
│   │   ├── params.mjs            # Environment variables (Ollama API key)
│   │   └── ccxt.mjs              # Binance exchange singleton via CCXT
│   ├── logic/
│   │   ├── strategy/main.strategy.mjs    # Main strategy — multi-TF signal logic
│   │   ├── exchange/binance.exchange.mjs # Exchange schema — candles, order book, formatting
│   │   ├── frame/*.frame.mjs             # Backtest time frames (Feb 2024, Oct–Dec 2025)
│   │   ├── risk/sl_distance.risk.mjs     # Stop-loss distance validation (≥0.2%)
│   │   ├── risk/tp_distance.risk.mjs     # Take-profit distance validation (≥0.2%)
│   │   └── action/
│   │       ├── backtest_partial_profit_taking.action.mjs
│   │       ├── backtest_lower_stop_on_breakeven.action.mjs
│   │       └── backtest_position_monitor.action.mjs
│   ├── classes/
│   │   ├── BacktestPartialProfitTakingAction.mjs  # Scale out at 3 TP levels
│   │   ├── BacktestLowerStopOnBreakevenAction.mjs # Trailing stop on breakeven
│   │   └── BacktestPositionMonitorAction.mjs      # Position event logger
│   ├── math/
│   │   ├── timeframe_4h.math.mjs   # 4H trend data — RSI, MACD, ADX, DI+/DI−
│   │   └── timeframe_15m.math.mjs  # 15m signal data — EMA, ATR, volume, momentum
│   ├── enum/                       # String constants for type-safe schema refs
│   └── utils/getArgs.mjs           # CLI argument parser with defaults
├── config/source/
│   ├── timeframe_4h.pine    # Pine Script v5 — Daily Trend Filter (RSI/MACD/ADX)
│   └── timeframe_15m.pine   # Pine Script v5 — Signal Strategy (EMA/ATR/Volume)
├── scripts/
│   ├── run_timeframe_15m.mjs # Standalone 15m Pine Script runner
│   ├── run_timeframe_4h.mjs  # Standalone 4H Pine Script runner
│   └── cache/
│       ├── cache_candles.mjs     # Pre-download OHLCV candles (1m/15m/4h)
│       ├── validate_candles.mjs  # Verify cached candle data integrity
│       └── cache_model.mjs       # Pull Ollama LLM model with progress bar
├── docker/ollama/
│   ├── docker-compose.yaml   # Ollama GPU container setup
│   └── watch.sh              # nvidia-smi monitor
├── CLAUDE.md                 # AI strategy development guide
├── .env                      # Environment variables
└── package.json

CLI options & dependencies

npx -y @backtest-kit/sidekick my-bot   # named project
npx -y @backtest-kit/sidekick .        # current directory (must be empty)
Dependencies installed
PackagePurpose
backtest-kitCore backtesting / trading framework
@backtest-kit/pinetsPine Script v5 runtime for Node.js
@backtest-kit/uiInteractive charting dashboard
@backtest-kit/ollamaLLM inference integration
ccxtBinance exchange connectivity
functools-kitsingleshot, randomString utilities
pinologFile-based structured logging
openaiOpenAI API client
ollamaOllama local LLM client

Documentation · GitHub · Reference implementation

🤝 Contribute

Found a bug or want a feature? Open an issue or submit a PR.

📜 License

MIT © tripolskypetr

版本与发布记录

@backtest-kit/sidekick 共发布 176 个版本,首次发布于 2026/01/15;过去 12 个月发布了 176 个版本。

版本发布日期距今
23.7.0latest2026/10/299 天前
23.6.02026/10/299 天前
23.5.02026/10/2612 天前
23.4.02026/10/2613 天前
23.3.02026/10/2514 天前
23.2.02026/10/2414 天前

关于 @backtest-kit/sidekick 的常见问题

@backtest-kit/sidekick 是什么?

The easiest way to create a new Backtest Kit trading bot project. Like create-react-app, but for algorithmic trading with LLM integration and technical analysis.

如何安装 @backtest-kit/sidekick?

在项目目录运行 npm install @backtest-kit/sidekick,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 sidekick,可以用 npx sidekick 直接运行。

@backtest-kit/sidekick 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/backtest-kit__sidekick 是否存在。

@backtest-kit/sidekick 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@backtest-kit/sidekick 可以商用吗?

@backtest-kit/sidekick 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@backtest-kit/sidekick 的下载量有多少?

根据 npm 官方下载统计,@backtest-kit/sidekick 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,979 次,日均约 99 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@backtest-kit/sidekick 还在维护吗?

最新版本 23.7.0 发布于 2026/10/29(9 天前);至今共发布 176 个版本,其中过去 12 个月发布了 176 个;首次发布于 2026/01/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。