@tradejs/strategy-head-and-shoulders 3.0.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/LICENSE +96 -0
- package/README.md +34 -0
- package/dist/index.cjs +1074 -0
- package/dist/index.d.cts +103 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +1050 -0
- package/package.json +65 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { StrategyConfig, Interval, BacktestPriceMode, Direction, StrategyRegistryEntry, StrategyManifest, StrategyAiAdapter } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
interface HeadAndShouldersSideConfig {
|
|
4
|
+
enable: boolean;
|
|
5
|
+
direction: Direction;
|
|
6
|
+
minRiskRatio: number;
|
|
7
|
+
}
|
|
8
|
+
type HeadAndShouldersEntryMode = "breakout" | "close_acceptance" | "retest";
|
|
9
|
+
declare const config: {
|
|
10
|
+
readonly ENV: "BACKTEST";
|
|
11
|
+
readonly INTERVAL: Interval;
|
|
12
|
+
readonly MAKE_ORDERS: true;
|
|
13
|
+
readonly CLOSE_OPPOSITE_POSITIONS: false;
|
|
14
|
+
readonly BACKTEST_PRICE_MODE: "open";
|
|
15
|
+
readonly AI_ENABLED: false;
|
|
16
|
+
readonly AI_MODE: "llm";
|
|
17
|
+
readonly ML_ENABLED: false;
|
|
18
|
+
readonly ML_THRESHOLD: 0.1;
|
|
19
|
+
readonly MIN_AI_QUALITY: 4;
|
|
20
|
+
readonly FEE_PERCENT: 0.001;
|
|
21
|
+
readonly MAX_LOSS_VALUE: 10;
|
|
22
|
+
readonly MA_FAST: 14;
|
|
23
|
+
readonly MA_MEDIUM: 49;
|
|
24
|
+
readonly MA_SLOW: 50;
|
|
25
|
+
readonly OBV_SMA: 10;
|
|
26
|
+
readonly ATR: 14;
|
|
27
|
+
readonly ATR_PCT_SHORT: 7;
|
|
28
|
+
readonly ATR_PCT_LONG: 30;
|
|
29
|
+
readonly BB: 20;
|
|
30
|
+
readonly BB_STD: 2;
|
|
31
|
+
readonly MACD_FAST: 12;
|
|
32
|
+
readonly MACD_SLOW: 26;
|
|
33
|
+
readonly MACD_SIGNAL: 9;
|
|
34
|
+
readonly HEADSHOULDERS_PIVOT_LOOKBACK: 3;
|
|
35
|
+
readonly HEADSHOULDERS_SHOULDER_TOLERANCE_PCT: 15;
|
|
36
|
+
readonly HEADSHOULDERS_MIN_HEAD_PROMINENCE_RATIO: 0.2;
|
|
37
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT: 100;
|
|
38
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT_LONG: 120;
|
|
39
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT_SHORT: 100;
|
|
40
|
+
readonly HEADSHOULDERS_STOP_BUFFER_HEIGHT_PCT: 5;
|
|
41
|
+
readonly HEADSHOULDERS_MIN_HEAD_HEIGHT_PCT: 0.8;
|
|
42
|
+
readonly HEADSHOULDERS_MIN_HEAD_HEIGHT_ATR: 2.5;
|
|
43
|
+
readonly HEADSHOULDERS_ATR_PERIOD: 14;
|
|
44
|
+
readonly HEADSHOULDERS_MIN_PATTERN_BARS: 8;
|
|
45
|
+
readonly HEADSHOULDERS_MAX_PATTERN_BARS: 180;
|
|
46
|
+
readonly HEADSHOULDERS_MIN_PATTERN_SYMMETRY_RATIO: 0.45;
|
|
47
|
+
readonly HEADSHOULDERS_MAX_NECKLINE_SLOPE_RATIO: 0.2;
|
|
48
|
+
readonly HEADSHOULDERS_MAX_PATTERN_AGE_BARS: 220;
|
|
49
|
+
readonly HEADSHOULDERS_PRIOR_TREND_LOOKBACK: 80;
|
|
50
|
+
readonly HEADSHOULDERS_MAX_PRIOR_MOVE_ATR: 3;
|
|
51
|
+
readonly HEADSHOULDERS_MIN_BREAKOUT_DISTANCE_ATR: 0.2;
|
|
52
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DISTANCE_HEIGHT_RATIO: 0.35;
|
|
53
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DISTANCE_PCT: 0.8;
|
|
54
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DELAY_BARS: 8;
|
|
55
|
+
readonly HEADSHOULDERS_REQUIRE_BREAKOUT_CROSS: false;
|
|
56
|
+
readonly HEADSHOULDERS_ENTRY_MODE: HeadAndShouldersEntryMode;
|
|
57
|
+
readonly HEADSHOULDERS_CONFIRMATION_MAX_BARS: 2;
|
|
58
|
+
readonly HEADSHOULDERS_MIN_CONFIRMATION_BODY_ATR: 0;
|
|
59
|
+
readonly HEADSHOULDERS_MAX_CONFIRMATION_CLOSE_LOCATION: 1;
|
|
60
|
+
readonly HEADSHOULDERS_CONFIRMATION_VOLUME_PERIOD: 20;
|
|
61
|
+
readonly HEADSHOULDERS_MIN_CONFIRMATION_VOLUME_REL: 0.8;
|
|
62
|
+
readonly HEADSHOULDERS_RETEST_MAX_BARS: 4;
|
|
63
|
+
readonly HEADSHOULDERS_RETEST_TOLERANCE_ATR: 0.25;
|
|
64
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH: 0;
|
|
65
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH_LONG: 0.5;
|
|
66
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH_SHORT: 0;
|
|
67
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR: 0;
|
|
68
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR_LONG: 4;
|
|
69
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR_SHORT: 0;
|
|
70
|
+
readonly HEADSHOULDERS_EXIT_ON_OPPOSITE_PATTERN: false;
|
|
71
|
+
readonly LONG: {
|
|
72
|
+
readonly enable: false;
|
|
73
|
+
readonly direction: "LONG";
|
|
74
|
+
readonly minRiskRatio: 0.7;
|
|
75
|
+
};
|
|
76
|
+
readonly SHORT: {
|
|
77
|
+
readonly enable: true;
|
|
78
|
+
readonly direction: "SHORT";
|
|
79
|
+
readonly minRiskRatio: 0.7;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
type HeadAndShouldersConfig = StrategyConfig & Omit<typeof config, "BACKTEST_PRICE_MODE" | "LONG" | "SHORT" | "MIN_AI_QUALITY"> & {
|
|
83
|
+
BACKTEST_PRICE_MODE: BacktestPriceMode;
|
|
84
|
+
MIN_AI_QUALITY: number;
|
|
85
|
+
HEADSHOULDERS_ENTRY_MODE: HeadAndShouldersEntryMode;
|
|
86
|
+
LONG: HeadAndShouldersSideConfig;
|
|
87
|
+
SHORT: HeadAndShouldersSideConfig;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare const HeadAndShouldersStrategyDefinition: StrategyRegistryEntry<HeadAndShouldersConfig>;
|
|
91
|
+
|
|
92
|
+
declare const headAndShouldersManifest: StrategyManifest;
|
|
93
|
+
|
|
94
|
+
declare const headAndShouldersAiAdapter: StrategyAiAdapter;
|
|
95
|
+
|
|
96
|
+
declare const strategyEntries: StrategyRegistryEntry[];
|
|
97
|
+
declare const getBuiltInStrategyDefaultConfig: (strategyName: string) => StrategyConfig | undefined;
|
|
98
|
+
|
|
99
|
+
declare const _default: {
|
|
100
|
+
strategyEntries: StrategyRegistryEntry<any>[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { HeadAndShouldersStrategyDefinition, _default as default, getBuiltInStrategyDefaultConfig, headAndShouldersAiAdapter, config as headAndShouldersDefaultConfig, headAndShouldersManifest, strategyEntries };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { StrategyConfig, Interval, BacktestPriceMode, Direction, StrategyRegistryEntry, StrategyManifest, StrategyAiAdapter } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
interface HeadAndShouldersSideConfig {
|
|
4
|
+
enable: boolean;
|
|
5
|
+
direction: Direction;
|
|
6
|
+
minRiskRatio: number;
|
|
7
|
+
}
|
|
8
|
+
type HeadAndShouldersEntryMode = "breakout" | "close_acceptance" | "retest";
|
|
9
|
+
declare const config: {
|
|
10
|
+
readonly ENV: "BACKTEST";
|
|
11
|
+
readonly INTERVAL: Interval;
|
|
12
|
+
readonly MAKE_ORDERS: true;
|
|
13
|
+
readonly CLOSE_OPPOSITE_POSITIONS: false;
|
|
14
|
+
readonly BACKTEST_PRICE_MODE: "open";
|
|
15
|
+
readonly AI_ENABLED: false;
|
|
16
|
+
readonly AI_MODE: "llm";
|
|
17
|
+
readonly ML_ENABLED: false;
|
|
18
|
+
readonly ML_THRESHOLD: 0.1;
|
|
19
|
+
readonly MIN_AI_QUALITY: 4;
|
|
20
|
+
readonly FEE_PERCENT: 0.001;
|
|
21
|
+
readonly MAX_LOSS_VALUE: 10;
|
|
22
|
+
readonly MA_FAST: 14;
|
|
23
|
+
readonly MA_MEDIUM: 49;
|
|
24
|
+
readonly MA_SLOW: 50;
|
|
25
|
+
readonly OBV_SMA: 10;
|
|
26
|
+
readonly ATR: 14;
|
|
27
|
+
readonly ATR_PCT_SHORT: 7;
|
|
28
|
+
readonly ATR_PCT_LONG: 30;
|
|
29
|
+
readonly BB: 20;
|
|
30
|
+
readonly BB_STD: 2;
|
|
31
|
+
readonly MACD_FAST: 12;
|
|
32
|
+
readonly MACD_SLOW: 26;
|
|
33
|
+
readonly MACD_SIGNAL: 9;
|
|
34
|
+
readonly HEADSHOULDERS_PIVOT_LOOKBACK: 3;
|
|
35
|
+
readonly HEADSHOULDERS_SHOULDER_TOLERANCE_PCT: 15;
|
|
36
|
+
readonly HEADSHOULDERS_MIN_HEAD_PROMINENCE_RATIO: 0.2;
|
|
37
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT: 100;
|
|
38
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT_LONG: 120;
|
|
39
|
+
readonly HEADSHOULDERS_TARGET_HEIGHT_PCT_SHORT: 100;
|
|
40
|
+
readonly HEADSHOULDERS_STOP_BUFFER_HEIGHT_PCT: 5;
|
|
41
|
+
readonly HEADSHOULDERS_MIN_HEAD_HEIGHT_PCT: 0.8;
|
|
42
|
+
readonly HEADSHOULDERS_MIN_HEAD_HEIGHT_ATR: 2.5;
|
|
43
|
+
readonly HEADSHOULDERS_ATR_PERIOD: 14;
|
|
44
|
+
readonly HEADSHOULDERS_MIN_PATTERN_BARS: 8;
|
|
45
|
+
readonly HEADSHOULDERS_MAX_PATTERN_BARS: 180;
|
|
46
|
+
readonly HEADSHOULDERS_MIN_PATTERN_SYMMETRY_RATIO: 0.45;
|
|
47
|
+
readonly HEADSHOULDERS_MAX_NECKLINE_SLOPE_RATIO: 0.2;
|
|
48
|
+
readonly HEADSHOULDERS_MAX_PATTERN_AGE_BARS: 220;
|
|
49
|
+
readonly HEADSHOULDERS_PRIOR_TREND_LOOKBACK: 80;
|
|
50
|
+
readonly HEADSHOULDERS_MAX_PRIOR_MOVE_ATR: 3;
|
|
51
|
+
readonly HEADSHOULDERS_MIN_BREAKOUT_DISTANCE_ATR: 0.2;
|
|
52
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DISTANCE_HEIGHT_RATIO: 0.35;
|
|
53
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DISTANCE_PCT: 0.8;
|
|
54
|
+
readonly HEADSHOULDERS_MAX_BREAKOUT_DELAY_BARS: 8;
|
|
55
|
+
readonly HEADSHOULDERS_REQUIRE_BREAKOUT_CROSS: false;
|
|
56
|
+
readonly HEADSHOULDERS_ENTRY_MODE: HeadAndShouldersEntryMode;
|
|
57
|
+
readonly HEADSHOULDERS_CONFIRMATION_MAX_BARS: 2;
|
|
58
|
+
readonly HEADSHOULDERS_MIN_CONFIRMATION_BODY_ATR: 0;
|
|
59
|
+
readonly HEADSHOULDERS_MAX_CONFIRMATION_CLOSE_LOCATION: 1;
|
|
60
|
+
readonly HEADSHOULDERS_CONFIRMATION_VOLUME_PERIOD: 20;
|
|
61
|
+
readonly HEADSHOULDERS_MIN_CONFIRMATION_VOLUME_REL: 0.8;
|
|
62
|
+
readonly HEADSHOULDERS_RETEST_MAX_BARS: 4;
|
|
63
|
+
readonly HEADSHOULDERS_RETEST_TOLERANCE_ATR: 0.25;
|
|
64
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH: 0;
|
|
65
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH_LONG: 0.5;
|
|
66
|
+
readonly HEADSHOULDERS_MIN_SIGNAL_BODY_STRENGTH_SHORT: 0;
|
|
67
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR: 0;
|
|
68
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR_LONG: 4;
|
|
69
|
+
readonly HEADSHOULDERS_MIN_ENTRY_HEAD_HEIGHT_ATR_SHORT: 0;
|
|
70
|
+
readonly HEADSHOULDERS_EXIT_ON_OPPOSITE_PATTERN: false;
|
|
71
|
+
readonly LONG: {
|
|
72
|
+
readonly enable: false;
|
|
73
|
+
readonly direction: "LONG";
|
|
74
|
+
readonly minRiskRatio: 0.7;
|
|
75
|
+
};
|
|
76
|
+
readonly SHORT: {
|
|
77
|
+
readonly enable: true;
|
|
78
|
+
readonly direction: "SHORT";
|
|
79
|
+
readonly minRiskRatio: 0.7;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
type HeadAndShouldersConfig = StrategyConfig & Omit<typeof config, "BACKTEST_PRICE_MODE" | "LONG" | "SHORT" | "MIN_AI_QUALITY"> & {
|
|
83
|
+
BACKTEST_PRICE_MODE: BacktestPriceMode;
|
|
84
|
+
MIN_AI_QUALITY: number;
|
|
85
|
+
HEADSHOULDERS_ENTRY_MODE: HeadAndShouldersEntryMode;
|
|
86
|
+
LONG: HeadAndShouldersSideConfig;
|
|
87
|
+
SHORT: HeadAndShouldersSideConfig;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare const HeadAndShouldersStrategyDefinition: StrategyRegistryEntry<HeadAndShouldersConfig>;
|
|
91
|
+
|
|
92
|
+
declare const headAndShouldersManifest: StrategyManifest;
|
|
93
|
+
|
|
94
|
+
declare const headAndShouldersAiAdapter: StrategyAiAdapter;
|
|
95
|
+
|
|
96
|
+
declare const strategyEntries: StrategyRegistryEntry[];
|
|
97
|
+
declare const getBuiltInStrategyDefaultConfig: (strategyName: string) => StrategyConfig | undefined;
|
|
98
|
+
|
|
99
|
+
declare const _default: {
|
|
100
|
+
strategyEntries: StrategyRegistryEntry<any>[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { HeadAndShouldersStrategyDefinition, _default as default, getBuiltInStrategyDefaultConfig, headAndShouldersAiAdapter, config as headAndShouldersDefaultConfig, headAndShouldersManifest, strategyEntries };
|