openfund-maker 2.1.9__py3-none-any.whl → 2.1.11__py3-none-any.whl
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.
- maker/BestFVGStrategyMaker.py +41 -34
- maker/SMCStrategyMaker.py +12 -1
- {openfund_maker-2.1.9.dist-info → openfund_maker-2.1.11.dist-info}/METADATA +1 -1
- {openfund_maker-2.1.9.dist-info → openfund_maker-2.1.11.dist-info}/RECORD +6 -6
- {openfund_maker-2.1.9.dist-info → openfund_maker-2.1.11.dist-info}/WHEEL +0 -0
- {openfund_maker-2.1.9.dist-info → openfund_maker-2.1.11.dist-info}/entry_points.txt +0 -0
maker/BestFVGStrategyMaker.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
import traceback
|
3
|
+
from typing import override
|
3
4
|
import pandas as pd
|
4
5
|
|
5
6
|
from maker.SMCStrategyMaker import SMCStrategyMaker
|
@@ -8,7 +9,7 @@ from maker.SMCStrategyMaker import SMCStrategyMaker
|
|
8
9
|
class BestFVGStrategyMaker(SMCStrategyMaker):
|
9
10
|
def __init__(self, config, platform_config, feishu_webhook=None,logger=None):
|
10
11
|
super().__init__(config, platform_config, feishu_webhook, logger)
|
11
|
-
|
12
|
+
|
12
13
|
self.htf_last_CHoCH = {} #记录HTF的CHoCH struct
|
13
14
|
|
14
15
|
def check_price_in_fvg(self, df, side, fvg):
|
@@ -37,6 +38,14 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
37
38
|
max_price = max(df['high'].iloc[fvg_index+2:])
|
38
39
|
return fvg_bot <= max_price
|
39
40
|
|
41
|
+
@override
|
42
|
+
def reset_all_cache(self, symbol):
|
43
|
+
"""
|
44
|
+
重置所有缓存
|
45
|
+
"""
|
46
|
+
super().reset_all_cache(symbol)
|
47
|
+
if symbol in self.htf_last_CHoCH:
|
48
|
+
self.htf_last_CHoCH.pop(symbol)
|
40
49
|
|
41
50
|
def process_pair(self,symbol,pair_config):
|
42
51
|
self.logger.info("=" * 60)
|
@@ -51,11 +60,8 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
51
60
|
try:
|
52
61
|
# 检查是否有持仓,有持仓不进行下单
|
53
62
|
if self.check_position(symbol=symbol) :
|
54
|
-
self.
|
55
|
-
|
56
|
-
self.place_order_prices[symbol] = {}
|
57
|
-
if symbol in self.htf_last_CHoCH:
|
58
|
-
self.htf_last_CHoCH[symbol] = {}
|
63
|
+
self.reset_all_cache(symbol)
|
64
|
+
self.logger.info(f"{symbol} : 有持仓合约,不进行下单。")
|
59
65
|
return
|
60
66
|
|
61
67
|
|
@@ -79,41 +85,42 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
79
85
|
|
80
86
|
|
81
87
|
# 初始化HTF趋势相关变量
|
82
|
-
htf_side, htf_last_CHoCH_label = None, None
|
88
|
+
htf_side, htf_last_CHoCH_label, valid_htf_struct = None, None, None
|
83
89
|
htf_struct = {"struct": "None"}
|
84
|
-
#
|
90
|
+
# 获取上一个周期的CHoCH结构
|
85
91
|
htf_last_CHoCH = self.htf_last_CHoCH.get(symbol,None)
|
86
|
-
|
92
|
+
# 获取最新的CHoCH结构
|
93
|
+
htf_struct = self.detect_struct(htf_df, prd=htf_prd) # HTF结构要严谨,prd周期要长一些
|
87
94
|
|
88
|
-
#
|
89
|
-
if
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
if htf_struct["struct"] == "None":
|
95
|
-
htf_struct = htf_last_CHoCH
|
96
|
-
self.logger.debug(f"{symbol} : {htf} 使用之前 {htf_entry_struct} struct。{htf_struct['struct']} prd={htf_prd}。")
|
95
|
+
# 处理最新结构未形成的情况,使用上一个周期的结构
|
96
|
+
if htf_struct["struct"] == "None":
|
97
|
+
if htf_last_CHoCH:
|
98
|
+
htf_last_CHoCH_label = htf_last_CHoCH["struct"]
|
99
|
+
valid_htf_struct = htf_last_CHoCH
|
100
|
+
self.logger.debug(f"{symbol} : {htf} 使用之前 {htf_entry_struct} struct。{valid_htf_struct['struct']} prd={htf_prd}。")
|
97
101
|
else:
|
98
|
-
self.logger.debug(f"{symbol} : {htf}
|
102
|
+
self.logger.debug(f"{symbol} : {htf} 未形成有效的 {htf_entry_struct} struct,不下单。")
|
103
|
+
return
|
104
|
+
else:
|
105
|
+
valid_htf_struct = htf_struct
|
106
|
+
self.logger.debug(f"{symbol} : {htf} 形成新的 {htf_entry_struct} struct。{valid_htf_struct['struct']} prd={htf_prd}。")
|
99
107
|
|
100
|
-
#
|
101
|
-
htf_struct_label =
|
102
|
-
htf_side =
|
103
|
-
if htf_struct_label == "None" and not htf_last_CHoCH:
|
104
|
-
|
108
|
+
# 检查是否已形成有效的结构
|
109
|
+
htf_struct_label = valid_htf_struct["struct"]
|
110
|
+
htf_side = valid_htf_struct["side"]
|
111
|
+
# if htf_struct_label == "None" and not htf_last_CHoCH:
|
112
|
+
# 20250417 优化: 最新的HTF_entry_struct结构要满足,才能下单。
|
113
|
+
if htf_entry_struct not in htf_struct_label :
|
114
|
+
# 如果是反转结构判断一下方向是否一致,不一致重置缓存。
|
115
|
+
if "CHoCH" in htf_struct_label and htf_last_CHoCH["side"] != htf_side:
|
116
|
+
self.htf_last_CHoCH[symbol] = {}
|
117
|
+
self.logger.debug(f"{symbol} : {htf} is {htf_struct_label}, 未形成有效的 {htf_entry_struct} struct,不下单。")
|
105
118
|
return
|
106
|
-
|
107
|
-
# 更新最新的结构信息
|
108
|
-
if ltf_entry_struct in htf_struct_label and htf_struct_label != htf_last_CHoCH_label:
|
109
|
-
self.htf_last_CHoCH[symbol] = htf_struct
|
110
|
-
htf_last_CHoCH = htf_struct
|
111
|
-
htf_last_CHoCH_label = htf_struct_label
|
112
119
|
|
113
120
|
|
114
121
|
# 1. HTF 判断struct趋势(CHoCH\SMS\BMS) ,HTF struct 看趋势,CTF 看FVG和OB的位置
|
115
|
-
htf_pivot_high =
|
116
|
-
htf_pivot_low =
|
122
|
+
htf_pivot_high = valid_htf_struct["pivot_high"]
|
123
|
+
htf_pivot_low = valid_htf_struct["pivot_low"]
|
117
124
|
htf_mid_line = self.calculate_ce(symbol,htf_pivot_high,htf_pivot_low)
|
118
125
|
|
119
126
|
# 2. HTF 获取最新的两个极值点,设置折价(discount)区和溢价(premium)区
|
@@ -129,11 +136,11 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
129
136
|
'ce': self.calculate_ce(symbol,htf_mid_line,htf_pivot_low)
|
130
137
|
}
|
131
138
|
|
132
|
-
self.logger.info(f"{symbol} : {htf} 趋势={htf_last_CHoCH_label}")
|
139
|
+
self.logger.info(f"{symbol} : {htf} 趋势={htf_last_CHoCH_label} 匹配 {htf_entry_struct} struct")
|
133
140
|
self.logger.debug(f"{symbol} : {htf}\npivot_high={htf_pivot_high} pivot_low={htf_pivot_low} mid_line={htf_mid_line}\n溢价区={premium_box}\n折价区={discount_box}")
|
134
141
|
|
135
142
|
# 3. find HTF FVG
|
136
|
-
pivot_index =
|
143
|
+
pivot_index = valid_htf_struct["pivot_low_index"] if htf_side == "buy" else valid_htf_struct["pivot_high_index"]
|
137
144
|
# TODO 优化: 缓存FVG,不用每次都计算,且被平衡
|
138
145
|
htf_fvg_boxes = self.find_fvg_boxes(htf_df,side=htf_side,threshold=htf_mid_line,check_balanced=False,pivot_index=pivot_index)
|
139
146
|
if len(htf_fvg_boxes) == 0:
|
maker/SMCStrategyMaker.py
CHANGED
@@ -516,6 +516,16 @@ class SMCStrategyMaker(ThreeLineStrategyMaker):
|
|
516
516
|
ce = (pivot_high + pivot_low) / 2
|
517
517
|
return float(self.round_price(symbol, ce))
|
518
518
|
|
519
|
+
def calculate_pe(self,symbol,pivot_high, pivot_low) -> float:
|
520
|
+
pe = (pivot_high + pivot_low) / 2
|
521
|
+
return float(self.round_price(symbol, pe))
|
522
|
+
|
523
|
+
def reset_all_cache(self, symbol):
|
524
|
+
"""_summary_
|
525
|
+
重置所有缓存数据
|
526
|
+
"""
|
527
|
+
if symbol in self.place_order_prices:
|
528
|
+
self.place_order_prices.pop(symbol)
|
519
529
|
|
520
530
|
def process_pair(self,symbol,pair_config):
|
521
531
|
self.logger.info("=" * 60)
|
@@ -531,7 +541,8 @@ class SMCStrategyMaker(ThreeLineStrategyMaker):
|
|
531
541
|
if self.check_position(symbol=symbol) :
|
532
542
|
self.logger.info(f"{symbol} : 有持仓合约,不进行下单。")
|
533
543
|
if symbol in self.place_order_prices:
|
534
|
-
self.
|
544
|
+
self.reset_all_cache(symbol)
|
545
|
+
|
535
546
|
return
|
536
547
|
|
537
548
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
maker/BestFVGStrategyMaker.py,sha256=
|
1
|
+
maker/BestFVGStrategyMaker.py,sha256=eQrBB8qCf3ErweYhcQI_eaa3smPw3lQ5J8pQYgHd9Go,11682
|
2
2
|
maker/MACDStrategyMaker.py,sha256=iS5HO04piKHFJxUI2e5QmicxzGeK-V1aphJSr2n_4Ac,12651
|
3
|
-
maker/SMCStrategyMaker.py,sha256=
|
3
|
+
maker/SMCStrategyMaker.py,sha256=ThXxa-mfbxNavqok86fUg-HstMdVrBVS75TeCJCt2Ck,35087
|
4
4
|
maker/ThreeLineStrategyMaker.py,sha256=ArjnHlGECiD3cCFXxO0Ex5scR2agwoxZY-4mKukyKc4,30402
|
5
5
|
maker/WickReversalStrategyMaker.py,sha256=7DqPDVJot4EM0_lSAcFAHrR9rNvkIds9KLMoDOiAHEc,17486
|
6
6
|
maker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -10,7 +10,7 @@ maker/main_m.py,sha256=0PzDTnuBrxfpy5WDfsIHKAzZ_7pkuvuqqeWik0vpWio,15522
|
|
10
10
|
maker/okxapi.py,sha256=_9G0U_o0ZC8NxaT6PqpiLgxBm9gPobC9PsFHZE1c5w0,553
|
11
11
|
maker/zhen.py.bak,sha256=HNkrQbJts8G9umE9chEFsc0cLQApcM9KOVNMYPpkBXM,10918
|
12
12
|
maker/zhen_2.py,sha256=4IaHVtTCMSlrLGSTZrWpW2q-f7HZsUNRkW_-5QgWv24,10509
|
13
|
-
openfund_maker-2.1.
|
14
|
-
openfund_maker-2.1.
|
15
|
-
openfund_maker-2.1.
|
16
|
-
openfund_maker-2.1.
|
13
|
+
openfund_maker-2.1.11.dist-info/METADATA,sha256=Gtv2JpXBjB9wokm71fY3ltGqXBo1EE7tIwbl0K2o6ik,1954
|
14
|
+
openfund_maker-2.1.11.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
15
|
+
openfund_maker-2.1.11.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
|
16
|
+
openfund_maker-2.1.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|