siglab-py 0.5.5__py3-none-any.whl → 0.5.7__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.
- siglab_py/market_data_providers/tg_monitor.py +2 -2
- siglab_py/util/trading_util.py +43 -7
- {siglab_py-0.5.5.dist-info → siglab_py-0.5.7.dist-info}/METADATA +1 -1
- {siglab_py-0.5.5.dist-info → siglab_py-0.5.7.dist-info}/RECORD +6 -6
- {siglab_py-0.5.5.dist-info → siglab_py-0.5.7.dist-info}/WHEEL +0 -0
- {siglab_py-0.5.5.dist-info → siglab_py-0.5.7.dist-info}/top_level.txt +0 -0
|
@@ -410,10 +410,10 @@ async def main() -> None:
|
|
|
410
410
|
log(f"No messages processed in this iteration. last_message_date: {last_message_date}", LogLevel.INFO)
|
|
411
411
|
last_message_date = last_message_date + timedelta(days=1)
|
|
412
412
|
|
|
413
|
-
await asyncio.sleep(int(param['loop_freq_ms'] / 1000))
|
|
414
|
-
|
|
415
413
|
except Exception as e:
|
|
416
414
|
log(f"Oops {str(e)} {str(sys.exc_info()[0])} {str(sys.exc_info()[1])} {traceback.format_exc()}", LogLevel.ERROR)
|
|
415
|
+
finally:
|
|
416
|
+
await asyncio.sleep(int(param['loop_freq_ms'] / 1000))
|
|
417
417
|
|
|
418
418
|
if __name__ == '__main__':
|
|
419
419
|
try:
|
siglab_py/util/trading_util.py
CHANGED
|
@@ -59,12 +59,48 @@ 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 =
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
if pnl_percent_notional>tp_max_percent:
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
if linear:
|
|
70
|
+
slope = (0 - sl_percent_trailing) / (tp_max_percent - tp_min_percent)
|
|
71
|
+
effective_tp_trailing_percent = (
|
|
72
|
+
slope * (pnl_percent_notional - tp_min_percent) + sl_percent_trailing
|
|
73
|
+
if pnl_percent_notional>=tp_min_percent
|
|
74
|
+
else default_effective_tp_trailing_percent
|
|
75
|
+
)
|
|
76
|
+
else:
|
|
77
|
+
def y(
|
|
78
|
+
x : float,
|
|
79
|
+
x_shift : float,
|
|
80
|
+
pow : float
|
|
81
|
+
) -> float:
|
|
82
|
+
return -1 * ( (x+x_shift)**pow)
|
|
83
|
+
|
|
84
|
+
y_min = y(
|
|
85
|
+
x=tp_min_percent,
|
|
86
|
+
x_shift=tp_min_percent,
|
|
87
|
+
pow=pow
|
|
88
|
+
)
|
|
89
|
+
y_max = y(
|
|
90
|
+
x=tp_max_percent,
|
|
91
|
+
x_shift=tp_min_percent,
|
|
92
|
+
pow=pow
|
|
93
|
+
)
|
|
94
|
+
y_shift = abs(y_max) - abs(y_min)
|
|
95
|
+
|
|
96
|
+
y_normalized = y(
|
|
97
|
+
x=pnl_percent_notional,
|
|
98
|
+
x_shift=tp_min_percent,
|
|
99
|
+
pow=pow
|
|
100
|
+
) / y_shift
|
|
101
|
+
effective_tp_trailing_percent = (
|
|
102
|
+
y_normalized * sl_percent_trailing + sl_percent_trailing
|
|
103
|
+
if pnl_percent_notional>=tp_min_percent
|
|
104
|
+
else default_effective_tp_trailing_percent
|
|
105
|
+
)
|
|
70
106
|
return effective_tp_trailing_percent
|
|
@@ -12,7 +12,7 @@ siglab_py/market_data_providers/deribit_options_expiry_provider.py,sha256=e9Ee8T
|
|
|
12
12
|
siglab_py/market_data_providers/futu_candles_ta_to_csv.py,sha256=S4GXaJ7AveEh-Cm9-VhENBdlj_1CfyBTrQO7acTqfUE,10226
|
|
13
13
|
siglab_py/market_data_providers/orderbooks_provider.py,sha256=olt-3LIkoyzQWfNNQRhJtKibLbkTutt_q_rCCTM7i1g,16216
|
|
14
14
|
siglab_py/market_data_providers/test_provider.py,sha256=wBLCgcWjs7FGZJXWsNyn30lkOLa_cgpuvqRakMC0wbA,2221
|
|
15
|
-
siglab_py/market_data_providers/tg_monitor.py,sha256=
|
|
15
|
+
siglab_py/market_data_providers/tg_monitor.py,sha256=ryS8cK2Yh7BatsnjTTw1z49TVvUZW5yP5-ja-D-SSKc,21826
|
|
16
16
|
siglab_py/ordergateway/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
siglab_py/ordergateway/client.py,sha256=LvtrYirrdFOcKgTkvuqwdEN7r3nurjX320ESnk7tHE0,15095
|
|
18
18
|
siglab_py/ordergateway/encrypt_keys_util.py,sha256=-qi87db8To8Yf1WS1Q_Cp2Ya7ZqgWlRqSHfNXCM7wE4,1339
|
|
@@ -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=
|
|
36
|
-
siglab_py-0.5.
|
|
37
|
-
siglab_py-0.5.
|
|
38
|
-
siglab_py-0.5.
|
|
39
|
-
siglab_py-0.5.
|
|
35
|
+
siglab_py/util/trading_util.py,sha256=LGDnI688Dy04G6shVvZzjjPdb7v8lPLCevkWmgm7QEw,4440
|
|
36
|
+
siglab_py-0.5.7.dist-info/METADATA,sha256=BmL4Zsl0sHiV6Pz5g1-ZqN-oSpqe518ydZySpC657Og,979
|
|
37
|
+
siglab_py-0.5.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
38
|
+
siglab_py-0.5.7.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
|
|
39
|
+
siglab_py-0.5.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|