openfund-taker 1.3.1__py3-none-any.whl → 1.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openfund-taker
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: Openfund-taker
5
5
  Requires-Python: >=3.9,<4.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,6 +1,7 @@
1
1
  taker/MultiAssetOldTradingBot.py,sha256=uBh_BxglvcbaHIsWHM7GI9Qa_QjzsxXaXJAAWEOMO5c,15315
2
2
  taker/ThreeLineTradingBot.py,sha256=oXIoQ8z9AzKzk0z13d0ufj2KGBOk5iHJTJNZQRDKA5U,20625
3
- taker/TrailingSLTaker.py,sha256=vYUrE-UO6s4xkDyToPoj_65-wsnuXnnCQT70X6Hmr30,42228
3
+ taker/TrailingSLAndTPTaker.py,sha256=gikp-Yahn4nWYk6PmUB02t8Sun--Fo4I7vDEU4U2uso,1263
4
+ taker/TrailingSLTaker.py,sha256=LL6BxJQo6yhkruXRDA0jQMt9K-GxhMZiTmKrWwIuZzo,42277
4
5
  taker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
6
  taker/chua_bitget.py,sha256=YY6XK5Bd-wlArsN5BnAfiqE0h1DPkti6i4TEB4F5zDA,12918
6
7
  taker/chua_bn.py,sha256=GnTePWlgDwdHgroBbEp1Ajcsf5_m_Vn_RV63SYzu2jI,10668
@@ -8,8 +9,8 @@ taker/chua_ok.py,sha256=5pPAoEYbFuKxfZwqNvOO890s-2cy6n69QiI0ZA0GTCQ,12474
8
9
  taker/chua_ok_all.py,sha256=2XnZM6QdB3juSE1pqQIJyh2x1XuhlTlnBKNA3owlJ9E,15267
9
10
  taker/chua_ok_bot.py,sha256=9SW0ujhi6PfN4yR1JZ9NaA37HtnXJ2QAWUfW52NG68w,13109
10
11
  taker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
11
- taker/main.py,sha256=sNLe49TZZzE0FXmmGNzh8b3PyS5KnKS3SFcNKO8q8RU,2492
12
- openfund_taker-1.3.1.dist-info/METADATA,sha256=iUV2Dwu936Z5WXcVOmmgwBQo1GLOWnldfW7LXfthHuU,7527
13
- openfund_taker-1.3.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
14
- openfund_taker-1.3.1.dist-info/entry_points.txt,sha256=a7mG8F7aOA5-Gk2vPWuAR4537faxaHUgM_jwIDBZoEc,50
15
- openfund_taker-1.3.1.dist-info/RECORD,,
12
+ taker/main.py,sha256=CYibDo9PEOWbhpSXZ5JTmE-NGJXqDdgvhpadXJNRX60,2557
13
+ openfund_taker-1.3.2.dist-info/METADATA,sha256=JG97fvJiR96kRpwabOg1MlIRSTNGoBOX9A2bsymTm94,7527
14
+ openfund_taker-1.3.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
15
+ openfund_taker-1.3.2.dist-info/entry_points.txt,sha256=a7mG8F7aOA5-Gk2vPWuAR4537faxaHUgM_jwIDBZoEc,50
16
+ openfund_taker-1.3.2.dist-info/RECORD,,
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ import ccxt
3
+ import time
4
+ import requests
5
+ import traceback
6
+ import pandas as pd
7
+ import talib as ta
8
+ from taker.TrailingSLTaker import TrailingSLTaker
9
+ '''
10
+ 自动设置移动止损单
11
+ '''
12
+ class TrailingSLAndTPTaker(TrailingSLTaker):
13
+ def __init__(self,g_config, platform_config, feishu_webhook=None, monitor_interval=4,logger=None):
14
+ super().__init__(g_config, platform_config, feishu_webhook, monitor_interval,logger)
15
+ self.all_TP_LS_ratio = float(platform_config.get("all_TP_LS_ratio",1.5)) #The profit-loss ratio 盈亏比
16
+ self.all_take_profit_pct = self.stop_loss_pct * self.all_TP_LS_ratio
17
+
18
+ def set_stop_loss_take_profit(self, symbol, position, stop_loss_price=None, take_profit_price=None) -> bool:
19
+ is_successful = super().set_stop_loss_take_profit(symbol, position, stop_loss_price, take_profit_price)
20
+ # take_profile_pct = self.stop_loss_pct * 2
21
+ order_take_profit_price = take_profit_price
22
+ if take_profit_price is None:
23
+ order_take_profit_price = self.calculate_take_profile_price(symbol, position, self.all_take_profit_pct)
24
+ is_successful = self.set_take_profit(symbol, position, order_take_profit_price)
25
+
26
+
27
+ return is_successful
28
+
taker/TrailingSLTaker.py CHANGED
@@ -13,8 +13,8 @@ class TrailingSLTaker:
13
13
  self.trading_pairs_config = g_config.get('tradingPairs', {})
14
14
 
15
15
 
