backtest-kit 5.6.8 → 5.10.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 +18 -4
- package/build/index.cjs +3623 -587
- package/build/index.mjs +3610 -587
- package/package.json +1 -1
- package/types.d.ts +1289 -103
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ npm install backtest-kit ccxt ollama uuid
|
|
|
62
62
|
- Breakeven protection
|
|
63
63
|
- Stop limit entries (before OCO)
|
|
64
64
|
- Dollar cost averaging
|
|
65
|
+
- Time attack / Infinite hold
|
|
65
66
|
|
|
66
67
|
## 📚 Code Samples
|
|
67
68
|
|
|
@@ -134,7 +135,7 @@ addFrameSchema({
|
|
|
134
135
|
### 💡 Example Strategy (with LLM)
|
|
135
136
|
```typescript
|
|
136
137
|
import { v4 as uuid } from 'uuid';
|
|
137
|
-
import { addStrategySchema,
|
|
138
|
+
import { addStrategySchema, getCandles, Dump } from 'backtest-kit';
|
|
138
139
|
import { json } from './utils/json.mjs'; // LLM wrapper
|
|
139
140
|
import { getMessages } from './utils/messages.mjs'; // Market data prep
|
|
140
141
|
|
|
@@ -158,7 +159,20 @@ addStrategySchema({
|
|
|
158
159
|
|
|
159
160
|
const resultId = uuid();
|
|
160
161
|
const signal = await json(messages); // LLM generates signal
|
|
161
|
-
|
|
162
|
+
|
|
163
|
+
Dump.dumpAgentAnswer(messages, {
|
|
164
|
+
dumpId: "position-context",
|
|
165
|
+
bucketName: "multi-timeframe-strategy",
|
|
166
|
+
signalId: resultId,
|
|
167
|
+
description: signal.description, // search keywords for BM25 index
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
Dump.dumpRecord(signal, {
|
|
171
|
+
dumpId: "position-entry",
|
|
172
|
+
bucketName: "multi-timeframe-strategy",
|
|
173
|
+
signalId: resultId,
|
|
174
|
+
description: signal.description, // agent can review the history using RAG
|
|
175
|
+
});
|
|
162
176
|
|
|
163
177
|
return { ...signal, id: resultId };
|
|
164
178
|
},
|
|
@@ -214,7 +228,7 @@ Backtest Kit is **not a data-processing library** - it is a **time execution eng
|
|
|
214
228
|
These three functions work together to dynamically manage the position. To reduce position linearity, by default, each DCA entry is formatted as a fixed **unit of $100**. This can be changed. No mathematical knowledge is required.
|
|
215
229
|
|
|
216
230
|
**Public API:**
|
|
217
|
-
- **`commitAverageBuy`** — adds a new DCA entry.
|
|
231
|
+
- **`commitAverageBuy`** — adds a new DCA entry. By default, **only accepted when current price is below a new low**. Silently rejected otherwise. This prevents averaging up. Can be overridden using `setConfig`
|
|
218
232
|
- **`commitPartialProfit`** — closes X% of the position at a profit. Locks in gains while keeping exposure.
|
|
219
233
|
- **`commitPartialLoss`** — closes X% of the position at a loss. Cuts exposure before the stop-loss is hit.
|
|
220
234
|
|
|
@@ -1674,7 +1688,7 @@ npm start
|
|
|
1674
1688
|
|
|
1675
1689
|
## ✅ Tested & Reliable
|
|
1676
1690
|
|
|
1677
|
-
|
|
1691
|
+
515+ tests cover validation, recovery, reports, and events.
|
|
1678
1692
|
|
|
1679
1693
|
## 🤝 Contribute
|
|
1680
1694
|
|