backtest-kit 1.5.19 → 1.5.20
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 +16 -3
- package/build/index.cjs +3 -3
- package/build/index.mjs +3 -3
- package/package.json +1 -1
- package/types.d.ts +9884 -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
|
+
candles15m,
|
|
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
|
});
|
package/build/index.cjs
CHANGED
|
@@ -2075,7 +2075,7 @@ const GET_SIGNAL_FN = functoolsKit.trycatch(async (self) => {
|
|
|
2075
2075
|
// НЕМЕДЛЕННАЯ АКТИВАЦИЯ: priceOpen уже достигнут
|
|
2076
2076
|
// Создаем активный сигнал напрямую (БЕЗ scheduled фазы)
|
|
2077
2077
|
const signalRow = {
|
|
2078
|
-
id: functoolsKit.randomString(),
|
|
2078
|
+
id: signal.id || functoolsKit.randomString(),
|
|
2079
2079
|
priceOpen: signal.priceOpen, // Используем priceOpen из сигнала
|
|
2080
2080
|
position: signal.position,
|
|
2081
2081
|
note: toPlainString(signal.note),
|
|
@@ -2095,7 +2095,7 @@ const GET_SIGNAL_FN = functoolsKit.trycatch(async (self) => {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
// ОЖИДАНИЕ АКТИВАЦИИ: создаем scheduled signal (risk check при активации)
|
|
2097
2097
|
const scheduledSignalRow = {
|
|
2098
|
-
id: functoolsKit.randomString(),
|
|
2098
|
+
id: signal.id || functoolsKit.randomString(),
|
|
2099
2099
|
priceOpen: signal.priceOpen,
|
|
2100
2100
|
position: signal.position,
|
|
2101
2101
|
note: toPlainString(signal.note),
|
|
@@ -2114,7 +2114,7 @@ const GET_SIGNAL_FN = functoolsKit.trycatch(async (self) => {
|
|
|
2114
2114
|
return scheduledSignalRow;
|
|
2115
2115
|
}
|
|
2116
2116
|
const signalRow = {
|
|
2117
|
-
id: functoolsKit.randomString(),
|
|
2117
|
+
id: signal.id || functoolsKit.randomString(),
|
|
2118
2118
|
priceOpen: currentPrice,
|
|
2119
2119
|
...signal,
|
|
2120
2120
|
note: toPlainString(signal.note),
|
package/build/index.mjs
CHANGED
|
@@ -2073,7 +2073,7 @@ const GET_SIGNAL_FN = trycatch(async (self) => {
|
|
|
2073
2073
|
// НЕМЕДЛЕННАЯ АКТИВАЦИЯ: priceOpen уже достигнут
|
|
2074
2074
|
// Создаем активный сигнал напрямую (БЕЗ scheduled фазы)
|
|
2075
2075
|
const signalRow = {
|
|
2076
|
-
id: randomString(),
|
|
2076
|
+
id: signal.id || randomString(),
|
|
2077
2077
|
priceOpen: signal.priceOpen, // Используем priceOpen из сигнала
|
|
2078
2078
|
position: signal.position,
|
|
2079
2079
|
note: toPlainString(signal.note),
|
|
@@ -2093,7 +2093,7 @@ const GET_SIGNAL_FN = trycatch(async (self) => {
|
|
|
2093
2093
|
}
|
|
2094
2094
|
// ОЖИДАНИЕ АКТИВАЦИИ: создаем scheduled signal (risk check при активации)
|
|
2095
2095
|
const scheduledSignalRow = {
|
|
2096
|
-
id: randomString(),
|
|
2096
|
+
id: signal.id || randomString(),
|
|
2097
2097
|
priceOpen: signal.priceOpen,
|
|
2098
2098
|
position: signal.position,
|
|
2099
2099
|
note: toPlainString(signal.note),
|
|
@@ -2112,7 +2112,7 @@ const GET_SIGNAL_FN = trycatch(async (self) => {
|
|
|
2112
2112
|
return scheduledSignalRow;
|
|
2113
2113
|
}
|
|
2114
2114
|
const signalRow = {
|
|
2115
|
-
id: randomString(),
|
|
2115
|
+
id: signal.id || randomString(),
|
|
2116
2116
|
priceOpen: currentPrice,
|
|
2117
2117
|
...signal,
|
|
2118
2118
|
note: toPlainString(signal.note),
|