openfund-maker 1.3.7__py3-none-any.whl → 1.3.9__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.
@@ -63,7 +63,31 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
63
63
  }
64
64
 
65
65
  return cross_direction
66
+
67
+ def get_macd_trend_of_hist(self, symbol, kLines) -> bool:
68
+ macd = pd.DataFrame(kLines, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
69
+ # 将时间戳转换为日期时间格式
70
+ macd['timestamp'] = pd.to_datetime(macd['timestamp'], unit='ms').dt.strftime('%m-%d %H:%M')
71
+
72
+ # 使用 TA-Lib 计算 MACD
73
+ macd[['macd', 'signal', 'hist']] = pd.DataFrame(ta.MACD(macd['close'], fastperiod=12, slowperiod=26, signalperiod=9)).T
74
+
75
+ # 获取最新的三个hist值
76
+ latest_hist = macd['hist'].iloc[-3:].values
77
+
78
+ # 计算相邻点之间的斜率
79
+ slope1 = latest_hist[1] - latest_hist[0]
80
+ slope2 = latest_hist[2] - latest_hist[1]
66
81
 
82
+ # 判断斜率是否同向(都为正或都为负)
83
+ is_same_trend = (slope1 > 0 and slope2 > 0) or (slope1 < 0 and slope2 < 0)
84
+
85
+ self.logger.debug(f"{symbol} : 最近三个hist值 {latest_hist} ,斜率 {slope1} {slope2} ,是否同向 {is_same_trend}。")
86
+
87
+
88
+ return is_same_trend
89
+
90
+
67
91
 
68
92
  def judge_order_side(self, symbol, kLines, valid_klines=5 ,strategy=None) -> str:
69
93
 
@@ -91,7 +115,7 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
91
115
  order_side = 'buy'
92
116
  self.logger.debug(f"{symbol} : 零轴之上的macd与signal形成金叉{all_cross[0]} 。")
93
117
 
94
- # 如果最新的交叉是死叉,且又是零轴下方的死叉
118
+ # # 如果最新的交叉是死叉,且又是零轴下方的死叉
95
119
  elif (len(last_down_crosses) > 0 and
96
120
  all_cross[0][0] == 'death' and
97
121
  all_cross[0][1] == last_down_crosses[0][1] and
@@ -174,10 +198,18 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
174
198
  # self.logger.debug(f"{symbol} : MACD Values = \n {df.tail(5)}")
175
199
  side = self.judge_order_side(symbol, kLines,valid_klines, macd_strategy)
176
200
 
201
+ # 校验一下macd的能量柱的趋势是否一致
202
+ is_same_trend = self.get_macd_trend_of_hist(symbol, kLines)
203
+ if not is_same_trend :
204
+ self.logger.debug(f"{symbol} : MACD 能量柱趋势不一致,不进行下单。")
205
+ return
206
+
207
+ # 和HTF方向进行对比
177
208
  htf_side = self.judge_HTF_side(symbol, macd_strategy)
178
209
  if htf_side != 'none' and side != htf_side:
179
210
  self.logger.debug(f"{symbol} : 下单方向 {side} 与HTF方向 {htf_side} 不一致,不进行下单。")
180
211
  return
212
+
181
213
 
182
214
 
183
215
  long_amount_usdt = pair_config.get('long_amount_usdt', 5)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openfund-maker
3
- Version: 1.3.7
3
+ Version: 1.3.9
4
4
  Summary: Openfund-maker.
5
5
  Requires-Python: >=3.9,<4.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,4 +1,4 @@
1
- maker/MACDStrategyMaker.py,sha256=8VZ9tVYZqYhAiSHrboLzGAQQz6oOAi3iEd-paH2W2YY,10412
1
+ maker/MACDStrategyMaker.py,sha256=Jykr8aBgL4ztsj_IbXSEqgyQ9uYe9XOBM9unQeHZBVs,11854
2
2
  maker/ThreeLineStrategyMaker.py,sha256=5uUTRMOCe0-0d2Ll7Bzhe-0WKpnfddhDEaj3XTGDgyA,30270
3
3
  maker/WickReversalStrategyMaker.py,sha256=7DqPDVJot4EM0_lSAcFAHrR9rNvkIds9KLMoDOiAHEc,17486
4
4
  maker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -8,7 +8,7 @@ maker/main_m.py,sha256=0PzDTnuBrxfpy5WDfsIHKAzZ_7pkuvuqqeWik0vpWio,15522
8
8
  maker/okxapi.py,sha256=_9G0U_o0ZC8NxaT6PqpiLgxBm9gPobC9PsFHZE1c5w0,553
9
9
  maker/zhen.py.bak,sha256=HNkrQbJts8G9umE9chEFsc0cLQApcM9KOVNMYPpkBXM,10918
10
10
  maker/zhen_2.py,sha256=4IaHVtTCMSlrLGSTZrWpW2q-f7HZsUNRkW_-5QgWv24,10509
11
- openfund_maker-1.3.7.dist-info/METADATA,sha256=ZWuxLVi0KrI87lzl4mnl1IWvhcLZRY-MQqAC6zAMJ_U,1953
12
- openfund_maker-1.3.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
13
- openfund_maker-1.3.7.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
14
- openfund_maker-1.3.7.dist-info/RECORD,,
11
+ openfund_maker-1.3.9.dist-info/METADATA,sha256=DOMTLWOxfbOpeUx5Q5arkWKypQIJI2WZ8kS22C01Sm4,1953
12
+ openfund_maker-1.3.9.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
13
+ openfund_maker-1.3.9.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
14
+ openfund_maker-1.3.9.dist-info/RECORD,,