openfund-maker 1.0.7__py3-none-any.whl → 1.0.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.
@@ -359,7 +359,7 @@ class ThreeLineOrdergBot:
359
359
  'index': None
360
360
  }
361
361
 
362
- def judge_ma_direction(self,fastklines,slowklines) -> bool:
362
+ def judge_ma_apex(self,fastklines,slowklines) -> bool:
363
363
  df = pd.DataFrame()
364
364
  df['ema'] = fastklines
365
365
  df['sma'] = slowklines
@@ -368,9 +368,8 @@ class ThreeLineOrdergBot:
368
368
  # 计算斜率,【正】表示两线距离扩张,【负】表示两线距离收缩
369
369
  df['slope'] = df['diff'].abs().diff().round(6)
370
370
 
371
- #
372
- return df['slope'].iloc[-1] > 0
373
- # df['statu'] = df['slope']
371
+ # 检查最后两个斜率是否都为负
372
+ return all(slope < 0 for slope in df['slope'].tail(2))
374
373
 
375
374
 
376
375
  def calculate_range_diff(self,prices:pd.Series) -> float:
@@ -452,38 +451,36 @@ class ThreeLineOrdergBot:
452
451
  is_bullish_trend = True
453
452
  elif direction == 0:
454
453
  is_bearish_trend = True
455
- else:
456
- self.logger.info(f"{symbol} 当前是震荡(平)趋势,不执行挂单!!")
457
- return
458
-
454
+
455
+ # 结合金叉死叉判断是否是周期顶部和底部
456
+ is_apex = self.judge_ma_apex(fastklines=fastk,slowklines=slowk)
457
+ # 金叉死叉逻辑
459
458
  if last_cross_direction and last_cross_direction['cross'] == 1 : # 金叉
460
459
  self.logger.debug(f"{symbol} 金叉:{last_cross_direction},清理空单,挂多单!!")
461
460
  is_bearish_trend = False
461
+ if is_apex :
462
+ self.logger.debug(f"{symbol} 金叉:{last_cross_direction},周期见顶 {is_apex},不开单!!")
463
+ is_bullish_trend = False
464
+
462
465
  elif last_cross_direction and last_cross_direction['cross'] == 0 : # 死叉
463
466
  self.logger.debug(f"{symbol} 死叉:{last_cross_direction},清理多单,挂空单!!")
464
467
  is_bullish_trend = False
468
+ if is_apex :
469
+ self.logger.debug(f"{symbol} 死叉:{last_cross_direction},周期见顶 {is_apex},不开单!!")
470
+ is_bearish_trend = False
471
+
465
472
  else:
466
473
  self.logger.debug(f"{symbol} 当前没有金叉死叉,以快线趋势为准。!")
467
- return
474
+
475
+
476
+ if not is_bullish_trend and not is_bearish_trend :
477
+ self.logger.info(f"{symbol} 当前是震荡趋势(平),不挂单!!")
478
+ return
468
479
 
469
480
  '''
470
481
  取当前K线的前三根K线中最高/低的值作为止盈位。
471
482
  20250210 增加开单价格约束,下单时,三线如果价格振幅小(如0.32%内),那去找到0.32%外的那根。 振幅 amplitude_limit
472
483
  '''
473
- # 获取 K 线数据
474
- # ohlcv = self.exchange.fetch_ohlcv(symbol, '1m')
475
-
476
- # 取当前 K 线的前三根 K 线
477
- # previous_three_candles = ohlcv[-4:-1]
478
- # 提取每根 K 线的最高价
479
-
480
- # high_prices = [candle[2] for candle in previous_three_candles]
481
- # # 提取每根 K 线的最低价
482
- # low_prices = [candle[3] for candle in previous_three_candles]
483
- # # 找出最大值
484
- # max_high = max(high_prices)
485
- # # 找出最小值
486
- # min_low = min(low_prices)
487
484
 
488
485
  # 取当前 K 线的前三根 K 线
489
486
 
@@ -511,10 +508,11 @@ class ThreeLineOrdergBot:
511
508
  # 取最新K线的收盘价格
512
509
  close_price = klines[-1][4]
513
510
  self.logger.debug(f"-- {symbol} 最新K线 {klines[-1]}")
