openfund-maker 1.3.8__tar.gz → 1.3.10__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.8 → openfund_maker-1.3.10}/PKG-INFO +1 -1
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/pyproject.toml +1 -1
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/MACDStrategyMaker.py +35 -2
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/main.py +2 -2
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/README.md +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/ThreeLineStrategyMaker.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/WickReversalStrategyMaker.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/__init__.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/config.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/main_m.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/okxapi.py +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/zhen.py.bak +0 -0
- {openfund_maker-1.3.8 → openfund_maker-1.3.10}/src/maker/zhen_2.py +0 -0
@@ -63,7 +63,32 @@ 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
|
+
# self.logger.debug(f"{symbol} : macd = \n {macd[['timestamp','close', 'macd', 'signal', 'hist']].tail(5)}")
|
76
|
+
# 获取最新的三个hist值
|
77
|
+
latest_hist = macd['hist'].iloc[-3:].values
|
78
|
+
|
79
|
+
# 计算相邻点之间的斜率
|
80
|
+
slope1 = latest_hist[1] - latest_hist[0]
|
81
|
+
slope2 = latest_hist[2] - latest_hist[1]
|
82
|
+
|
83
|
+
# 判断斜率是否同向(都为正或都为负)
|
84
|
+
is_same_trend = (slope1 > 0 and slope2 > 0) or (slope1 < 0 and slope2 < 0)
|
66
85
|
|
86
|
+
self.logger.debug(f"{symbol} : 最近三个hist值 {latest_hist} ,斜率 {slope1:.10f} {slope2:.10f} ,是否同向 {is_same_trend}。")
|
87
|
+
|
88
|
+
|
89
|
+
return is_same_trend
|
90
|
+
|
91
|
+
|
67
92
|
|
68
93
|
def judge_order_side(self, symbol, kLines, valid_klines=5 ,strategy=None) -> str:
|
69
94
|
|
@@ -91,7 +116,7 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
|
|
91
116
|
order_side = 'buy'
|
92
117
|
self.logger.debug(f"{symbol} : 零轴之上的macd与signal形成金叉{all_cross[0]} 。")
|
93
118
|
|
94
|
-
# 如果最新的交叉是死叉,且又是零轴下方的死叉
|
119
|
+
# # 如果最新的交叉是死叉,且又是零轴下方的死叉
|
95
120
|
elif (len(last_down_crosses) > 0 and
|
96
121
|
all_cross[0][0] == 'death' and
|
97
122
|
all_cross[0][1] == last_down_crosses[0][1] and
|
@@ -172,12 +197,20 @@ class MACDStrategyMaker(ThreeLineStrategyMaker):
|
|
172
197
|
|
173
198
|
valid_klines = pair_config.get('valid_klines', 5)
|
174
199
|
# self.logger.debug(f"{symbol} : MACD Values = \n {df.tail(5)}")
|
175
|
-
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
|
+
side = self.judge_order_side(symbol, kLines,valid_klines, macd_strategy)
|
208
|
+
# 和HTF方向进行对比
|
177
209
|
htf_side = self.judge_HTF_side(symbol, macd_strategy)
|
178
210
|
if htf_side != 'none' and side != htf_side:
|
179
211
|
self.logger.debug(f"{symbol} : 下单方向 {side} 与HTF方向 {htf_side} 不一致,不进行下单。")
|
180
212
|
return
|
213
|
+
|
181
214
|
|
182
215
|
|
183
216
|
long_amount_usdt = pair_config.get('long_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
|