openfund-taker 1.3.13__py3-none-any.whl → 1.3.14__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.
- {openfund_taker-1.3.13.dist-info → openfund_taker-1.3.14.dist-info}/METADATA +1 -1
- {openfund_taker-1.3.13.dist-info → openfund_taker-1.3.14.dist-info}/RECORD +5 -5
- taker/TrailingSLTaker.py +31 -10
- {openfund_taker-1.3.13.dist-info → openfund_taker-1.3.14.dist-info}/WHEEL +0 -0
- {openfund_taker-1.3.13.dist-info → openfund_taker-1.3.14.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
taker/MultiAssetOldTradingBot.py,sha256=uBh_BxglvcbaHIsWHM7GI9Qa_QjzsxXaXJAAWEOMO5c,15315
|
2
2
|
taker/ThreeLineTradingTaker.py,sha256=ElD9pKDO4nxw5VKNRrvXqyiU0gkV_1Mg_zk-hftfaPs,20553
|
3
3
|
taker/TrailingSLAndTPTaker.py,sha256=rx3tw9TwFCpqnz3e0WlTtFVcn8mBbPHtp62n3RF86Kg,1144
|
4
|
-
taker/TrailingSLTaker.py,sha256=
|
4
|
+
taker/TrailingSLTaker.py,sha256=iAFeGsgWVdMlaOQEYgRcjPPuRcmPsytCdguEKu1Qz9o,44928
|
5
5
|
taker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
taker/chua_bitget.py,sha256=YY6XK5Bd-wlArsN5BnAfiqE0h1DPkti6i4TEB4F5zDA,12918
|
7
7
|
taker/chua_bn.py,sha256=GnTePWlgDwdHgroBbEp1Ajcsf5_m_Vn_RV63SYzu2jI,10668
|
@@ -10,7 +10,7 @@ taker/chua_ok_all.py,sha256=2XnZM6QdB3juSE1pqQIJyh2x1XuhlTlnBKNA3owlJ9E,15267
|
|
10
10
|
taker/chua_ok_bot.py,sha256=9SW0ujhi6PfN4yR1JZ9NaA37HtnXJ2QAWUfW52NG68w,13109
|
11
11
|
taker/config.py,sha256=YPxghO5i0vgRg9Cja8kGj9O7pgSbbtzOgf3RexqXXwY,1188
|
12
12
|
taker/main.py,sha256=QCEjINu3IgwWEGcuquHzeYjKJYAQrPe8ctQhMoIb9SA,2561
|
13
|
-
openfund_taker-1.3.
|
14
|
-
openfund_taker-1.3.
|
15
|
-
openfund_taker-1.3.
|
16
|
-
openfund_taker-1.3.
|
13
|
+
openfund_taker-1.3.14.dist-info/METADATA,sha256=nrN5bTWF-fmAMIwkzFSY0x-w8HpUzypKYivAYK3gPhg,7528
|
14
|
+
openfund_taker-1.3.14.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
15
|
+
openfund_taker-1.3.14.dist-info/entry_points.txt,sha256=a7mG8F7aOA5-Gk2vPWuAR4537faxaHUgM_jwIDBZoEc,50
|
16
|
+
openfund_taker-1.3.14.dist-info/RECORD,,
|
taker/TrailingSLTaker.py
CHANGED
@@ -18,11 +18,17 @@ class TrailingSLTaker:
|
|
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"]# 第三档
|
21
|
-
#
|
21
|
+
# 止损阈值
|
22
22
|
self.low_trail_profit_threshold = platform_config["all_low_trail_profit_threshold"]# 第一档
|
23
23
|
self.first_trail_profit_threshold = platform_config["all_first_trail_profit_threshold"]# 第二档
|
24
24
|
self.second_trail_profit_threshold = platform_config["all_second_trail_profit_threshold"]# 第三档
|
25
25
|
|
26
|
+
# 追踪止盈回撤
|
27
|
+
self.open_trail_tp = platform_config.get("open_trail_tp",False)# 是否开启追踪止盈
|
28
|
+
self.low_trail_tp_pct = platform_config["all_low_trail_tp_pct"]# 第一档
|
29
|
+
self.trail_tp_pct = platform_config["all_trail_tp_pct"]# 第二档
|
30
|
+
self.higher_trail_tp_pct = platform_config["all_higher_trail_tp_pct"]# 第三档
|
31
|
+
|
26
32
|
self.feishu_webhook = feishu_webhook
|
27
33
|
self.monitor_interval = monitor_interval # 监控循环时间是分仓监控的3倍
|
28
34
|
|
@@ -824,8 +830,9 @@ class TrailingSLTaker:
|
|
824
830
|
|
825
831
|
total_profit = self.calculate_average_profit(symbol, position)
|
826
832
|
|
827
|
-
|
828
|
-
self.
|
833
|
+
msg = f"{symbol}: 盈利= {total_profit:.2f}% 开仓= {position['entryPrice']:.10f} 市价= {position['markPrice']:.10f}"
|
834
|
+
self.logger.info(msg)
|
835
|
+
self.send_feishu_notification(msg)
|
829
836
|
|
830
837
|
cur_highest_total_profit = self.highest_total_profit.get(symbol, 0.0)
|
831
838
|
|
@@ -847,7 +854,7 @@ class TrailingSLTaker:
|
|
847
854
|
|
848
855
|
if total_profit > 0.0 :
|
849
856
|
self.logger.info(
|
850
|
-
f"{symbol} 档位[{current_tier}]:
|
857
|
+
f"{symbol} 档位[{current_tier}]: 盈利: {total_profit:.2f}%,最高盈利: {cur_highest_total_profit:.2f}%")
|
851
858
|
|
852
859
|
'''
|
853
860
|
第一档:低档保护止盈:当盈利达到0.3%触发,要么到第二档,要么回到0.2%止盈
|
@@ -860,21 +867,35 @@ class TrailingSLTaker:
|
|
860
867
|
# 根据不同档位设置止损价格,没有单独为交易对设置,用全局参数代替
|
861
868
|
tier_config = {
|
862
869
|
"低档": {
|
863
|
-
"stop_loss_pct": float(pair_config.get('low_trail_stop_loss_pct',self.low_trail_stop_loss_pct))
|
870
|
+
"stop_loss_pct": float(pair_config.get('low_trail_stop_loss_pct',self.low_trail_stop_loss_pct)),
|
871
|
+
"trail_tp_pct": float(pair_config.get('low_trail_tp_pct',self.low_trail_tp_pct))
|
864
872
|
},
|
865
873
|
"中档": {
|
866
|
-
"stop_loss_pct": float(pair_config.get('trail_stop_loss_pct',self.trail_stop_loss_pct))
|
874
|
+
"stop_loss_pct": float(pair_config.get('trail_stop_loss_pct',self.trail_stop_loss_pct)),
|
875
|
+
"trail_tp_pct": float(pair_config.get('trail_tp_pct',self.trail_tp_pct))
|
867
876
|
},
|
868
877
|
"高档": {
|
869
|
-
"stop_loss_pct": float(pair_config.get('higher_trail_stop_loss_pct',self.higher_trail_stop_loss_pct))
|
878
|
+
"stop_loss_pct": float(pair_config.get('higher_trail_stop_loss_pct',self.higher_trail_stop_loss_pct)),
|
879
|
+
"trail_tp_pct": float(pair_config.get('higher_trail_tp_pct',self.higher_trail_tp_pct))
|
870
880
|
}
|
871
881
|
}
|
872
882
|
|
873
883
|
if current_tier in tier_config:
|
874
884
|
config = tier_config[current_tier]
|
875
885
|
|
886
|
+
# 是否追踪止盈
|
887
|
+
if self.open_trail_tp and total_profit < cur_highest_total_profit:
|
888
|
+
cur_trail_tp_pct = round((1-total_profit/cur_highest_total_profit), 3)
|
889
|
+
trail_tp_pct = float(config['trail_tp_pct'])
|
890
|
+
if cur_trail_tp_pct >= trail_tp_pct:
|
891
|
+
self.close_all_positions(symbol=symbol, position=position)
|
892
|
+
msg = f"{symbol}: 盈利【{current_tier}】保护止盈={trail_tp_pct*100}%,价格回撤 -{cur_trail_tp_pct*100}%: 利润={total_profit:.2f}%,执行止盈平仓"
|
893
|
+
self.logger.info(msg)
|
894
|
+
self.send_feishu_notification(msg)
|
895
|
+
return
|
896
|
+
|
876
897
|
# 记录日志
|
877
|
-
self.logger.debug(f"{symbol} 回撤止盈阈值: {config['stop_loss_pct']*100}%")
|
898
|
+
self.logger.debug(f"{symbol}: 回撤止盈阈值: {config['stop_loss_pct']*100}%")
|
878
899
|
|
879
900
|
# 计算回撤止损价格
|
880
901
|
sl_price = self.calculate_stop_loss_price(
|
@@ -886,7 +907,7 @@ class TrailingSLTaker:
|
|
886
907
|
# 检查价格是否变化
|
887
908
|
latest_sl_price = self.exchange.safe_float(self.global_symbol_stop_loss_price, symbol, 0.0)
|
888
909
|
if sl_price == latest_sl_price:
|
889
|
-
self.logger.debug(f"{symbol} 回撤止损价格{latest_sl_price}未变化,不设置")
|
910
|
+
self.logger.debug(f"{symbol}: 回撤止损价格{latest_sl_price}未变化,不设置")
|
890
911
|
return
|
891
912
|
|
892
913
|
# 设置止损
|
@@ -909,7 +930,7 @@ class TrailingSLTaker:
|
|
909
930
|
|
910
931
|
# 默认全局止损
|
911
932
|
self.set_global_stop_loss(symbol, position)
|
912
|
-
self.logger.info(f"{symbol} 全局止损阈值: {self.stop_loss_pct:.2f}%")
|
933
|
+
self.logger.info(f"{symbol}: 全局止损阈值: {self.stop_loss_pct:.2f}%")
|
913
934
|
|
914
935
|
return
|
915
936
|
|
File without changes
|
File without changes
|