511
+
514
512
  if is_bullish_trend:
515
513
  diff = self.calculate_range_diff(prices=low_prices)
516
514
  cur_amplitude_limit = diff / close_price * 100
517
- self.logger.info(f"{symbol} 当前为上升(多)趋势,允许挂多单,振幅{cur_amplitude_limit:.3f} hight/low {max(low_prices)}/{min(low_prices)} ++")
515
+ self.logger.info(f"{symbol} 当前为上升(多)趋势,允许挂多单,振幅{cur_amplitude_limit:.3f} hight/low {low_prices.max()}/{low_prices.min()} ++")
518
516
  # 振幅大于限制,直接下单,否则,根据振幅计算下单价格
519
517
  if cur_amplitude_limit >= amplitude_limit:
520
518
  self.place_order(symbol, min_low, long_amount_usdt, 'buy')
@@ -526,13 +524,12 @@ class ThreeLineOrdergBot:
526
524
  if is_bearish_trend:
527
525
  diff = self.calculate_range_diff(prices=high_prices)
528
526
  cur_amplitude_limit = diff / close_price * 100
529
- self.logger.info(f"{symbol} 当前为下降(空)趋势,允许挂空单,振幅{cur_amplitude_limit:.3f} hight/low {max(high_prices)}/{min(high_prices)}--")
527
+ self.logger.info(f"{symbol} 当前为下降(空)趋势,允许挂空单,振幅{cur_amplitude_limit:.3f} hight/low {high_prices.max()}/{high_prices.min()}--")
530
528
  if cur_amplitude_limit >= amplitude_limit:
531
529
  self.place_order(symbol, max_high, short_amount_usdt, 'sell')
532
530
  else:
533
531
  entry_price = self.calculate_place_order_price(symbol,side='sell',base_price=max_high, amplitude_limit=amplitude_limit,offset=0)
534
- self.place_order(symbol, entry_price ,long_amount_usdt, 'sell')
535
-
532
+ self.place_order(symbol, entry_price ,long_amount_usdt, 'sell')
536
533
 
537
534
  except KeyboardInterrupt:
538
535
  self.logger.info("程序收到中断信号,开始退出...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openfund-maker
3
- Version: 1.0.7
3
+ Version: 1.0.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/ThreeLineOrderBot.py,sha256=5ye25LP090vITVieCCVDB2bZndfndKv8od7vfuXB6ZM,23768
1
+ maker/ThreeLineOrderBot.py,sha256=9kj-84oqBlgsfTDm1LdFn3Y4JJ5UmhAVGHMCwY0VIdg,23846
2
2
  maker/WickReversalOrderBot.py,sha256=Oc6wChdWu39lfWh3NRHM8BqvaRIYDNZiDR6PDnE9XUM,17374
3
3
  maker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  maker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
@@ -7,7 +7,7 @@ maker/main_m.py,sha256=0PzDTnuBrxfpy5WDfsIHKAzZ_7pkuvuqqeWik0vpWio,15522
7
7
  maker/okxapi.py,sha256=_9G0U_o0ZC8NxaT6PqpiLgxBm9gPobC9PsFHZE1c5w0,553
8
8
  maker/zhen.py.bak,sha256=HNkrQbJts8G9umE9chEFsc0cLQApcM9KOVNMYPpkBXM,10918
9
9
  maker/zhen_2.py,sha256=4IaHVtTCMSlrLGSTZrWpW2q-f7HZsUNRkW_-5QgWv24,10509
10
- openfund_maker-1.0.7.dist-info/METADATA,sha256=5cr-Ut4VsPUudjFfDdUCcG2mclOZ30gIlrKD278wmiE,1965
11
- openfund_maker-1.0.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
12
- openfund_maker-1.0.7.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
13
- openfund_maker-1.0.7.dist-info/RECORD,,
10
+ openfund_maker-1.0.9.dist-info/METADATA,sha256=2H8RDwdZY6LHayvt139dSj4YoMuz00a5NhnkU6lb5Fw,1965
11
+ openfund_maker-1.0.9.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
12
+ openfund_maker-1.0.9.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
13
+ openfund_maker-1.0.9.dist-info/RECORD,,