openfund-maker 2.1.15__py3-none-any.whl → 2.2.2__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 +21 -13
- maker/SMCStrategyMaker.py +3 -3
- maker/ThreeLineStrategyMaker.py +1 -1
- maker/main.py +3 -1
- {openfund_maker-2.1.15.dist-info → openfund_maker-2.2.2.dist-info}/METADATA +2 -2
- openfund_maker-2.2.2.dist-info/RECORD +16 -0
- openfund_maker-2.1.15.dist-info/RECORD +0 -16
- {openfund_maker-2.1.15.dist-info → openfund_maker-2.2.2.dist-info}/WHEEL +0 -0
- {openfund_maker-2.1.15.dist-info → openfund_maker-2.2.2.dist-info}/entry_points.txt +0 -0
maker/BestFVGStrategyMaker.py
CHANGED
@@ -12,30 +12,36 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
12
12
|
|
13
13
|
self.htf_last_CHoCH = {} #记录HTF的CHoCH struct
|
14
14
|
|
15
|
-
def check_price_in_fvg(self, df, side, fvg):
|
15
|
+
def check_price_in_fvg(self, df, side, fvg, struct_index=None):
|
16
16
|
"""
|
17
17
|
检查最大或最小价格是否在FVG范围内
|
18
18
|
Args:
|
19
|
+
df: DataFrame, 包含价格数据的DataFrame
|
19
20
|
side: str, 方向 'buy' or 'sell'
|
20
21
|
fvg: Dic, FVG
|
22
|
+
struct_index: int, 从哪个index开始检查,默认None
|
21
23
|
Returns:
|
22
24
|
bool: 是否在FVG范围内
|
23
25
|
"""
|
24
26
|
if fvg is None:
|
25
27
|
return False
|
28
|
+
|
29
|
+
data = df.copy()
|
30
|
+
if struct_index is not None:
|
31
|
+
data = data.iloc[struct_index:]
|
26
32
|
|
27
33
|
fvg_top = fvg["top"]
|
28
34
|
fvg_bot = fvg["bot"]
|
29
35
|
fvg_index = fvg["index"]
|
30
36
|
|
31
|
-
# 检查价格是否在FVG范围内,bar_index
|
37
|
+
# 检查价格是否在FVG范围内,bar_index 从struct_index
|
32
38
|
if side == 'buy':
|
33
39
|
# 多头趋势检查最低价是否进入FVG区域
|
34
|
-
min_price = min(
|
40
|
+
min_price = min(data['low'])
|
35
41
|
return min_price <= fvg_top
|
36
42
|
else:
|
37
43
|
# 空头趋势检查最高价是否进入FVG区域
|
38
|
-
max_price = max(
|
44
|
+
max_price = max(data['high'])
|
39
45
|
return fvg_bot <= max_price
|
40
46
|
|
41
47
|
@override
|
@@ -85,7 +91,7 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
85
91
|
|
86
92
|
|
87
93
|
# 初始化HTF趋势相关变量
|
88
|
-
htf_side,
|
94
|
+
htf_side, valid_htf_struct = None, None
|
89
95
|
htf_struct = {"struct": "None"}
|
90
96
|
# 获取上一个周期的CHoCH结构
|
91
97
|
htf_last_CHoCH = self.htf_last_CHoCH.get(symbol,None)
|
@@ -95,7 +101,7 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
95
101
|
# 处理最新结构未形成的情况,使用上一个周期的结构
|
96
102
|
if htf_struct["struct"] == "None":
|
97
103
|
if htf_last_CHoCH:
|
98
|
-
|
104
|
+
|
99
105
|
valid_htf_struct = htf_last_CHoCH
|
100
106
|
self.logger.debug(f"{symbol} : {htf} 使用之前 {htf_entry_struct} struct。{valid_htf_struct['struct']} prd={htf_prd}。")
|
101
107
|
else:
|
@@ -108,12 +114,13 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
108
114
|
# 检查是否已形成有效的结构
|
109
115
|
htf_struct_label = valid_htf_struct["struct"]
|
110
116
|
htf_side = valid_htf_struct["side"]
|
111
|
-
|
117
|
+
|
112
118
|
# 20250417 优化: 最新的HTF_entry_struct结构要满足,才能下单。
|
113
119
|
if htf_entry_struct not in htf_struct_label :
|
114
120
|
# 如果是反转结构判断一下方向是否一致,不一致重置缓存。
|
115
121
|
if "CHoCH" in htf_struct_label and htf_last_CHoCH and htf_last_CHoCH["side"] != htf_side:
|
116
122
|
self.htf_last_CHoCH[symbol] = {}
|
123
|
+
|
117
124
|
self.logger.debug(f"{symbol} : {htf} is {htf_struct_label}, 未形成有效的 {htf_entry_struct} struct,不下单。")
|
118
125
|
return
|
119
126
|
|
@@ -136,10 +143,11 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
136
143
|
'ce': self.calculate_ce(symbol,htf_mid_line,htf_pivot_low)
|
137
144
|
}
|
138
145
|
|
139
|
-
self.logger.info(f"{symbol} : {htf} 趋势={
|
146
|
+
self.logger.info(f"{symbol} : {htf} 趋势={htf_struct_label} 匹配 {htf_entry_struct} struct")
|
140
147
|
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}")
|
141
148
|
|
142
|
-
# 3. find HTF FVG
|
149
|
+
# 3. find HTF FVG
|
150
|
+
|
143
151
|
pivot_index = valid_htf_struct["pivot_low_index"] if htf_side == "buy" else valid_htf_struct["pivot_high_index"]
|
144
152
|
# TODO 优化: 缓存FVG,不用每次都计算,且被平衡
|
145
153
|
htf_fvg_boxes = self.find_fvg_boxes(htf_df,side=htf_side,threshold=htf_mid_line,check_balanced=False,pivot_index=pivot_index)
|
@@ -148,8 +156,8 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
148
156
|
return
|
149
157
|
self.logger.debug(f"{symbol} : HTF_fvg_box={htf_fvg_boxes[-1]}")
|
150
158
|
|
151
|
-
# 判断是否进入最近的FVG
|
152
|
-
if_tap_into_fvg = self.check_price_in_fvg(htf_df,htf_side,htf_fvg_boxes[-1])
|
159
|
+
# 判断是否进入最近的FVG
|
160
|
+
if_tap_into_fvg = self.check_price_in_fvg(htf_df,htf_side,htf_fvg_boxes[-1],valid_htf_struct["index"])
|
153
161
|
if not if_tap_into_fvg:
|
154
162
|
self.logger.debug(f"{symbol} : 价格[未进入] HTF_FVG区域,不进行下单")
|
155
163
|
return
|
@@ -186,9 +194,9 @@ class BestFVGStrategyMaker(SMCStrategyMaker):
|
|
186
194
|
|
187
195
|
|
188
196
|
# 5. LTF 寻找FVG,下单
|
189
|
-
|
197
|
+
|
190
198
|
if ltf_struct_label == "None" or htf_side != ltf_struct_side :
|
191
|
-
self.logger.debug(f"{symbol} : {htf} {
|
199
|
+
self.logger.debug(f"{symbol} : {htf} {htf_struct_label} VS {ltf} {ltf_struct_label} 趋势不一致{htf_side}|{ltf_struct_side},不进行下单")
|
192
200
|
return
|
193
201
|
|
194
202
|
threshold = 0.0
|
maker/SMCStrategyMaker.py
CHANGED
@@ -507,7 +507,7 @@ class SMCStrategyMaker(ThreeLineStrategyMaker):
|
|
507
507
|
current_low = data.at[index, 'low']
|
508
508
|
prev_lows = data['low'].iloc[max(0,index - period):index]
|
509
509
|
next_lows = data['low'].iloc[index+1 :min(len(data),index + period)+1]
|
510
|
-
return all(current_low <= prev_lows) and all(current_low
|
510
|
+
return all(current_low <= prev_lows) and all(current_low < next_lows)
|
511
511
|
|
512
512
|
def round_price(self,symbol, price):
|
513
513
|
tick_size = self.get_tick_size(symbol)
|
@@ -529,7 +529,7 @@ class SMCStrategyMaker(ThreeLineStrategyMaker):
|
|
529
529
|
self.place_order_prices.pop(symbol)
|
530
530
|
|
531
531
|
def process_pair(self,symbol,pair_config):
|
532
|
-
self.logger.info("
|
532
|
+
self.logger.info("-" * 60)
|
533
533
|
"""_summary_
|
534
534
|
1. HTF 判断struct趋势(SMS和BMS)
|
535
535
|
2. HTF 获取最新的两个极值点,设置折价区和溢价区
|
@@ -741,6 +741,6 @@ class SMCStrategyMaker(ThreeLineStrategyMaker):
|
|
741
741
|
traceback.print_exc()
|
742
742
|
self.send_feishu_notification(error_message)
|
743
743
|
finally:
|
744
|
-
self.logger.info("
|
744
|
+
self.logger.info("=" * 60)
|
745
745
|
|
746
746
|
|
maker/ThreeLineStrategyMaker.py
CHANGED
@@ -29,7 +29,7 @@ class ThreeLineStrategyMaker:
|
|
29
29
|
'timeout': 3000,
|
30
30
|
'rateLimit': 50,
|
31
31
|
'options': {'defaultType': 'future'},
|
32
|
-
'proxies': {'http': 'http://127.0.0.1:7890', 'https': 'http://127.0.0.1:7890'},
|
32
|
+
# 'proxies': {'http': 'http://127.0.0.1:7890', 'https': 'http://127.0.0.1:7890'},
|
33
33
|
})
|
34
34
|
|
35
35
|
|
maker/main.py
CHANGED
@@ -4,6 +4,7 @@ from logging.handlers import TimedRotatingFileHandler
|
|
4
4
|
from apscheduler.triggers.interval import IntervalTrigger
|
5
5
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
6
6
|
from datetime import datetime
|
7
|
+
from pyfiglet import Figlet
|
7
8
|
|
8
9
|
from maker.WickReversalStrategyMaker import WickReversalStrategyMaker
|
9
10
|
from maker.ThreeLineStrategyMaker import ThreeLineStrategyMaker
|
@@ -78,7 +79,8 @@ def main():
|
|
78
79
|
|
79
80
|
# 设置每5分钟执行一次的任务,从整点开始
|
80
81
|
monitor_interval = int(schedule_config.get('monitor_interval', 4))
|
81
|
-
|
82
|
+
f = Figlet(font="standard") # 字体可选(如 "block", "bubble")
|
83
|
+
logger.info(f"\n{f.renderText("OpenFund Maker")}")
|
82
84
|
# 计算下一个整点分钟
|
83
85
|
now = datetime.now()
|
84
86
|
# 将当前时间的秒和微秒设置为0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: openfund-maker
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.2.2
|
4
4
|
Summary: Openfund-maker.
|
5
5
|
Requires-Python: >=3.9,<4.0
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
@@ -9,10 +9,10 @@ Classifier: Programming Language :: Python :: 3.10
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
11
11
|
Classifier: Programming Language :: Python :: 3.13
|
12
|
-
Requires-Dist: TA-Lib (>=0.5.1,<0.6.0)
|
13
12
|
Requires-Dist: apscheduler (>=3.11.0,<4.0.0)
|
14
13
|
Requires-Dist: ccxt (>=4.4.26,<5.0.0)
|
15
14
|
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
15
|
+
Requires-Dist: pyfiglet (>=1.0.2,<2.0.0)
|
16
16
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
17
17
|
Description-Content-Type: text/markdown
|
18
18
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
maker/BestFVGStrategyMaker.py,sha256=Mis9Tgn2ERtMG4uM8ppeshg8pHTnFN6pFs5b5vGJQfE,11798
|
2
|
+
maker/MACDStrategyMaker.py,sha256=iS5HO04piKHFJxUI2e5QmicxzGeK-V1aphJSr2n_4Ac,12651
|
3
|
+
maker/SMCStrategyMaker.py,sha256=16AEM_SKZ48xhESYeK_lhPrgsH6WW-MuEFhNC187peI,35226
|
4
|
+
maker/ThreeLineStrategyMaker.py,sha256=cKPSztTUVkumVTwSotvZBGs1iLrKrsXnwFJ73bx6fhQ,30404
|
5
|
+
maker/WickReversalStrategyMaker.py,sha256=7DqPDVJot4EM0_lSAcFAHrR9rNvkIds9KLMoDOiAHEc,17486
|
6
|
+
maker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
maker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
|
8
|
+
maker/main.py,sha256=0c_0DJEmfFSxXR1tBrfC0m_9eLmHuqRTec21G6GtXjM,4562
|
9
|
+
maker/main_m.py,sha256=0PzDTnuBrxfpy5WDfsIHKAzZ_7pkuvuqqeWik0vpWio,15522
|
10
|
+
maker/okxapi.py,sha256=_9G0U_o0ZC8NxaT6PqpiLgxBm9gPobC9PsFHZE1c5w0,553
|
11
|
+
maker/zhen.py.bak,sha256=HNkrQbJts8G9umE9chEFsc0cLQApcM9KOVNMYPpkBXM,10918
|
12
|
+
maker/zhen_2.py,sha256=4IaHVtTCMSlrLGSTZrWpW2q-f7HZsUNRkW_-5QgWv24,10509
|
13
|
+
openfund_maker-2.2.2.dist-info/METADATA,sha256=HmZm5VUqjCzKEklNS7sZKnDSPB8D7KNOif_ogqisuA8,1955
|
14
|
+
openfund_maker-2.2.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
15
|
+
openfund_maker-2.2.2.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
|
16
|
+
openfund_maker-2.2.2.dist-info/RECORD,,
|
@@ -1,16 +0,0 @@
|
|
1
|
-
maker/BestFVGStrategyMaker.py,sha256=oZafiWLkyIY6Su17eqF27cXeRSYrmLnGWDeEejVLMsU,11681
|
2
|
-
maker/MACDStrategyMaker.py,sha256=iS5HO04piKHFJxUI2e5QmicxzGeK-V1aphJSr2n_4Ac,12651
|
3
|
-
maker/SMCStrategyMaker.py,sha256=T3SQIqbH6mMKS_YXLMqnT96McySp8pz0CUCpxTRVItQ,35227
|
4
|
-
maker/ThreeLineStrategyMaker.py,sha256=ArjnHlGECiD3cCFXxO0Ex5scR2agwoxZY-4mKukyKc4,30402
|
5
|
-
maker/WickReversalStrategyMaker.py,sha256=7DqPDVJot4EM0_lSAcFAHrR9rNvkIds9KLMoDOiAHEc,17486
|
6
|
-
maker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
maker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
|
8
|
-
maker/main.py,sha256=XpZ2N55bi5Fi_r2FKuqBu8e71mTxgHgrtzJUjBe1fUc,4405
|
9
|
-
maker/main_m.py,sha256=0PzDTnuBrxfpy5WDfsIHKAzZ_7pkuvuqqeWik0vpWio,15522
|
10
|
-
maker/okxapi.py,sha256=_9G0U_o0ZC8NxaT6PqpiLgxBm9gPobC9PsFHZE1c5w0,553
|
11
|
-
maker/zhen.py.bak,sha256=HNkrQbJts8G9umE9chEFsc0cLQApcM9KOVNMYPpkBXM,10918
|
12
|
-
maker/zhen_2.py,sha256=4IaHVtTCMSlrLGSTZrWpW2q-f7HZsUNRkW_-5QgWv24,10509
|
13
|
-
openfund_maker-2.1.15.dist-info/METADATA,sha256=DxvAfMNWxBvp3L5EnZhssQg6i5jLY_y3Y9Nw4ToP9OQ,1954
|
14
|
-
openfund_maker-2.1.15.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
15
|
-
openfund_maker-2.1.15.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
|
16
|
-
openfund_maker-2.1.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|