16
- self.stop_loss_pct = platform_config["all_stop_loss_pct"] # 全局止损百分比
17
- # 止盈比例
16
+ self.stop_loss_pct = float(platform_config.get("all_stop_loss_pct",2)) # 全局止损百分比
17
+ # 回撤比例
18
18
  self.low_trail_stop_loss_pct = platform_config["all_low_trail_stop_loss_pct"] # 第一档
19
19
  self.trail_stop_loss_pct = platform_config["all_trail_stop_loss_pct"]# 第二档
20
20
  self.higher_trail_stop_loss_pct = platform_config["all_higher_trail_stop_loss_pct"]# 第三档
@@ -467,7 +467,7 @@ class TrailingSLTaker:
467
467
  while retry_count < max_retries:
468
468
  try:
469
469
 
470
- self.logger.debug(f"{symbol}: {orderSide} - TP at {take_profit_price} Starting.... ")
470
+ self.logger.debug(f"{symbol}: {orderSide} - TP at {adjusted_price} Starting.... ")
471
471
 
472
472
  self.exchange.create_order(
473
473
  symbol=symbol,
@@ -479,7 +479,7 @@ class TrailingSLTaker:
479
479
  params=tp_params
480
480
  )
481
481
 
482
- self.logger.info(f"{symbol}: TP at {take_profit_price} Done.")
482
+ self.logger.info(f"{symbol}: TP at {adjusted_price} Done.")
483
483
  break
484
484
 
485
485
 
@@ -550,7 +550,7 @@ class TrailingSLTaker:
550
550
  while retry_count < max_retries:
551
551
  try:
552
552
 
553
- self.logger.debug(f"{symbol}: {orderSide} - Pre SL at {stop_loss_price} Starting.... ")
553
+ self.logger.debug(f"{symbol}: {orderSide} - Pre SL at {adjusted_price} Starting.... ")
554
554
 
555
555
  self.exchange.create_order(
556
556
  symbol=symbol,
@@ -562,7 +562,7 @@ class TrailingSLTaker:
562
562
  amount=amount,
563
563
  params=sl_params
564
564
  )
565
- self.logger.info(f"{symbol}: SL at {stop_loss_price} Done.")
565
+ self.logger.info(f"{symbol}: SL at {adjusted_price} Done.")
566
566
  break
567
567
 
568
568
 
@@ -675,17 +675,15 @@ class TrailingSLTaker:
675
675
  # 计算止盈价格。
676
676
 
677
677
  if side == 'long':
678
-
679
- base_price = entry_price * (1-take_profile_pct)
680
- take_profile_price = entry_price + base_price - offset * tick_size
678
+ take_profile_price = entry_price * (1+take_profile_pct/100) - offset * tick_size
681
679
 
682
680
 
683
681
  elif side == 'short':
684
682
 
685
- base_price = entry_price * (1-take_profile_pct)
686
- take_profile_price = entry_price - base_price + offset * tick_size
683
+ # base_price = entry_price * (1-take_profile_pct)
684
+ take_profile_price = entry_price * (1-take_profile_pct/100) + offset * tick_size
687
685
 
688
- return take_profile_price
686
+ return float(self.round_price_to_tick(symbol,take_profile_price))
689
687
 
690
688
  # 计算回撤止盈价格
691
689
  def calculate_stop_loss_price(self, symbol, position, stop_loss_pct, offset=1) -> float:
@@ -711,7 +709,7 @@ class TrailingSLTaker:
711
709
  stop_loss_price = entry_price - base_price + offset * tick_size
712
710
  if latest_stop_loss_price :
713
711
  stop_loss_price = min(stop_loss_price,latest_stop_loss_price)
714
- return stop_loss_price
712
+ return float(self.round_price_to_tick(symbol,stop_loss_price))
715
713
 
716
714
  # 市价仓位平仓
717
715
  def close_all_positions(self,symbol,position):
taker/main.py CHANGED
@@ -3,6 +3,7 @@ import yaml
3
3
  from logging.handlers import TimedRotatingFileHandler
4
4
 
5
5
  from taker.TrailingSLTaker import TrailingSLTaker
6
+ from taker.TrailingSLAndTPTaker import TrailingSLAndTPTaker
6
7
  from taker.ThreeLineTradingBot import ThreeLineTradingBot
7
8
 
8
9
  def build_logger(log_config) -> logging.Logger:
@@ -56,7 +57,7 @@ def main():
56
57
  package_name = __package__ or "taker"
57
58
 
58
59
  logger.info(f" ++ {package_name}:{version} is doing...")
59
- bot = TrailingSLTaker(config_data, platform_config, feishu_webhook=feishu_webhook_url, monitor_interval=monitor_interval,logger=logger)
60
+ bot = TrailingSLAndTPTaker(config_data, platform_config, feishu_webhook=feishu_webhook_url, monitor_interval=monitor_interval,logger=logger)
60
61
  bot.monitor_total_profit()
61
62
  # bot = ThreeLineTradingBot(platform_config, feishu_webhook=feishu_webhook_url, monitor_interval=monitor_interval)
62
63
  # bot.monitor_klines()