siglab-py 0.5.9__tar.gz → 0.5.11__tar.gz
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-0.5.9 → siglab_py-0.5.11}/PKG-INFO +1 -1
- {siglab_py-0.5.9 → siglab_py-0.5.11}/pyproject.toml +1 -1
- {siglab_py-0.5.9 → siglab_py-0.5.11}/setup.cfg +1 -1
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/unit/trading_util_tests.py +22 -1
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/trading_util.py +32 -10
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py.egg-info/PKG-INFO +1 -1
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/constants.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/exchanges/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/exchanges/any_exchange.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/exchanges/futubull.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/aggregated_orderbook_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/candles_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/candles_ta_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/deribit_options_expiry_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/orderbooks_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/test_provider.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/tg_monitor.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/ordergateway/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/ordergateway/client.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/ordergateway/encrypt_keys_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/ordergateway/gateway.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/ordergateway/test_ordergateway.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/integration/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/integration/market_data_util_tests.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/unit/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/unit/analytic_util_tests.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/tests/unit/market_data_util_tests.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/__init__.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/analytic_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/aws_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/market_data_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/notification_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/retry_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/util/slack_notification_util.py +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py.egg-info/SOURCES.txt +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py.egg-info/dependency_links.txt +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py.egg-info/requires.txt +0 -0
- {siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "siglab_py"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.11"
|
|
8
8
|
description = "Market data fetches, TA calculations and generic order gateway."
|
|
9
9
|
authors = [{name = "r0bbarh00d", email = "r0bbarh00d@gmail.com"}]
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -62,4 +62,25 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
62
62
|
pnl_percent_notional = pnl_percent_notional,
|
|
63
63
|
default_effective_tp_trailing_percent = default_effective_tp_trailing_percent
|
|
64
64
|
)
|
|
65
|
-
assert(effective_tp_trailing_percent==0) # Most tight trailing SL
|
|
65
|
+
assert(effective_tp_trailing_percent==0) # Most tight trailing SL
|
|
66
|
+
|
|
67
|
+
def test_round_to_level(self):
|
|
68
|
+
prices = [
|
|
69
|
+
{ 'price' : 15080, 'rounded' : 15000},
|
|
70
|
+
{ 'price' : 15180, 'rounded' : 15200},
|
|
71
|
+
{ 'price' : 25080, 'rounded' : 25200},
|
|
72
|
+
{ 'price' : 25180, 'rounded' : 25200},
|
|
73
|
+
{ 'price' : 25380, 'rounded' : 25500},
|
|
74
|
+
{ 'price' : 95332, 'rounded' : 95000},
|
|
75
|
+
{ 'price' : 95878, 'rounded' : 96000},
|
|
76
|
+
{ 'price' : 103499, 'rounded' : 103000},
|
|
77
|
+
{ 'price' : 103500, 'rounded' : 104000},
|
|
78
|
+
{ 'price' : 150800, 'rounded' : 150000},
|
|
79
|
+
{ 'price' : 151800, 'rounded' : 152000}
|
|
80
|
+
]
|
|
81
|
+
for entry in prices:
|
|
82
|
+
price = entry['price']
|
|
83
|
+
expected = entry['rounded']
|
|
84
|
+
rounded_price = round_to_level(price, level_granularity=0.01)
|
|
85
|
+
print(f"{price} rounded to: {rounded_price}")
|
|
86
|
+
assert(rounded_price==expected)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import math
|
|
1
2
|
|
|
2
3
|
'''
|
|
3
4
|
pnl_percent_notional = Trade's current pnl in percent.
|
|
@@ -95,14 +96,35 @@ def calc_eff_trailing_sl(
|
|
|
95
96
|
)
|
|
96
97
|
y_shift = abs(y_max) - abs(y_min)
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
if y_shift!=0:
|
|
100
|
+
y_normalized = y(
|
|
101
|
+
x=pnl_percent_notional,
|
|
102
|
+
x_shift=tp_min_percent,
|
|
103
|
+
pow=pow
|
|
104
|
+
) / y_shift
|
|
105
|
+
effective_tp_trailing_percent = (
|
|
106
|
+
y_normalized * sl_percent_trailing + sl_percent_trailing
|
|
107
|
+
if pnl_percent_notional>=tp_min_percent
|
|
108
|
+
else default_effective_tp_trailing_percent
|
|
109
|
+
)
|
|
110
|
+
else:
|
|
111
|
+
'''
|
|
112
|
+
y_shift = 0 when tp_max_percent==tp_min_percent.
|
|
113
|
+
If default_effective_tp_trailing_percent==float('inf'), essentially it means trailing stops won't fire.
|
|
114
|
+
Client side needs handle this.
|
|
115
|
+
'''
|
|
116
|
+
effective_tp_trailing_percent = default_effective_tp_trailing_percent
|
|
117
|
+
|
|
108
118
|
return effective_tp_trailing_percent
|
|
119
|
+
|
|
120
|
+
# https://norman-lm-fung.medium.com/levels-are-psychological-7176cdefb5f2
|
|
121
|
+
def round_to_level(
|
|
122
|
+
price : float,
|
|
123
|
+
level_granularity : float = 0.01
|
|
124
|
+
) -> float:
|
|
125
|
+
level_size = price * level_granularity
|
|
126
|
+
magnitude = math.floor(math.log10(level_size))
|
|
127
|
+
base_increment = 10 ** magnitude
|
|
128
|
+
rounded_level_size = round(level_size / base_increment) * base_increment
|
|
129
|
+
rounded_price = round(price / rounded_level_size) * rounded_level_size
|
|
130
|
+
return rounded_price
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py
RENAMED
|
File without changes
|
|
File without changes
|
{siglab_py-0.5.9 → siglab_py-0.5.11}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|