backtest-kit 1.5.21 โ 1.5.23
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 +32 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# ๐งฟ Backtest Kit
|
|
4
4
|
|
|
5
|
-
> A TypeScript framework for backtesting and live trading strategies on crypto markets, with crash-safe persistence, signal validation, and AI optimization.
|
|
5
|
+
> A TypeScript framework for backtesting and live trading strategies on crypto markets or forex, with crash-safe persistence, signal validation, and AI optimization.
|
|
6
|
+
|
|
7
|
+

|
|
6
8
|
|
|
7
9
|
[](https://deepwiki.com/tripolskypetr/backtest-kit)
|
|
8
10
|
[](https://npmjs.org/package/backtest-kit)
|
|
@@ -10,7 +12,7 @@
|
|
|
10
12
|
|
|
11
13
|
Build reliable trading systems: backtest on historical data, deploy live bots with recovery, and optimize strategies using LLMs like Ollama.
|
|
12
14
|
|
|
13
|
-
๐ **[API Reference](https://backtest-kit.github.io/)** | ๐ **[Quick Start](https://github.com/tripolskypetr/backtest-kit/tree/master/demo)**
|
|
15
|
+
๐ **[API Reference](https://backtest-kit.github.io/)** | ๐ **[Quick Start](https://github.com/tripolskypetr/backtest-kit/tree/master/demo)** | **๐ฐ [Article](https://tripolskypetr.medium.com/how-i-made-look-ahead-bias-architecturally-impossible-in-trading-backtests-63e4115f6e16)**
|
|
14
16
|
|
|
15
17
|
## โจ Why Choose Backtest Kit?
|
|
16
18
|
|
|
@@ -24,20 +26,20 @@ Build reliable trading systems: backtest on historical data, deploy live bots wi
|
|
|
24
26
|
- ๐ **Pluggable**: Custom data sources (CCXT), persistence (file/Redis), and sizing calculators.
|
|
25
27
|
- ๐งช **Tested**: 280+ unit/integration tests for validation, recovery, and events.
|
|
26
28
|
|
|
27
|
-
### Supported Order Types
|
|
29
|
+
### ๐ Supported Order Types
|
|
28
30
|
|
|
29
31
|
- Market/Limit entries
|
|
30
32
|
- TP/SL/OCO exits
|
|
31
33
|
- Grid with auto-cancel on unmet conditions
|
|
32
34
|
|
|
33
|
-
## Quick Start
|
|
35
|
+
## ๐ Quick Start
|
|
34
36
|
|
|
35
|
-
### Installation
|
|
37
|
+
### ๐ฆ Installation
|
|
36
38
|
```bash
|
|
37
39
|
npm install backtest-kit ccxt ollama uuid
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
### Basic Configuration
|
|
42
|
+
### โ๏ธ Basic Configuration
|
|
41
43
|
```typescript
|
|
42
44
|
import { setLogger, setConfig } from 'backtest-kit';
|
|
43
45
|
|
|
@@ -57,7 +59,7 @@ setConfig({
|
|
|
57
59
|
});
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
### Register Components
|
|
62
|
+
### ๐ง Register Components
|
|
61
63
|
```typescript
|
|
62
64
|
import ccxt from 'ccxt';
|
|
63
65
|
import { addExchange, addStrategy, addFrame, addRisk } from 'backtest-kit';
|
|
@@ -103,7 +105,7 @@ addFrame({
|
|
|
103
105
|
});
|
|
104
106
|
```
|
|
105
107
|
|
|
106
|
-
### Example Strategy (with LLM)
|
|
108
|
+
### ๐ก Example Strategy (with LLM)
|
|
107
109
|
```typescript
|
|
108
110
|
import { v4 as uuid } from 'uuid';
|
|
109
111
|
import { addStrategy, dumpSignal, getCandles } from 'backtest-kit';
|
|
@@ -137,7 +139,7 @@ addStrategy({
|
|
|
137
139
|
});
|
|
138
140
|
```
|
|
139
141
|
|
|
140
|
-
### Run Backtest
|
|
142
|
+
### ๐งช Run Backtest
|
|
141
143
|
```typescript
|
|
142
144
|
import { Backtest, listenSignalBacktest, listenDoneBacktest } from 'backtest-kit';
|
|
143
145
|
|
|
@@ -153,7 +155,7 @@ listenDoneBacktest(async (event) => {
|
|
|
153
155
|
});
|
|
154
156
|
```
|
|
155
157
|
|
|
156
|
-
### Run Live Trading
|
|
158
|
+
### ๐ Run Live Trading
|
|
157
159
|
```typescript
|
|
158
160
|
import { Live, listenSignalLive } from 'backtest-kit';
|
|
159
161
|
|
|
@@ -165,22 +167,39 @@ Live.background('BTCUSDT', {
|
|
|
165
167
|
listenSignalLive((event) => console.log(event));
|
|
166
168
|
```
|
|
167
169
|
|
|
168
|
-
### Monitoring & Events
|
|
170
|
+
### ๐ก Monitoring & Events
|
|
169
171
|
|
|
170
172
|
- Use `listenRisk`, `listenError`, `listenPartialProfit/Loss` for alerts.
|
|
171
173
|
- Dump reports: `Backtest.dump()`, `Live.dump()`.
|
|
172
174
|
|
|
173
|
-
## Global Configuration
|
|
175
|
+
## ๐ Global Configuration
|
|
174
176
|
|
|
175
177
|
Customize via `setConfig()`:
|
|
176
178
|
|
|
177
179
|
- `CC_SCHEDULE_AWAIT_MINUTES`: Pending timeout (default: 120).
|
|
178
180
|
- `CC_AVG_PRICE_CANDLES_COUNT`: VWAP candles (default: 5).
|
|
179
181
|
|
|
180
|
-
## Tested & Reliable
|
|
182
|
+
## โ
Tested & Reliable
|
|
181
183
|
|
|
182
184
|
280+ tests cover validation, recovery, reports, and events.
|
|
183
185
|
|
|
186
|
+
## ๐ป Developer Note
|
|
187
|
+
|
|
188
|
+
### ๐ How getCandles Works
|
|
189
|
+
|
|
190
|
+
backtest-kit uses Node.js `AsyncLocalStorage` to automatically provide
|
|
191
|
+
temporal context to your strategies.
|
|
192
|
+
|
|
193
|
+
### ๐ญ What this means:
|
|
194
|
+
- `getCandles()` always returns data UP TO the current backtest timestamp using `async_hooks`
|
|
195
|
+
- Multi-timeframe data is automatically synchronized
|
|
196
|
+
- **Impossible to introduce look-ahead bias**
|
|
197
|
+
- Same code works in both backtest and live modes
|
|
198
|
+
|
|
199
|
+
## ๐ค Are you a robot?
|
|
200
|
+
|
|
201
|
+
**For language models**: Read extended description in [./LLMs.md](./LLMs.md)
|
|
202
|
+
|
|
184
203
|
## ๐ค Contribute
|
|
185
204
|
|
|
186
205
|
Fork/PR on [GitHub](https://github.com/tripolskypetr/backtest-kit).
|
|
@@ -189,6 +208,3 @@ Fork/PR on [GitHub](https://github.com/tripolskypetr/backtest-kit).
|
|
|
189
208
|
|
|
190
209
|
MIT ยฉ [tripolskypetr](https://github.com/tripolskypetr)
|
|
191
210
|
|
|
192
|
-
## ๐ค Are you a robot?
|
|
193
|
-
|
|
194
|
-
**For language models**: Read extended description in [./LLMs.md](./LLMs.md)
|