openfund-maker 1.3.9__tar.gz → 1.3.11__tar.gz
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.
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/PKG-INFO +1 -1
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/pyproject.toml +1 -1
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/MACDStrategyMaker.py +19 -16
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/main.py +2 -2
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/README.md +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/ThreeLineStrategyMaker.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/WickReversalStrategyMaker.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/__init__.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/config.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/main_m.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/okxapi.py +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/zhen.py.bak +0 -0
- {openfund_maker-1.3.9 → openfund_maker-1.3.11}/src/maker/zhen_2.py +0 -0
@@ -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=
|
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
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
-
|
170
|
+
# self.logger.debug(f"{symbol} : HTF={htf} , {order_side}。")
|
167
171
|
|
168
|
-
else:
|
169
|
-
|
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
|
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
|
@@ -73,10 +73,10 @@ def main():
|
|
73
73
|
# 计算下一个整点分钟
|
74
74
|
now = datetime.now()
|
75
75
|
# 将当前时间的秒和微秒设置为0
|
76
|
-
next_run = now.replace(second=
|
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:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|