@backtest-kit/sidekick 13.6.0 โ 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -91
- package/package.json +1 -1
- package/template/package.mustache +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ๐งฟ @backtest-kit/sidekick
|
|
2
2
|
|
|
3
|
-
> The
|
|
3
|
+
> The fastest way to start a [backtest-kit](https://www.npmjs.com/package/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.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -8,41 +8,89 @@
|
|
|
8
8
|
[](https://npmjs.org/package/@backtest-kit/sidekick)
|
|
9
9
|
[](https://github.com/tripolskypetr/backtest-kit/blob/master/LICENSE)
|
|
10
10
|
|
|
11
|
-
๐ **[
|
|
11
|
+
๐ **[Docs](https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html)** ยท ๐ **[Reference implementation](https://github.com/tripolskypetr/backtest-kit/tree/master/example)** ยท ๐ **[GitHub](https://github.com/tripolskypetr/backtest-kit)**
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npx -y @backtest-kit/sidekick my-trading-bot
|
|
15
|
+
cd my-trading-bot && npm start
|
|
16
|
+
```
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
- ๐ **Multi-timeframe analysis** โ 4H daily trend filter (RSI + MACD + ADX) combined with 15m entry signals (EMA crossover + volume spike + momentum)
|
|
17
|
-
- ๐ **Pine Script indicators** โ strategies written in TradingView Pine Script v5, executed locally via `@backtest-kit/pinets`
|
|
18
|
-
- ๐ก๏ธ **Risk management** โ SL/TP distance validation, Kelly-optimized partial profit taking (33/33/34%), breakeven trailing stop
|
|
19
|
-
- ๐ **Position lifecycle** โ full monitoring with scheduled/opened/closed/cancelled event logging
|
|
20
|
-
- ๐ **Binance integration** โ OHLCV candles, order book depth, tick-precise price/quantity formatting via CCXT
|
|
21
|
-
- ๐ **Historical frames** โ predefined backtest periods covering bull runs, sharp drops, and sideways markets
|
|
22
|
-
- ๐จ **Web UI dashboard** โ interactive charting via `@backtest-kit/ui`
|
|
23
|
-
- ๐พ **Persistent storage** โ crash-safe state with atomic persistence for both backtest and live modes
|
|
18
|
+
---
|
|
24
19
|
|
|
25
|
-
##
|
|
20
|
+
## Init vs. Sidekick โ pick your level of control
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
`@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.
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
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.
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
- ๐ **Zero config** โ one command, no setup.
|
|
27
|
+
- ๐ **Multi-timeframe** โ 4H trend filter (RSI+MACD+ADX) + 15m entries (EMA crossover + volume spike + momentum).
|
|
28
|
+
- ๐ **Pine Script v5** โ strategies run locally via `@backtest-kit/pinets`, no TradingView.
|
|
29
|
+
- ๐ก๏ธ **Risk management** โ SL/TP distance validation, 33/33/34 partial profit, breakeven trailing.
|
|
30
|
+
- ๐ **Full lifecycle** โ scheduled/opened/closed/cancelled event logging.
|
|
31
|
+
- ๐ **Binance via CCXT** โ OHLCV, order-book depth, tick-precise formatting.
|
|
32
|
+
- ๐ **Historical frames** โ bull, sharp-drop, and sideways periods predefined.
|
|
33
|
+
- ๐จ **Web dashboard** โ `@backtest-kit/ui` charting.
|
|
34
|
+
- ๐พ **Crash-safe storage** โ atomic persistence for backtest and live.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## The strategy it scaffolds
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary>4H trend filter (timeframe_4h.pine)</summary>
|
|
42
|
+
|
|
43
|
+
Classifies the market regime from three indicators:
|
|
44
|
+
|
|
45
|
+
| Regime | Condition |
|
|
46
|
+
|--------|-----------|
|
|
47
|
+
| **AllowLong** | ADX > 25, MACD histogram > 0, DI+ > DIโ, RSI > 50 |
|
|
48
|
+
| **AllowShort** | ADX > 25, MACD histogram < 0, DIโ > DI+, RSI < 50 |
|
|
49
|
+
| **AllowBoth** | Strong trend, no clear bull/bear regime |
|
|
50
|
+
| **NoTrades** | ADX โค 25 (weak trend) |
|
|
51
|
+
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>15m signal generator (timeframe_15m.pine)</summary>
|
|
56
|
+
|
|
57
|
+
EMA crossover confirmed by volume and momentum:
|
|
58
|
+
|
|
59
|
+
- **Long** โ EMA(5) crosses above EMA(13), RSI 40โ65, price above EMA(50), volume spike (>1.5ร MA), positive momentum.
|
|
60
|
+
- **Short** โ EMA(5) crosses below EMA(13), RSI 35โ60, price below EMA(50), volume spike, negative momentum.
|
|
61
|
+
- **SL/TP** โ static 2% / 3% from entry. **Signal expiry** โ 5 bars.
|
|
62
|
+
|
|
63
|
+
</details>
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary>Risk filters & position management</summary>
|
|
67
|
+
|
|
68
|
+
**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).
|
|
69
|
+
|
|
70
|
+
**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.
|
|
71
|
+
|
|
72
|
+
</details>
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Backtest frames</summary>
|
|
76
|
+
|
|
77
|
+
| Frame | Period | Market note |
|
|
78
|
+
|-------|--------|-------------|
|
|
79
|
+
| `February2024` | Feb 1โ29, 2024 | Bull run |
|
|
80
|
+
| `October2025` | Oct 1โ31, 2025 | Sharp drop Oct 9โ11 |
|
|
81
|
+
| `November2025` | Nov 1โ30, 2025 | Sideways with downtrend |
|
|
82
|
+
| `December2025` | Dec 1โ31, 2025 | Sideways, no clear direction |
|
|
83
|
+
|
|
84
|
+
</details>
|
|
36
85
|
|
|
37
|
-
|
|
38
|
-
- Multi-timeframe Pine Script strategy (4H trend + 15m signals)
|
|
39
|
-
- Risk management validation (SL/TP distance checks)
|
|
40
|
-
- Partial profit taking and breakeven trailing stops
|
|
41
|
-
- Cache utilities and debug scripts
|
|
42
|
-
- CLAUDE.md for AI-assisted strategy iteration
|
|
43
|
-
- Environment configuration
|
|
86
|
+
---
|
|
44
87
|
|
|
45
|
-
##
|
|
88
|
+
## Generated project structure
|
|
89
|
+
|
|
90
|
+
Everything below lands as editable source in your project โ this *is* the package's deliverable.
|
|
91
|
+
|
|
92
|
+
<details>
|
|
93
|
+
<summary>Full tree</summary>
|
|
46
94
|
|
|
47
95
|
```
|
|
48
96
|
my-trading-bot/
|
|
@@ -51,9 +99,9 @@ my-trading-bot/
|
|
|
51
99
|
โ โโโ main/bootstrap.mjs # Mode dispatcher (backtest / paper / live)
|
|
52
100
|
โ โโโ config/
|
|
53
101
|
โ โ โโโ setup.mjs # Logger, storage, notifications, UI server
|
|
54
|
-
โ โ โโโ validate.mjs
|
|
55
|
-
โ โ โโโ params.mjs
|
|
56
|
-
โ โ โโโ ccxt.mjs
|
|
102
|
+
โ โ โโโ validate.mjs # Schema validation for all enums
|
|
103
|
+
โ โ โโโ params.mjs # Environment variables (Ollama API key)
|
|
104
|
+
โ โ โโโ ccxt.mjs # Binance exchange singleton via CCXT
|
|
57
105
|
โ โโโ logic/
|
|
58
106
|
โ โ โโโ strategy/main.strategy.mjs # Main strategy โ multi-TF signal logic
|
|
59
107
|
โ โ โโโ exchange/binance.exchange.mjs # Exchange schema โ candles, order book, formatting
|
|
@@ -69,10 +117,10 @@ my-trading-bot/
|
|
|
69
117
|
โ โ โโโ BacktestLowerStopOnBreakevenAction.mjs # Trailing stop on breakeven
|
|
70
118
|
โ โ โโโ BacktestPositionMonitorAction.mjs # Position event logger
|
|
71
119
|
โ โโโ math/
|
|
72
|
-
โ โ โโโ timeframe_4h.math.mjs # 4H trend data โ RSI, MACD, ADX, DI+/DI
|
|
120
|
+
โ โ โโโ timeframe_4h.math.mjs # 4H trend data โ RSI, MACD, ADX, DI+/DIโ
|
|
73
121
|
โ โ โโโ timeframe_15m.math.mjs # 15m signal data โ EMA, ATR, volume, momentum
|
|
74
|
-
โ โโโ enum/
|
|
75
|
-
โ โโโ utils/getArgs.mjs
|
|
122
|
+
โ โโโ enum/ # String constants for type-safe schema refs
|
|
123
|
+
โ โโโ utils/getArgs.mjs # CLI argument parser with defaults
|
|
76
124
|
โโโ config/source/
|
|
77
125
|
โ โโโ timeframe_4h.pine # Pine Script v5 โ Daily Trend Filter (RSI/MACD/ADX)
|
|
78
126
|
โ โโโ timeframe_15m.pine # Pine Script v5 โ Signal Strategy (EMA/ATR/Volume)
|
|
@@ -88,85 +136,44 @@ my-trading-bot/
|
|
|
88
136
|
โ โโโ watch.sh # nvidia-smi monitor
|
|
89
137
|
โโโ CLAUDE.md # AI strategy development guide
|
|
90
138
|
โโโ .env # Environment variables
|
|
91
|
-
โโโ package.json
|
|
139
|
+
โโโ package.json
|
|
92
140
|
```
|
|
93
141
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### ๐ฏ 4H Trend Filter (`timeframe_4h.pine`)
|
|
97
|
-
|
|
98
|
-
Determines the market regime using three indicators:
|
|
99
|
-
|
|
100
|
-
| Regime | Condition |
|
|
101
|
-
|--------|-----------|
|
|
102
|
-
| **AllowLong** | ADX > 25, MACD histogram > 0, DI+ > DI-, RSI > 50 |
|
|
103
|
-
| **AllowShort** | ADX > 25, MACD histogram < 0, DI- > DI+, RSI < 50 |
|
|
104
|
-
| **AllowBoth** | Strong trend but no clear bull/bear regime |
|
|
105
|
-
| **NoTrades** | ADX โค 25 (weak trend) |
|
|
106
|
-
|
|
107
|
-
### โก 15m Signal Generator (`timeframe_15m.pine`)
|
|
108
|
-
|
|
109
|
-
Generates entry signals with EMA crossover confirmed by volume and momentum:
|
|
142
|
+
</details>
|
|
110
143
|
|
|
111
|
-
|
|
112
|
-
- **Short**: EMA(5) crosses below EMA(13), RSI 35โ60, price below EMA(50), volume spike, negative momentum
|
|
113
|
-
- **SL/TP**: Static 2%/3% from entry price
|
|
114
|
-
- **Signal expiry**: 5 bars
|
|
144
|
+
---
|
|
115
145
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- Reject signals where SL distance < 0.2% (slippage protection)
|
|
119
|
-
- Reject signals where TP distance < 0.2% (slippage protection)
|
|
120
|
-
- Trend alignment: long signals rejected in bear regime, short signals rejected in bull regime
|
|
121
|
-
|
|
122
|
-
### ๐น Position Management
|
|
123
|
-
|
|
124
|
-
- **Partial profit taking**: Scale out at 3 levels โ 33% at TP3, 33% at TP2, 34% at TP1
|
|
125
|
-
- **Breakeven trailing stop**: When breakeven is reached, lower trailing stop by 3 points
|
|
126
|
-
|
|
127
|
-
## ๐ Backtest Frames
|
|
128
|
-
|
|
129
|
-
| Frame | Period | Market Note |
|
|
130
|
-
|-------|--------|-------------|
|
|
131
|
-
| `February2024` | Feb 1โ29, 2024 | Bull run |
|
|
132
|
-
| `October2025` | Oct 1โ31, 2025 | Sharp drop Oct 9โ11 |
|
|
133
|
-
| `November2025` | Nov 1โ30, 2025 | Sideways with downtrend |
|
|
134
|
-
| `December2025` | Dec 1โ31, 2025 | Sideways, no clear direction |
|
|
135
|
-
|
|
136
|
-
## ๐ก CLI Options
|
|
146
|
+
## CLI options & dependencies
|
|
137
147
|
|
|
138
148
|
```bash
|
|
139
|
-
|
|
140
|
-
npx -y @backtest-kit/sidekick
|
|
141
|
-
|
|
142
|
-
# Create in current directory (must be empty)
|
|
143
|
-
npx -y @backtest-kit/sidekick .
|
|
149
|
+
npx -y @backtest-kit/sidekick my-bot # named project
|
|
150
|
+
npx -y @backtest-kit/sidekick . # current directory (must be empty)
|
|
144
151
|
```
|
|
145
152
|
|
|
146
|
-
|
|
153
|
+
<details>
|
|
154
|
+
<summary>Dependencies installed</summary>
|
|
147
155
|
|
|
148
156
|
| Package | Purpose |
|
|
149
157
|
|---------|---------|
|
|
150
|
-
| [backtest-kit](https://
|
|
151
|
-
| [@backtest-kit/pinets](https://
|
|
152
|
-
| [@backtest-kit/ui](https://
|
|
153
|
-
| [@backtest-kit/ollama](https://
|
|
158
|
+
| [backtest-kit](https://www.npmjs.com/package/backtest-kit) | Core backtesting / trading framework |
|
|
159
|
+
| [@backtest-kit/pinets](https://www.npmjs.com/package/@backtest-kit/pinets) | Pine Script v5 runtime for Node.js |
|
|
160
|
+
| [@backtest-kit/ui](https://www.npmjs.com/package/@backtest-kit/ui) | Interactive charting dashboard |
|
|
161
|
+
| [@backtest-kit/ollama](https://www.npmjs.com/package/@backtest-kit/ollama) | LLM inference integration |
|
|
154
162
|
| [ccxt](https://github.com/ccxt/ccxt) | Binance exchange connectivity |
|
|
155
163
|
| [functools-kit](https://www.npmjs.com/package/functools-kit) | `singleshot`, `randomString` utilities |
|
|
156
164
|
| [pinolog](https://www.npmjs.com/package/pinolog) | File-based structured logging |
|
|
157
165
|
| [openai](https://www.npmjs.com/package/openai) | OpenAI API client |
|
|
158
166
|
| [ollama](https://www.npmjs.com/package/ollama) | Ollama local LLM client |
|
|
159
167
|
|
|
168
|
+
</details>
|
|
169
|
+
|
|
160
170
|
## ๐ Links
|
|
161
171
|
|
|
162
|
-
|
|
163
|
-
- [GitHub Repository](https://github.com/tripolskypetr/backtest-kit)
|
|
164
|
-
- [Demo Projects](https://github.com/tripolskypetr/backtest-kit/tree/master/demo)
|
|
165
|
-
- [API Reference](https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html)
|
|
172
|
+
[Documentation](https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html) ยท [GitHub](https://github.com/tripolskypetr/backtest-kit) ยท [Reference implementation](https://github.com/tripolskypetr/backtest-kit/tree/master/example)
|
|
166
173
|
|
|
167
174
|
## ๐ค Contribute
|
|
168
175
|
|
|
169
|
-
Found a bug or want
|
|
176
|
+
Found a bug or want a feature? [Open an issue](https://github.com/tripolskypetr/backtest-kit/issues) or submit a PR.
|
|
170
177
|
|
|
171
178
|
## ๐ License
|
|
172
179
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtest-kit/sidekick",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "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.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Petr Tripolsky",
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
"start": "node ./src/index.mjs --backtest"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@backtest-kit/ollama": "^
|
|
13
|
-
"@backtest-kit/pinets": "^
|
|
14
|
-
"@backtest-kit/ui": "^
|
|
12
|
+
"@backtest-kit/ollama": "^14.0.0",
|
|
13
|
+
"@backtest-kit/pinets": "^14.0.0",
|
|
14
|
+
"@backtest-kit/ui": "^14.0.0",
|
|
15
15
|
"@huggingface/inference": "^4.7.1",
|
|
16
16
|
"@langchain/core": "^0.3.57",
|
|
17
17
|
"@langchain/xai": "^0.0.2",
|
|
18
|
-
"agent-swarm-kit": "^2.
|
|
19
|
-
"backtest-kit": "^
|
|
18
|
+
"agent-swarm-kit": "^3.2.0",
|
|
19
|
+
"backtest-kit": "^14.0.0",
|
|
20
20
|
"ccxt": "^4.4.41",
|
|
21
21
|
"dotenv": "^16.4.7",
|
|
22
|
-
"functools-kit": "^
|
|
22
|
+
"functools-kit": "^3.0.0",
|
|
23
23
|
"ollama": "^0.6.0",
|
|
24
24
|
"openai": "^4.97.0",
|
|
25
25
|
"pinolog": "^1.0.5",
|