backtest-kit 1.5.19 โ 1.5.21
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 +17 -4
- package/build/index.cjs +412 -248
- package/build/index.mjs +412 -248
- package/package.json +1 -1
- package/types.d.ts +9890 -9884
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Build reliable trading systems: backtest on historical data, deploy live bots wi
|
|
|
22
22
|
- ๐ **Reports & Metrics**: Auto Markdown reports with PNL, Sharpe Ratio, win rate, and more.
|
|
23
23
|
- ๐ก๏ธ **Risk Management**: Custom rules for position limits, time windows, and multi-strategy coordination.
|
|
24
24
|
- ๐ **Pluggable**: Custom data sources (CCXT), persistence (file/Redis), and sizing calculators.
|
|
25
|
-
- ๐งช **Tested**:
|
|
25
|
+
- ๐งช **Tested**: 280+ unit/integration tests for validation, recovery, and events.
|
|
26
26
|
|
|
27
27
|
### Supported Order Types
|
|
28
28
|
|
|
@@ -106,7 +106,7 @@ addFrame({
|
|
|
106
106
|
### Example Strategy (with LLM)
|
|
107
107
|
```typescript
|
|
108
108
|
import { v4 as uuid } from 'uuid';
|
|
109
|
-
import { addStrategy, dumpSignal } from 'backtest-kit';
|
|
109
|
+
import { addStrategy, dumpSignal, getCandles } from 'backtest-kit';
|
|
110
110
|
import { json } from './utils/json.mjs'; // LLM wrapper
|
|
111
111
|
import { getMessages } from './utils/messages.mjs'; // Market data prep
|
|
112
112
|
|
|
@@ -115,10 +115,23 @@ addStrategy({
|
|
|
115
115
|
interval: '5m',
|
|
116
116
|
riskName: 'demo',
|
|
117
117
|
getSignal: async (symbol) => {
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
const candles1h = await getCandles(symbol, "1h", 24);
|
|
120
|
+
const candles15m = await getCandles(symbol, "15m", 48);
|
|
121
|
+
const candles5m = await getCandles(symbol, "5m", 60);
|
|
122
|
+
const candles1m = await getCandles(symbol, "1m", 60);
|
|
123
|
+
|
|
124
|
+
const messages = await getMessages(symbol, {
|
|
125
|
+
candles1h,
|
|
126
|
+
candles15m,
|
|
127
|
+
candles5m,
|
|
128
|
+
candles1m,
|
|
129
|
+
}); // Calculate indicators / Fetch news
|
|
130
|
+
|
|
119
131
|
const resultId = uuid();
|
|
120
132
|
const signal = await json(messages); // LLM generates signal
|
|
121
133
|
await dumpSignal(resultId, messages, signal); // Log
|
|
134
|
+
|
|
122
135
|
return { ...signal, id: resultId };
|
|
123
136
|
},
|
|
124
137
|
});
|
|
@@ -166,7 +179,7 @@ Customize via `setConfig()`:
|
|
|
166
179
|
|
|
167
180
|
## Tested & Reliable
|
|
168
181
|
|
|
169
|
-
|
|
182
|
+
280+ tests cover validation, recovery, reports, and events.
|
|
170
183
|
|
|
171
184
|
## ๐ค Contribute
|
|
172
185
|
|