openfund-maker 1.0.7__py3-none-any.whl → 1.0.8__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
@@ -369,7 +369,7 @@ class ThreeLineOrdergBot:
369
369
  df['slope'] = df['diff'].abs().diff().round(6)
370
370
 
371
371
  #
372
- return df['slope'].iloc[-1] > 0
372
+ return df['slope'].iloc[-1] < 0
373
373
  # df['statu'] = df['slope']
374
374
 
375
375
 
@@ -452,38 +452,36 @@ class ThreeLineOrdergBot:
452
452
  is_bullish_trend = True
453
453
  elif direction == 0:
454
454
  is_bearish_trend = True
455
- else:
456
- self.logger.info(f"{symbol} 当前是震荡(平)趋势,不执行挂单!!")
457
- return
458
-
455
+
456
+ # 结合金叉死叉判断是否是周期顶部和底部
457
+ is_apex = self.judge_ma_apex(fastklines=fastk,slowklines=slowk)
458
+ # 金叉死叉逻辑
459
459
  if last_cross_direction and last_cross_direction['cross'] == 1 : # 金叉
460
460
  self.logger.debug(f"{symbol} 金叉:{last_cross_direction},清理空单,挂多单!!")
461
461
  is_bearish_trend = False
462
+ if is_apex :
463
+ self.logger.debug(f"{symbol} 金叉:{last_cross_direction},周期见顶 {is_apex},不开单!!")
464
+ is_bullish_trend = False
465
+ return
462
466
  elif last_cross_direction and last_cross_direction['cross'] == 0 : # 死叉
463
467
  self.logger.debug(f"{symbol} 死叉:{last_cross_direction},清理多单,挂空单!!")
464
468
  is_bullish_trend = False
469
+ if is_apex :
470
+ self.logger.debug(f"{symbol} 死叉:{last_cross_direction},周期见顶 {is_apex},不开单!!")
471
+ is_bearish_trend = False
472
+ return
465
473
  else:
466
474
  self.logger.debug(f"{symbol} 当前没有金叉死叉,以快线趋势为准。!")
467
- return
475
+ return
476
+
477
+ if not is_bullish_trend and not is_bearish_trend :
478
+ self.logger.info(f"{symbol} 当前是震荡趋势(平),不挂单!!")
479
+ return
468
480
 
469
481
  '''
470
482
  取当前K线的前三根K线中最高/低的值作为止盈位。
471
483
  20250210 增加开单价格约束,下单时,三线如果价格振幅小(如0.32%内),那去找到0.32%外的那根。 振幅 amplitude_limit
472
484
  '''
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
485
 
488
486
  # 取当前 K 线的前三根 K 线
489
487
 
@@ -511,10 +509,11 @@ class ThreeLineOrdergBot:
511
509
  # 取最新K线的收盘价格
512
510
  close_price = klines[-1][4]
513
511
  self.logger.debug(f"-- {symbol} 最新K线 {klines[-1]}")
512
+
514
513
  if is_bullish_trend:
515
514
  diff = self.calculate_range_diff(prices=low_prices)
516
515
  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)} ++")
516
+ self.logger.info(f"{symbol} 当前为上升(多)趋势,允许挂多单,振幅{cur_amplitude_limit:.3f} hight/low {low_prices.max()}/{low_prices.min()} ++")
518
517
  # 振幅大于限制,直接下单,否则,根据振幅计算下单价格
519
518
  if cur_amplitude_limit >= amplitude_limit:
520
519
  self.place_order(symbol, min_low, long_amount_usdt, 'buy')
@@ -526,13 +525,12 @@ class ThreeLineOrdergBot:
526
525
  if is_bearish_trend:
527
526
  diff = self.calculate_range_diff(prices=high_prices)
528
527
  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)}--")
528
+ self.logger.info(f"{symbol} 当前为下降(空)趋势,允许挂空单,振幅{cur_amplitude_limit:.3f} hight/low {high_prices.max()}/{high_prices.min()}--")
530
529
  if cur_amplitude_limit >= amplitude_limit:
531
530
  self.place_order(symbol, max_high, short_amount_usdt, 'sell')
532
531
  else:
533
532
  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
-
533
+ self.place_order(symbol, entry_price ,long_amount_usdt, 'sell')
536
534
 
537
535
  except KeyboardInterrupt:
538
536
  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.8
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=bqJj17SQw4XVGXtgDvY-uNCIG4NAwalRjWr5OT_SQG4,23838
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.8.dist-info/METADATA,sha256=jlncVj8iDI2oWPC2YL6Ox30K71pOUP85HIhWSB9rAws,1965
11
+ openfund_maker-1.0.8.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
12
+ openfund_maker-1.0.8.dist-info/entry_points.txt,sha256=gKMytICEKcMRFQDFkHZLnIpID7UQFoTIM_xcpiiV6Ns,50
13
+ openfund_maker-1.0.8.dist-info/RECORD,,