openfund-maker 1.3.9__py3-none-any.whl → 1.3.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.
@@ -72,6 +72,7 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
72
72
  # 使用 TA-Lib 计算 MACD
73
73
  macd[['macd', 'signal', 'hist']] = pd.DataFrame(ta.MACD(macd['close'], fastperiod=12, slowperiod=26, signalperiod=9)).T
74
74
 
75
+ # self.logger.debug(f"{symbol} : macd = \n {macd[['timestamp','close', 'macd', 'signal', 'hist']].tail(5)}")
75
76
  # 获取最新的三个hist值
76
77
  latest_hist = macd['hist'].iloc[-3:].values
77
78
 
@@ -82,14 +83,14 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
82
83
  # 判断斜率是否同向(都为正或都为负)
83
84
  is_same_trend = (slope1 > 0 and slope2 > 0) or (slope1 < 0 and slope2 < 0)
84
85
 
85
- self.logger.debug(f"{symbol} : 最近三个hist值 {latest_hist} ,斜率 {slope1} {slope2} ,是否同向 {is_same_trend}。")
86
+ self.logger.debug(f"{symbol} : 最近三个hist值 {latest_hist} ,斜率 {slope1:.10f} {slope2:.10f} ,是否同向 {is_same_trend}。")
86
87
 
87
88
 
88
89
  return is_same_trend
89
90
 
90
91
 
91
92
 
92
- def judge_order_side(self, symbol, kLines, valid_klines=5 ,strategy=None) -> str:
93
+ def judge_order_side(self, symbol, kLines, valid_klines=241 ,strategy=None) -> str:
93
94
 
94
95
  '''
95
96
  零轴之上的macd与signal形成金叉
@@ -155,18 +156,21 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
155
156
  htf = str(strategy.get('HTF', '1h'))
156
157
  htf_kLines = self.get_historical_klines(symbol=symbol, bar=htf)
157
158
 
158
- crosses = self.get_macd_cross_direction(symbol, htf_kLines, strategy)
159
- all_cross = crosses.get('all_cross',[])
160
- if len(all_cross) > 1:
161
- if all_cross[0][0] == 'golden':
162
- order_side = 'buy'
163
- else:
164
- order_side = 'sell'
159
+ # 20250312 修改为MACD形态校验,而不只是金死叉
160
+ order_side = self.judge_order_side(symbol, kLines=htf_kLines)
161
+ self.logger.debug(f"{symbol} : HTF={htf} , {order_side}。")
162
+ # crosses = self.get_macd_cross_direction(symbol, htf_kLines, strategy)
163
+ # all_cross = crosses.get('all_cross',[])
164
+ # if len(all_cross) > 1:
165
+ # if all_cross[0][0] == 'golden':
166
+ # order_side = 'buy'
167
+ # else:
168
+ # order_side = 'sell'
165
169
 
166
- self.logger.debug(f"{symbol} : HTF={htf} , {order_side}。")
170
+ # self.logger.debug(f"{symbol} : HTF={htf} , {order_side}。")
167
171
 
168
- else:
169
- self.logger.debug(f"{symbol} : HTF={htf} ,没有满足条件的交叉点。")
172
+ # else:
173
+ # self.logger.debug(f"{symbol} : HTF={htf} ,没有满足条件的交叉点。")
170
174
 
171
175
  except Exception as e:
172
176
  error_message = f"程序异常退出: {str(e)}"
@@ -196,7 +200,6 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
196
200
 
197
201
  valid_klines = pair_config.get('valid_klines', 5)
198
202
  # self.logger.debug(f"{symbol} : MACD Values = \n {df.tail(5)}")
199
- side = self.judge_order_side(symbol, kLines,valid_klines, macd_strategy)
200
203
 
201
204
  # 校验一下macd的能量柱的趋势是否一致
202
205
  is_same_trend = self.get_macd_trend_of_hist(symbol, kLines)
@@ -204,14 +207,14 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
204
207
  self.logger.debug(f"{symbol} : MACD 能量柱趋势不一致,不进行下单。")
205
208
  return
206
209
 
210
+ side = self.judge_order_side(symbol, kLines,valid_klines, macd_strategy)
207
211
  # 和HTF方向进行对比
208
212
  htf_side = self.judge_HTF_side(symbol, macd_strategy)
209
- if htf_side != 'none' and side != htf_side:
213
+ if htf_side == 'none' or side == 'none' or side != htf_side:
210
214
  self.logger.debug(f"{symbol} : 下单方向 {side} 与HTF方向 {htf_side} 不一致,不进行下单。")
211
215
  return
212
216
 
213
-
214
-
217
+
215
218
  long_amount_usdt = pair_config.get('long_amount_usdt', 5)
216
219
  short_amount_usdt = pair_config.get('short_amount_usdt', 5)
217
220
  order_amount_usdt = 5
maker/main.py CHANGED
@@ -73,10 +73,10 @@ def main():
73
73
  # 计算下一个整点分钟
74
74
  now = datetime.now()
75
75
  # 将当前时间的秒和微秒设置为0
76
- next_run = now.replace(second=59, microsecond=0)
76
+ next_run = now.replace(second=58, microsecond=0)
77
77
  # 计算下一个周期的开始时间
78
78
  current_minute = next_run.minute
79
- # 向上取整到下一个周期时间点
79
+ # 向上取整到下一个周期时间点, 然后再减去2Units,比如秒就是58秒执行。
80
80
  next_interval = ((current_minute // monitor_interval) + 1) * monitor_interval -1
81
81
  # 如果下一个周期时间点超过60分钟,需要调整为下一个小时的对应分钟数
82
82
  if next_interval >= 60:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openfund-maker
3
- Version: 1.3.9
3
+ Version: 1.3.11
4
4
  Summary: Openfund-maker.
5
5
  Requires-Python: >=3.9,<4.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,14 +1,14 @@
1
- maker/MACDStrategyMaker.py,sha256=Jykr8aBgL4ztsj_IbXSEqgyQ9uYe9XOBM9unQeHZBVs,11854
1
+ maker/MACDStrategyMaker.py,sha256=7qH295CZrnGgJr9THo_EYZ65R5mni6DlSaw_8tTWSWY,12252
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
5
5
  maker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
6
- maker/main.py,sha256=QOlz6XGXDmmcan8dIA3NOap1BqoRCAyxoP5R9cV1beI,4097
6
+ maker/main.py,sha256=3VMvFJW_ugmB3QpUrzjBfkma9erDsVw3Tox6RdGjhRk,4150
7
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.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,,
11
+ openfund_maker-1.3.11.dist-info/METADATA,sha256=pFB9ass2dhlkL4dABaB3KQlqsqvnvQagdJw0BeEF-6I,1954
12
+ openfund_maker-1.3.11.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
13
+ openfund_maker-1.3.11.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
14
+ openfund_maker-1.3.11.dist-info/RECORD,,