siglab-py 0.3.1__tar.gz → 0.3.2__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.3.1 → siglab_py-0.3.2}/PKG-INFO +1 -1
- {siglab_py-0.3.1 → siglab_py-0.3.2}/pyproject.toml +1 -1
- {siglab_py-0.3.1 → siglab_py-0.3.2}/setup.cfg +1 -1
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/unit/trading_util_tests.py +6 -6
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/analytic_util.py +8 -5
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/trading_util.py +3 -3
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py.egg-info/PKG-INFO +1 -1
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/constants.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/exchanges/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/exchanges/any_exchange.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/exchanges/futubull.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/aggregated_orderbook_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/candles_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/candles_ta_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/deribit_options_expiry_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/orderbooks_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/test_provider.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/ordergateway/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/ordergateway/client.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/ordergateway/encrypt_keys_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/ordergateway/gateway.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/ordergateway/test_ordergateway.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/integration/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/integration/market_data_util_tests.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/unit/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/unit/analytic_util_tests.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/tests/unit/market_data_util_tests.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/__init__.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/aws_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/market_data_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/notification_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/retry_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/util/slack_notification_util.py +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py.egg-info/SOURCES.txt +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py.egg-info/dependency_links.txt +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py.egg-info/requires.txt +0 -0
- {siglab_py-0.3.1 → siglab_py-0.3.2}/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.3.
|
|
7
|
+
version = "0.3.2"
|
|
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"}
|
|
@@ -12,7 +12,7 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
12
12
|
tp_min_percent : float = 1.5
|
|
13
13
|
tp_max_percent : float = 2.5
|
|
14
14
|
sl_percent_trailing : float = 50 # Trailing stop loss in percent
|
|
15
|
-
|
|
15
|
+
default_effective_tp_trailing_percent : float = 50
|
|
16
16
|
|
|
17
17
|
pnl_percent_notional : float = 0.5 # Trade's current pnl in percent.
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
21
21
|
tp_max_percent = tp_max_percent,
|
|
22
22
|
sl_percent_trailing = sl_percent_trailing,
|
|
23
23
|
pnl_percent_notional = pnl_percent_notional,
|
|
24
|
-
|
|
24
|
+
default_effective_tp_trailing_percent = default_effective_tp_trailing_percent
|
|
25
25
|
)
|
|
26
26
|
assert(effective_tp_trailing_percent==50) # Generous trailing SL when trading starting out and pnl small.
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
29
29
|
tp_min_percent : float = 1.5
|
|
30
30
|
tp_max_percent : float = 2.5
|
|
31
31
|
sl_percent_trailing : float = 50 # Trailing stop loss in percent
|
|
32
|
-
|
|
32
|
+
default_effective_tp_trailing_percent : float = 50
|
|
33
33
|
|
|
34
34
|
pnl_percent_notional : float = 2 # Trade's current pnl in percent.
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
38
38
|
tp_max_percent = tp_max_percent,
|
|
39
39
|
sl_percent_trailing = sl_percent_trailing,
|
|
40
40
|
pnl_percent_notional = pnl_percent_notional,
|
|
41
|
-
|
|
41
|
+
default_effective_tp_trailing_percent = default_effective_tp_trailing_percent
|
|
42
42
|
)
|
|
43
43
|
assert(effective_tp_trailing_percent==25) # Intermediate trailing SL
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
46
46
|
tp_min_percent : float = 1.5
|
|
47
47
|
tp_max_percent : float = 2.5
|
|
48
48
|
sl_percent_trailing : float = 50 # Trailing stop loss in percent
|
|
49
|
-
|
|
49
|
+
default_effective_tp_trailing_percent : float = 50
|
|
50
50
|
|
|
51
51
|
pnl_percent_notional : float = 2.5 # Trade's current pnl in percent.
|
|
52
52
|
|
|
@@ -55,6 +55,6 @@ class TradingUtilTests(unittest.TestCase):
|
|
|
55
55
|
tp_max_percent = tp_max_percent,
|
|
56
56
|
sl_percent_trailing = sl_percent_trailing,
|
|
57
57
|
pnl_percent_notional = pnl_percent_notional,
|
|
58
|
-
|
|
58
|
+
default_effective_tp_trailing_percent = default_effective_tp_trailing_percent
|
|
59
59
|
)
|
|
60
60
|
assert(effective_tp_trailing_percent==0) # Most tight trailing SL
|
|
@@ -98,10 +98,13 @@ def compute_candles_stats(
|
|
|
98
98
|
pd_candles['ema_short_periods'] = close_short_periods_ewm.mean()
|
|
99
99
|
pd_candles['ema_long_periods'] = close_long_periods_ewm.mean()
|
|
100
100
|
pd_candles['ema_close'] = pd_candles['ema_long_periods'] # Alias, shorter name
|
|
101
|
-
pd_candles['std'] =
|
|
101
|
+
pd_candles['std'] = close_long_periods_rolling.std()
|
|
102
102
|
|
|
103
103
|
pd_candles['std_percent'] = pd_candles['std'] / pd_candles['ema_close'] * 100
|
|
104
104
|
|
|
105
|
+
pd_candles['normalized_close_short'] = (pd_candles['close'] - pd_candles['sma_short_periods']) / close_short_periods_rolling.std()
|
|
106
|
+
pd_candles['normalized_close_long'] = (pd_candles['close'] - pd_candles['sma_long_periods']) / pd_candles['std']
|
|
107
|
+
|
|
105
108
|
pd_candles['candle_height_percent'] = pd_candles['candle_height'] / pd_candles['ema_close'] * 100
|
|
106
109
|
pd_candles['candle_height_percent_rounded'] = pd_candles['candle_height_percent'].round().astype('Int64')
|
|
107
110
|
|
|
@@ -368,12 +371,12 @@ def compute_candles_stats(
|
|
|
368
371
|
import statsmodels.api as sm # in-compatible with pypy
|
|
369
372
|
|
|
370
373
|
# Slopes
|
|
371
|
-
X = sm.add_constant(range(len(pd_candles['
|
|
372
|
-
rolling_slope = pd_candles['
|
|
374
|
+
X = sm.add_constant(range(len(pd_candles['normalized_close_short'])))
|
|
375
|
+
rolling_slope = pd_candles['normalized_close_short'].rolling(window=int(sliding_window_how_many_candles/slow_fast_interval_ratio)).apply(lambda x: sm.OLS(x, X[:len(x)]).fit().params[1], raw=False)
|
|
373
376
|
pd_candles['close_short_slope'] = rolling_slope
|
|
374
377
|
|
|
375
|
-
X = sm.add_constant(range(len(pd_candles['
|
|
376
|
-
rolling_slope = pd_candles['
|
|
378
|
+
X = sm.add_constant(range(len(pd_candles['normalized_close_long'])))
|
|
379
|
+
rolling_slope = pd_candles['normalized_close_long'].rolling(window=sliding_window_how_many_candles).apply(lambda x: sm.OLS(x, X[:len(x)]).fit().params[1], raw=False)
|
|
377
380
|
pd_candles['close_long_slope'] = rolling_slope
|
|
378
381
|
|
|
379
382
|
X = sm.add_constant(range(len(pd_candles['ema_short_periods'])))
|
|
@@ -11,11 +11,11 @@ Examples,
|
|
|
11
11
|
min TP = 1.5% <-- min TP
|
|
12
12
|
max TP = 2.5% <-- max TP
|
|
13
13
|
|
|
14
|
-
slope = (0-50)/(2.5-1.5) = -50
|
|
14
|
+
slope = (0-50)/(2.5-1.5) = -50/+1 = -50
|
|
15
15
|
effective_tp_trailing_percent = slope * (pnl_percent_notional - 1.5%) + sl_percent_trailing
|
|
16
16
|
|
|
17
|
-
Case 1. pnl_percent_notional =
|
|
18
|
-
effective_tp_trailing_percent = slope * (pnl_percent_notional -
|
|
17
|
+
Case 1. pnl_percent_notional = 1.5% (Trade starting off, only +50bps pnl. i.e. min TP)
|
|
18
|
+
effective_tp_trailing_percent = slope * (pnl_percent_notional - 1.5%) + sl_percent_trailing
|
|
19
19
|
= -50 * (1.5-1.5) + 50%
|
|
20
20
|
= 0 + 50
|
|
21
21
|
= 50% (Most loose)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/aggregated_orderbook_provider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{siglab_py-0.3.1 → siglab_py-0.3.2}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py
RENAMED
|
File without changes
|
|
File without changes
|
{siglab_py-0.3.1 → siglab_py-0.3.2}/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
|