siglab-py 0.5.5__py3-none-any.whl → 0.5.6__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.

Potentially problematic release.


This version of siglab-py might be problematic. Click here for more details.

@@ -59,12 +59,45 @@ def calc_eff_trailing_sl(
59
59
  tp_max_percent : float,
60
60
  sl_percent_trailing : float,
61
61
  pnl_percent_notional : float,
62
- default_effective_tp_trailing_percent : float = 50
62
+ default_effective_tp_trailing_percent : float = float('inf'), # inf: essentially saying, don't fire off trailing stop.
63
+ linear : bool = True,
64
+ pow : float = 5 # This is for non-linear trailing stops
63
65
  ) -> float:
64
- slope = (0 - sl_percent_trailing) / (tp_max_percent - tp_min_percent)
65
- effective_tp_trailing_percent = (
66
- slope * (pnl_percent_notional - tp_min_percent) + sl_percent_trailing
67
- if pnl_percent_notional>=tp_min_percent
68
- else default_effective_tp_trailing_percent
69
- )
66
+ if linear:
67
+ slope = (0 - sl_percent_trailing) / (tp_max_percent - tp_min_percent)
68
+ effective_tp_trailing_percent = (
69
+ slope * (pnl_percent_notional - tp_min_percent) + sl_percent_trailing
70
+ if pnl_percent_notional>=tp_min_percent
71
+ else default_effective_tp_trailing_percent
72
+ )
73
+ else:
74
+ def y(
75
+ x : float,
76
+ x_shift : float,
77
+ pow : float
78
+ ) -> float:
79
+ return -1 * ( (x+x_shift)**pow)
80
+
81
+ y_min = y(
82
+ x=tp_min_percent,
83
+ x_shift=tp_min_percent,
84
+ pow=pow
85
+ )
86
+ y_max = y(
87
+ x=tp_max_percent,
88
+ x_shift=tp_min_percent,
89
+ pow=pow
90
+ )
91
+ y_shift = abs(y_max) - abs(y_min)
92
+
93
+ y_normalized = y(
94
+ x=pnl_percent_notional,
95
+ x_shift=tp_min_percent,
96
+ pow=pow
97
+ ) / y_shift
98
+ effective_tp_trailing_percent = (
99
+ y_normalized * sl_percent_trailing + sl_percent_trailing
100
+ if pnl_percent_notional>=tp_min_percent
101
+ else default_effective_tp_trailing_percent
102
+ )
70
103
  return effective_tp_trailing_percent
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siglab-py
3
- Version: 0.5.5
3
+ Version: 0.5.6
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -32,8 +32,8 @@ siglab_py/util/market_data_util.py,sha256=mUXg4uaiX3b6_klgJWIEgnUQU4IUd6CwTOqKLi
32
32
  siglab_py/util/notification_util.py,sha256=vySgHjpHgwFDLW0tHSi_AGh9JBbPc25IUgvWxmjAeT8,2658
33
33
  siglab_py/util/retry_util.py,sha256=g-UU6pkPouWZZRZEqP99R2Z0lX5xzckYkzjwqqSDpVQ,922
34
34
  siglab_py/util/slack_notification_util.py,sha256=G27n-adbT3Q6oaHSMvu_Nom794rrda5PprSF-zvmzkM,1912
35
- siglab_py/util/trading_util.py,sha256=rXiBLOJGxerK1Uz1D1GBLedunTobtDCC85d42on4TYg,3321
36
- siglab_py-0.5.5.dist-info/METADATA,sha256=AiiTUyYs_Pd4mAgZexM9fLJ-AMW1uFfBYTDZ-jJzAQw,979
37
- siglab_py-0.5.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
38
- siglab_py-0.5.5.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
- siglab_py-0.5.5.dist-info/RECORD,,
35
+ siglab_py/util/trading_util.py,sha256=-LmjQmYRF9SpscGIajZ3_iVs02U28kKHv-xWkRT6Jwk,4363
36
+ siglab_py-0.5.6.dist-info/METADATA,sha256=KQBKtDwAg_4VANLd-w94rpv5Lv_p3BGnoGSRixHzxAo,979
37
+ siglab_py-0.5.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
38
+ siglab_py-0.5.6.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
+ siglab_py-0.5.6.dist-info/RECORD,,