@tradejs/strategies 1.0.6 → 1.0.8
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/dist/chunk-37ZWRG3W.mjs +128 -0
- package/dist/chunk-H4MHFD4B.mjs +62 -0
- package/dist/{chunk-MOBKL73M.mjs → chunk-IMLNXICX.mjs} +183 -41
- package/dist/{chunk-XMRB45ZO.mjs → chunk-QVWMBYYM.mjs} +92 -45
- package/dist/chunk-SOVTOGY4.mjs +163 -0
- package/dist/{chunk-H2TU2YMA.mjs → chunk-TDUTYEGH.mjs} +111 -76
- package/dist/{chunk-GNQJ5TVU.mjs → chunk-UK4YHD2E.mjs} +34 -38
- package/dist/index.d.mts +294 -13
- package/dist/index.d.ts +294 -13
- package/dist/index.js +1825 -906
- package/dist/index.mjs +51 -18
- package/dist/{strategy-FYNNJDOH.mjs → strategy-ABIO65CR.mjs} +2 -33
- package/dist/{strategy-AFIGEHDS.mjs → strategy-D7H5J3C4.mjs} +1 -71
- package/dist/{strategy-LC2FSFVN.mjs → strategy-HQIPCUOY.mjs} +1 -72
- package/dist/{strategy-Y4SOK6FF.mjs → strategy-JQIJILHQ.mjs} +28 -109
- package/dist/strategy-QEIPAPY4.mjs +373 -0
- package/dist/{strategy-6TS2NFSC.mjs → strategy-WYN4FZ5S.mjs} +2 -125
- package/dist/{strategy-OI4WRB3S.mjs → strategy-XTUKPYPM.mjs} +466 -120
- package/package.json +5 -5
- package/dist/chunk-3PN7ZSJJ.mjs +0 -27
- package/dist/chunk-RDK2JK3K.mjs +0 -28
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
breakoutManifest
|
|
3
|
-
|
|
2
|
+
breakoutManifest,
|
|
3
|
+
config as config2
|
|
4
|
+
} from "./chunk-37ZWRG3W.mjs";
|
|
4
5
|
import {
|
|
5
|
-
config,
|
|
6
|
+
config as config6,
|
|
6
7
|
trendLineManifest
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TDUTYEGH.mjs";
|
|
8
9
|
import {
|
|
9
|
-
config as
|
|
10
|
+
config as config5,
|
|
11
|
+
trendShiftAiAdapter,
|
|
12
|
+
trendShiftManifest
|
|
13
|
+
} from "./chunk-SOVTOGY4.mjs";
|
|
14
|
+
import {
|
|
15
|
+
config as config4,
|
|
10
16
|
reverseTrendLineAiAdapter,
|
|
11
17
|
reverseTrendLineManifest
|
|
12
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UK4YHD2E.mjs";
|
|
13
19
|
import {
|
|
20
|
+
config as config3,
|
|
14
21
|
maStrategyAiAdapter,
|
|
15
22
|
maStrategyManifest,
|
|
16
23
|
maStrategyMlAdapter
|
|
17
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-H4MHFD4B.mjs";
|
|
18
25
|
import {
|
|
19
26
|
adaptiveMomentumRibbonAiAdapter,
|
|
20
27
|
adaptiveMomentumRibbonManifest,
|
|
21
|
-
adaptiveMomentumRibbonMlAdapter
|
|
22
|
-
|
|
28
|
+
adaptiveMomentumRibbonMlAdapter,
|
|
29
|
+
config
|
|
30
|
+
} from "./chunk-IMLNXICX.mjs";
|
|
23
31
|
import {
|
|
32
|
+
config as config7,
|
|
24
33
|
volumeDivergenceAiAdapter,
|
|
25
34
|
volumeDivergenceManifest,
|
|
26
35
|
volumeDivergenceMlAdapter
|
|
27
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-QVWMBYYM.mjs";
|
|
28
37
|
import "./chunk-HEBXNMVQ.mjs";
|
|
29
38
|
|
|
30
39
|
// src/index.ts
|
|
@@ -45,57 +54,81 @@ var strategyEntries = [
|
|
|
45
54
|
{
|
|
46
55
|
manifest: breakoutManifest,
|
|
47
56
|
creator: createLazyStrategyCreator(
|
|
48
|
-
() => import("./strategy-
|
|
57
|
+
() => import("./strategy-JQIJILHQ.mjs"),
|
|
49
58
|
"BreakoutStrategyCreator"
|
|
50
59
|
)
|
|
51
60
|
},
|
|
52
61
|
{
|
|
53
62
|
manifest: trendLineManifest,
|
|
54
63
|
creator: createLazyStrategyCreator(
|
|
55
|
-
() => import("./strategy-
|
|
64
|
+
() => import("./strategy-D7H5J3C4.mjs"),
|
|
56
65
|
"TrendlineStrategyCreator"
|
|
57
66
|
)
|
|
58
67
|
},
|
|
68
|
+
{
|
|
69
|
+
manifest: trendShiftManifest,
|
|
70
|
+
creator: createLazyStrategyCreator(
|
|
71
|
+
() => import("./strategy-QEIPAPY4.mjs"),
|
|
72
|
+
"TrendShiftStrategyCreator"
|
|
73
|
+
)
|
|
74
|
+
},
|
|
59
75
|
{
|
|
60
76
|
manifest: reverseTrendLineManifest,
|
|
61
77
|
creator: createLazyStrategyCreator(
|
|
62
|
-
() => import("./strategy-
|
|
78
|
+
() => import("./strategy-HQIPCUOY.mjs"),
|
|
63
79
|
"ReverseTrendLineStrategyCreator"
|
|
64
80
|
)
|
|
65
81
|
},
|
|
66
82
|
{
|
|
67
83
|
manifest: maStrategyManifest,
|
|
68
84
|
creator: createLazyStrategyCreator(
|
|
69
|
-
() => import("./strategy-
|
|
85
|
+
() => import("./strategy-ABIO65CR.mjs"),
|
|
70
86
|
"MaStrategyCreator"
|
|
71
87
|
)
|
|
72
88
|
},
|
|
73
89
|
{
|
|
74
90
|
manifest: adaptiveMomentumRibbonManifest,
|
|
75
91
|
creator: createLazyStrategyCreator(
|
|
76
|
-
() => import("./strategy-
|
|
92
|
+
() => import("./strategy-XTUKPYPM.mjs"),
|
|
77
93
|
"AdaptiveMomentumRibbonStrategyCreator"
|
|
78
94
|
)
|
|
79
95
|
},
|
|
80
96
|
{
|
|
81
97
|
manifest: volumeDivergenceManifest,
|
|
82
98
|
creator: createLazyStrategyCreator(
|
|
83
|
-
() => import("./strategy-
|
|
99
|
+
() => import("./strategy-WYN4FZ5S.mjs"),
|
|
84
100
|
"VolumeDivergenceStrategyCreator"
|
|
85
101
|
)
|
|
86
102
|
}
|
|
87
103
|
];
|
|
104
|
+
var builtInStrategyDefaultConfigs = {
|
|
105
|
+
Breakout: config2,
|
|
106
|
+
TrendLine: config6,
|
|
107
|
+
TrendShift: config5,
|
|
108
|
+
ReverseTrendLine: config4,
|
|
109
|
+
MaStrategy: config3,
|
|
110
|
+
AdaptiveMomentumRibbon: config,
|
|
111
|
+
VolumeDivergence: config7
|
|
112
|
+
};
|
|
113
|
+
var getBuiltInStrategyDefaultConfig = (strategyName) => builtInStrategyDefaultConfigs[strategyName];
|
|
88
114
|
var index_default = defineStrategyPlugin({ strategyEntries });
|
|
89
115
|
export {
|
|
90
116
|
adaptiveMomentumRibbonAiAdapter,
|
|
117
|
+
config as adaptiveMomentumRibbonDefaultConfig,
|
|
91
118
|
adaptiveMomentumRibbonMlAdapter,
|
|
119
|
+
config2 as breakoutDefaultConfig,
|
|
92
120
|
index_default as default,
|
|
121
|
+
getBuiltInStrategyDefaultConfig,
|
|
93
122
|
maStrategyAiAdapter,
|
|
123
|
+
config3 as maStrategyDefaultConfig,
|
|
94
124
|
maStrategyMlAdapter,
|
|
95
125
|
reverseTrendLineAiAdapter,
|
|
96
|
-
|
|
126
|
+
config4 as reverseTrendLineDefaultConfig,
|
|
97
127
|
strategyEntries,
|
|
98
|
-
|
|
128
|
+
config6 as trendLineDefaultConfig,
|
|
129
|
+
trendShiftAiAdapter,
|
|
130
|
+
config5 as trendShiftDefaultConfig,
|
|
99
131
|
volumeDivergenceAiAdapter,
|
|
132
|
+
config7 as volumeDivergenceDefaultConfig,
|
|
100
133
|
volumeDivergenceMlAdapter
|
|
101
134
|
};
|
|
@@ -1,43 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
config,
|
|
2
3
|
maStrategyManifest
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-H4MHFD4B.mjs";
|
|
4
5
|
import "./chunk-HEBXNMVQ.mjs";
|
|
5
6
|
|
|
6
7
|
// src/MaStrategy/strategy.ts
|
|
7
8
|
import { createStrategyRuntime } from "@tradejs/node/strategies";
|
|
8
9
|
|
|
9
|
-
// src/MaStrategy/config.ts
|
|
10
|
-
var config = {
|
|
11
|
-
ENV: "BACKTEST",
|
|
12
|
-
INTERVAL: "15",
|
|
13
|
-
MAKE_ORDERS: true,
|
|
14
|
-
CLOSE_OPPOSITE_POSITIONS: false,
|
|
15
|
-
BACKTEST_PRICE_MODE: "mid",
|
|
16
|
-
AI_ENABLED: false,
|
|
17
|
-
ML_ENABLED: false,
|
|
18
|
-
ML_THRESHOLD: 0.1,
|
|
19
|
-
MIN_AI_QUALITY: 3,
|
|
20
|
-
FEE_PERCENT: 5e-3,
|
|
21
|
-
MAX_LOSS_VALUE: 10,
|
|
22
|
-
TRADE_COOLDOWN_MS: 0,
|
|
23
|
-
MA_FAST: 21,
|
|
24
|
-
MA_SLOW: 55,
|
|
25
|
-
LONG: {
|
|
26
|
-
enable: true,
|
|
27
|
-
direction: "LONG",
|
|
28
|
-
TP: 2,
|
|
29
|
-
SL: 1,
|
|
30
|
-
minRiskRatio: 1.5
|
|
31
|
-
},
|
|
32
|
-
SHORT: {
|
|
33
|
-
enable: true,
|
|
34
|
-
direction: "SHORT",
|
|
35
|
-
TP: 2,
|
|
36
|
-
SL: 1,
|
|
37
|
-
minRiskRatio: 1.5
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
10
|
// src/MaStrategy/core.ts
|
|
42
11
|
import { round } from "@tradejs/core/math";
|
|
43
12
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
buildTrendlineTimingContext,
|
|
4
4
|
config,
|
|
5
5
|
trendLineManifest
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TDUTYEGH.mjs";
|
|
7
7
|
import "./chunk-HEBXNMVQ.mjs";
|
|
8
8
|
|
|
9
9
|
// src/TrendLine/strategy.ts
|
|
@@ -174,7 +174,6 @@ var buildTrendlineRiskPlan = ({
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
// src/TrendLine/core.ts
|
|
177
|
-
var BREAK_EVEN_TRIGGER_RISK_MULTIPLIER = 0.5;
|
|
178
177
|
var buildTrendlineSignalSeed = ({
|
|
179
178
|
direction,
|
|
180
179
|
currentPrice,
|
|
@@ -198,51 +197,6 @@ var buildTrendlineSignalSeed = ({
|
|
|
198
197
|
var isOpenPosition = (position) => Boolean(
|
|
199
198
|
position && typeof position.price === "number" && Number.isFinite(position.price) && typeof position.qty === "number" && Number.isFinite(position.qty) && position.qty > 0 && (position.direction === "LONG" || position.direction === "SHORT")
|
|
200
199
|
);
|
|
201
|
-
var getFavorableMovePct = ({
|
|
202
|
-
direction,
|
|
203
|
-
entryPrice,
|
|
204
|
-
currentPrice
|
|
205
|
-
}) => {
|
|
206
|
-
if (!Number.isFinite(entryPrice) || !Number.isFinite(currentPrice) || entryPrice <= 0) {
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
return direction === "LONG" ? (currentPrice - entryPrice) / entryPrice * 100 : (entryPrice - currentPrice) / entryPrice * 100;
|
|
210
|
-
};
|
|
211
|
-
var getPositionStopLossPrice = (position) => {
|
|
212
|
-
if (!position || typeof position !== "object") {
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
const slPrice = Number(
|
|
216
|
-
position.slPrice ?? Number.NaN
|
|
217
|
-
);
|
|
218
|
-
if (Number.isFinite(slPrice)) {
|
|
219
|
-
return slPrice;
|
|
220
|
-
}
|
|
221
|
-
const signalStopLossPrice = Number(
|
|
222
|
-
position.signal?.prices?.stopLossPrice ?? Number.NaN
|
|
223
|
-
);
|
|
224
|
-
return Number.isFinite(signalStopLossPrice) ? signalStopLossPrice : null;
|
|
225
|
-
};
|
|
226
|
-
var getPositionRiskPct = ({
|
|
227
|
-
direction,
|
|
228
|
-
entryPrice,
|
|
229
|
-
stopLossPrice
|
|
230
|
-
}) => {
|
|
231
|
-
if (stopLossPrice == null || !Number.isFinite(entryPrice) || !Number.isFinite(stopLossPrice) || entryPrice <= 0) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
return direction === "LONG" ? (entryPrice - stopLossPrice) / entryPrice * 100 : (stopLossPrice - entryPrice) / entryPrice * 100;
|
|
235
|
-
};
|
|
236
|
-
var isBreakEvenStopAlreadyApplied = ({
|
|
237
|
-
direction,
|
|
238
|
-
entryPrice,
|
|
239
|
-
stopLossPrice
|
|
240
|
-
}) => {
|
|
241
|
-
if (stopLossPrice == null || !Number.isFinite(entryPrice) || !Number.isFinite(stopLossPrice)) {
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
return direction === "LONG" ? stopLossPrice >= entryPrice : stopLossPrice <= entryPrice;
|
|
245
|
-
};
|
|
246
200
|
var isFailedBreakout = ({
|
|
247
201
|
direction,
|
|
248
202
|
priceVsLinePct
|
|
@@ -277,17 +231,6 @@ var createTrendLineCore = async ({ config: config2, data: cachedData, strategyAp
|
|
|
277
231
|
const { currentPrice: currentPrice2 } = await strategyApi.getMarketData();
|
|
278
232
|
const activeLine = currentPosition.direction === "LONG" ? highsTrendlines[0] : lowsTrendlines[0];
|
|
279
233
|
const activeModeConfig = currentPosition.direction === "LONG" ? HIGHS : LOWS;
|
|
280
|
-
const currentStopLossPrice = getPositionStopLossPrice(currentPosition);
|
|
281
|
-
const favorableMovePct = getFavorableMovePct({
|
|
282
|
-
direction: currentPosition.direction,
|
|
283
|
-
entryPrice: currentPosition.price,
|
|
284
|
-
currentPrice: currentPrice2
|
|
285
|
-
});
|
|
286
|
-
const currentPositionRiskPct = getPositionRiskPct({
|
|
287
|
-
direction: currentPosition.direction,
|
|
288
|
-
entryPrice: currentPosition.price,
|
|
289
|
-
stopLossPrice: currentStopLossPrice
|
|
290
|
-
});
|
|
291
234
|
if (activeLine) {
|
|
292
235
|
const indicators2 = indicatorsState.snapshot();
|
|
293
236
|
const manageSignalSeed = buildTrendlineSignalSeed({
|
|
@@ -307,19 +250,6 @@ var createTrendLineCore = async ({ config: config2, data: cachedData, strategyAp
|
|
|
307
250
|
});
|
|
308
251
|
}
|
|
309
252
|
}
|
|
310
|
-
if (!isBreakEvenStopAlreadyApplied({
|
|
311
|
-
direction: currentPosition.direction,
|
|
312
|
-
entryPrice: currentPosition.price,
|
|
313
|
-
stopLossPrice: currentStopLossPrice
|
|
314
|
-
}) && favorableMovePct != null && favorableMovePct >= (currentPositionRiskPct ?? activeModeConfig.SL) * BREAK_EVEN_TRIGGER_RISK_MULTIPLIER) {
|
|
315
|
-
return strategyApi.protect({
|
|
316
|
-
code: "TRENDLINE_MOVE_STOP_TO_BREAK_EVEN",
|
|
317
|
-
protectPlan: {
|
|
318
|
-
direction: currentPosition.direction,
|
|
319
|
-
stopLossPrice: currentPosition.price
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
253
|
return strategyApi.skip("POSITION_EXISTS");
|
|
324
254
|
}
|
|
325
255
|
const bestLine = lowsTrendlines.length > 0 ? lowsTrendlines[0] : highsTrendlines[0];
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
config,
|
|
5
5
|
reverseTrendLineManifest,
|
|
6
6
|
toFiniteNumberOrNull
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UK4YHD2E.mjs";
|
|
8
8
|
import "./chunk-HEBXNMVQ.mjs";
|
|
9
9
|
|
|
10
10
|
// src/ReverseTrendLine/strategy.ts
|
|
@@ -151,7 +151,6 @@ var buildReverseTrendlineRiskPlan = ({
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
// src/ReverseTrendLine/core.ts
|
|
154
|
-
var BREAK_EVEN_TRIGGER_RISK_MULTIPLIER = 0.5;
|
|
155
154
|
var buildReverseTrendlineSignalSeed = ({
|
|
156
155
|
direction,
|
|
157
156
|
currentPrice,
|
|
@@ -177,51 +176,6 @@ var buildReverseTrendlineSignalSeed = ({
|
|
|
177
176
|
var isOpenPosition = (position) => Boolean(
|
|
178
177
|
position && typeof position.price === "number" && Number.isFinite(position.price) && typeof position.qty === "number" && Number.isFinite(position.qty) && position.qty > 0 && (position.direction === "LONG" || position.direction === "SHORT")
|
|
179
178
|
);
|
|
180
|
-
var getFavorableMovePct = ({
|
|
181
|
-
direction,
|
|
182
|
-
entryPrice,
|
|
183
|
-
currentPrice
|
|
184
|
-
}) => {
|
|
185
|
-
if (!Number.isFinite(entryPrice) || !Number.isFinite(currentPrice) || entryPrice <= 0) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
return direction === "LONG" ? (currentPrice - entryPrice) / entryPrice * 100 : (entryPrice - currentPrice) / entryPrice * 100;
|
|
189
|
-
};
|
|
190
|
-
var getPositionStopLossPrice = (position) => {
|
|
191
|
-
if (!position || typeof position !== "object") {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
const slPrice = Number(
|
|
195
|
-
position.slPrice ?? Number.NaN
|
|
196
|
-
);
|
|
197
|
-
if (Number.isFinite(slPrice)) {
|
|
198
|
-
return slPrice;
|
|
199
|
-
}
|
|
200
|
-
const signalStopLossPrice = Number(
|
|
201
|
-
position.signal?.prices?.stopLossPrice ?? Number.NaN
|
|
202
|
-
);
|
|
203
|
-
return Number.isFinite(signalStopLossPrice) ? signalStopLossPrice : null;
|
|
204
|
-
};
|
|
205
|
-
var getPositionRiskPct = ({
|
|
206
|
-
direction,
|
|
207
|
-
entryPrice,
|
|
208
|
-
stopLossPrice
|
|
209
|
-
}) => {
|
|
210
|
-
if (stopLossPrice == null || !Number.isFinite(entryPrice) || !Number.isFinite(stopLossPrice) || entryPrice <= 0) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
return direction === "LONG" ? (entryPrice - stopLossPrice) / entryPrice * 100 : (stopLossPrice - entryPrice) / entryPrice * 100;
|
|
214
|
-
};
|
|
215
|
-
var isBreakEvenStopAlreadyApplied = ({
|
|
216
|
-
direction,
|
|
217
|
-
entryPrice,
|
|
218
|
-
stopLossPrice
|
|
219
|
-
}) => {
|
|
220
|
-
if (stopLossPrice == null || !Number.isFinite(entryPrice) || !Number.isFinite(stopLossPrice)) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
return direction === "LONG" ? stopLossPrice >= entryPrice : stopLossPrice <= entryPrice;
|
|
224
|
-
};
|
|
225
179
|
var getLinePriceAtNow = (line, timestamp) => {
|
|
226
180
|
if (!line || !Array.isArray(line.points) || line.points.length === 0) {
|
|
227
181
|
return null;
|
|
@@ -304,7 +258,6 @@ var createReverseTrendLineCore = async ({ config: config2, data: cachedData, str
|
|
|
304
258
|
const currentPosition = await strategyApi.getCurrentPosition();
|
|
305
259
|
if (isOpenPosition(currentPosition)) {
|
|
306
260
|
const activeLine = currentPosition.direction === "LONG" ? lowsTrendlines[0] : highsTrendlines[0];
|
|
307
|
-
const activeModeConfig = currentPosition.direction === "LONG" ? LOWS : HIGHS;
|
|
308
261
|
const activeLinePrice = getLinePriceAtNow(
|
|
309
262
|
activeLine ?? null,
|
|
310
263
|
candle.timestamp
|
|
@@ -317,30 +270,6 @@ var createReverseTrendLineCore = async ({ config: config2, data: cachedData, str
|
|
|
317
270
|
direction: currentPosition.direction
|
|
318
271
|
});
|
|
319
272
|
}
|
|
320
|
-
const favorableMovePct = getFavorableMovePct({
|
|
321
|
-
direction: currentPosition.direction,
|
|
322
|
-
entryPrice: currentPosition.price,
|
|
323
|
-
currentPrice: candle.close
|
|
324
|
-
});
|
|
325
|
-
const currentStopLossPrice = getPositionStopLossPrice(currentPosition);
|
|
326
|
-
const currentPositionRiskPct = getPositionRiskPct({
|
|
327
|
-
direction: currentPosition.direction,
|
|
328
|
-
entryPrice: currentPosition.price,
|
|
329
|
-
stopLossPrice: currentStopLossPrice
|
|
330
|
-
});
|
|
331
|
-
if (!isBreakEvenStopAlreadyApplied({
|
|
332
|
-
direction: currentPosition.direction,
|
|
333
|
-
entryPrice: currentPosition.price,
|
|
334
|
-
stopLossPrice: currentStopLossPrice
|
|
335
|
-
}) && favorableMovePct != null && favorableMovePct >= (currentPositionRiskPct ?? activeModeConfig.SL) * BREAK_EVEN_TRIGGER_RISK_MULTIPLIER) {
|
|
336
|
-
return strategyApi.protect({
|
|
337
|
-
code: "REVERSE_TRENDLINE_MOVE_STOP_TO_BREAK_EVEN",
|
|
338
|
-
protectPlan: {
|
|
339
|
-
direction: currentPosition.direction,
|
|
340
|
-
stopLossPrice: currentPosition.price
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
273
|
return strategyApi.skip("POSITION_EXISTS");
|
|
345
274
|
}
|
|
346
275
|
if (lastTradeController.isInCooldown(candle.timestamp)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
breakoutManifest
|
|
3
|
-
|
|
2
|
+
breakoutManifest,
|
|
3
|
+
config
|
|
4
|
+
} from "./chunk-37ZWRG3W.mjs";
|
|
4
5
|
import {
|
|
5
6
|
__commonJS,
|
|
6
7
|
__toESM
|
|
@@ -12,9 +13,9 @@ var require_lodash = __commonJS({
|
|
|
12
13
|
"use strict";
|
|
13
14
|
(function() {
|
|
14
15
|
var undefined;
|
|
15
|
-
var VERSION = "4.
|
|
16
|
+
var VERSION = "4.18.1";
|
|
16
17
|
var LARGE_ARRAY_SIZE = 200;
|
|
17
|
-
var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
|
|
18
|
+
var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`", INVALID_TEMPL_IMPORTS_ERROR_TEXT = "Invalid `imports` option passed into `_.template`";
|
|
18
19
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
19
20
|
var MAX_MEMOIZE_SIZE = 500;
|
|
20
21
|
var PLACEHOLDER = "__lodash_placeholder__";
|
|
@@ -1940,8 +1941,21 @@ var require_lodash = __commonJS({
|
|
|
1940
1941
|
}
|
|
1941
1942
|
function baseUnset(object, path) {
|
|
1942
1943
|
path = castPath(path, object);
|
|
1943
|
-
|
|
1944
|
-
|
|
1944
|
+
var index = -1, length = path.length;
|
|
1945
|
+
if (!length) {
|
|
1946
|
+
return true;
|
|
1947
|
+
}
|
|
1948
|
+
while (++index < length) {
|
|
1949
|
+
var key = toKey(path[index]);
|
|
1950
|
+
if (key === "__proto__" && !hasOwnProperty.call(object, "__proto__")) {
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
if ((key === "constructor" || key === "prototype") && index < length - 1) {
|
|
1954
|
+
return false;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
var obj = parent(object, path);
|
|
1958
|
+
return obj == null || delete obj[toKey(last(path))];
|
|
1945
1959
|
}
|
|
1946
1960
|
function baseUpdate(object, path, updater, customizer) {
|
|
1947
1961
|
return baseSet(object, path, updater(baseGet(object, path)), customizer);
|
|
@@ -3268,7 +3282,7 @@ var require_lodash = __commonJS({
|
|
|
3268
3282
|
var index = -1, length = pairs == null ? 0 : pairs.length, result2 = {};
|
|
3269
3283
|
while (++index < length) {
|
|
3270
3284
|
var pair = pairs[index];
|
|
3271
|
-
result2
|
|
3285
|
+
baseAssignValue(result2, pair[0], pair[1]);
|
|
3272
3286
|
}
|
|
3273
3287
|
return result2;
|
|
3274
3288
|
}
|
|
@@ -4652,8 +4666,13 @@ var require_lodash = __commonJS({
|
|
|
4652
4666
|
options = undefined;
|
|
4653
4667
|
}
|
|
4654
4668
|
string = toString(string);
|
|
4655
|
-
options =
|
|
4656
|
-
var imports =
|
|
4669
|
+
options = assignWith({}, options, settings, customDefaultsAssignIn);
|
|
4670
|
+
var imports = assignWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
|
|
4671
|
+
arrayEach(importsKeys, function(key) {
|
|
4672
|
+
if (reForbiddenIdentifierChars.test(key)) {
|
|
4673
|
+
throw new Error(INVALID_TEMPL_IMPORTS_ERROR_TEXT);
|
|
4674
|
+
}
|
|
4675
|
+
});
|
|
4657
4676
|
var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
|
|
4658
4677
|
var reDelimiters = RegExp2(
|
|
4659
4678
|
(options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$",
|
|
@@ -5490,106 +5509,6 @@ var require_lodash = __commonJS({
|
|
|
5490
5509
|
// src/Breakout/strategy.ts
|
|
5491
5510
|
import { createStrategyRuntime } from "@tradejs/node/strategies";
|
|
5492
5511
|
|
|
5493
|
-
// src/Breakout/config.ts
|
|
5494
|
-
var config = {
|
|
5495
|
-
ML_ENABLED: false,
|
|
5496
|
-
MA_FAST: 49,
|
|
5497
|
-
MA_MEDIUM: 49,
|
|
5498
|
-
MA_SLOW: 99,
|
|
5499
|
-
OBV_SMA: 10,
|
|
5500
|
-
ATR: 14,
|
|
5501
|
-
ATR_PCT_SHORT: 7,
|
|
5502
|
-
ATR_PCT_LONG: 30,
|
|
5503
|
-
BB: 20,
|
|
5504
|
-
BB_STD: 2,
|
|
5505
|
-
MACD_FAST: 12,
|
|
5506
|
-
MACD_SLOW: 26,
|
|
5507
|
-
MACD_SIGNAL: 9,
|
|
5508
|
-
LEVEL_LOOKBACK: 20,
|
|
5509
|
-
LEVEL_DELAY: 2,
|
|
5510
|
-
ATR_PERIOD: 14,
|
|
5511
|
-
BB_PERIOD: 20,
|
|
5512
|
-
BB_STDDEV: 2,
|
|
5513
|
-
LIMIT: 100,
|
|
5514
|
-
ATR_OPEN: 0.5,
|
|
5515
|
-
ATR_CLOSE: 1.5,
|
|
5516
|
-
OBV_SMA_PERIOD: 10,
|
|
5517
|
-
BREAKOUT_LOOKBACK_DELAY: 2,
|
|
5518
|
-
BREAKOUT_LOOKBACK: 20,
|
|
5519
|
-
REQUIRED_SCORE_LONG: 7,
|
|
5520
|
-
REQUIRED_SCORE_SHORT: 7,
|
|
5521
|
-
SIGNALS_LONG: {
|
|
5522
|
-
VOLATILE: {
|
|
5523
|
-
weight: 1,
|
|
5524
|
-
required: true
|
|
5525
|
-
},
|
|
5526
|
-
SMA_UPTREND: {
|
|
5527
|
-
weight: 1,
|
|
5528
|
-
required: true
|
|
5529
|
-
},
|
|
5530
|
-
OBV_ABOVE_SMA: {
|
|
5531
|
-
weight: 1,
|
|
5532
|
-
required: true
|
|
5533
|
-
},
|
|
5534
|
-
PREV_HIGH_BREAKOUT: {
|
|
5535
|
-
weight: 1,
|
|
5536
|
-
required: false
|
|
5537
|
-
},
|
|
5538
|
-
CLOSE_ABOVE_UPPER_BB: {
|
|
5539
|
-
weight: 1,
|
|
5540
|
-
required: false
|
|
5541
|
-
},
|
|
5542
|
-
CLOSE_ABOVE_HIGH_LEVEL: {
|
|
5543
|
-
weight: 1,
|
|
5544
|
-
required: false
|
|
5545
|
-
},
|
|
5546
|
-
CLOSE_ABOVE_PREV_CLOSE: {
|
|
5547
|
-
weight: 1,
|
|
5548
|
-
required: false
|
|
5549
|
-
}
|
|
5550
|
-
},
|
|
5551
|
-
SIGNALS_SHORT: {
|
|
5552
|
-
VOLATILE: {
|
|
5553
|
-
weight: 1,
|
|
5554
|
-
required: true
|
|
5555
|
-
},
|
|
5556
|
-
SMA_DOWNTREND: {
|
|
5557
|
-
weight: 1,
|
|
5558
|
-
required: true
|
|
5559
|
-
},
|
|
5560
|
-
OBV_BELOW_SMA: {
|
|
5561
|
-
weight: 1,
|
|
5562
|
-
required: true
|
|
5563
|
-
},
|
|
5564
|
-
PREV_LOW_BREAKDOWN: {
|
|
5565
|
-
weight: 1,
|
|
5566
|
-
required: false
|
|
5567
|
-
},
|
|
5568
|
-
CLOSE_BELOW_LOWER_BB: {
|
|
5569
|
-
weight: 1,
|
|
5570
|
-
required: false
|
|
5571
|
-
},
|
|
5572
|
-
CLOSE_BELOW_LOW_LEVEL: {
|
|
5573
|
-
weight: 1,
|
|
5574
|
-
required: false
|
|
5575
|
-
},
|
|
5576
|
-
CLOSE_BELOW_PREV_CLOSE: {
|
|
5577
|
-
weight: 1,
|
|
5578
|
-
required: false
|
|
5579
|
-
}
|
|
5580
|
-
},
|
|
5581
|
-
TP_LONG: [
|
|
5582
|
-
{ profit: 0.1, rate: 0.25 },
|
|
5583
|
-
{ profit: 0.15, rate: 0.5 }
|
|
5584
|
-
],
|
|
5585
|
-
TP_SHORT: [
|
|
5586
|
-
{ profit: 0.05, rate: 0.25 },
|
|
5587
|
-
{ profit: 0.1, rate: 0.5 }
|
|
5588
|
-
],
|
|
5589
|
-
SL_LONG: 0.06,
|
|
5590
|
-
SL_SHORT: 0.03
|
|
5591
|
-
};
|
|
5592
|
-
|
|
5593
5512
|
// src/Breakout/core.ts
|
|
5594
5513
|
var import_lodash = __toESM(require_lodash());
|
|
5595
5514
|
|