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

@@ -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
- default_effective_tp_percent_trailing : float = 50
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
- default_effective_tp_percent_trailing = default_effective_tp_percent_trailing
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
- default_effective_tp_percent_trailing : float = 50
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
- default_effective_tp_percent_trailing = default_effective_tp_percent_trailing
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
- default_effective_tp_percent_trailing : float = 50
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
- default_effective_tp_percent_trailing = default_effective_tp_percent_trailing
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'] = pd_candles['close'].rolling(window=sliding_window_how_many_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['close'])))
372
- rolling_slope = pd_candles['close'].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)
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['close'])))
376
- rolling_slope = pd_candles['close'].rolling(window=sliding_window_how_many_candles).apply(lambda x: sm.OLS(x, X[:len(x)]).fit().params[1], raw=False)
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 = 0.5% (Trade starting off, only +50bps pnl. i.e. min TP)
18
- effective_tp_trailing_percent = slope * (pnl_percent_notional - 0.5%) + sl_percent_trailing
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siglab-py
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -23,16 +23,16 @@ siglab_py/tests/integration/market_data_util_tests.py,sha256=p-RWIJZLyj0lAdfi4QT
23
23
  siglab_py/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  siglab_py/tests/unit/analytic_util_tests.py,sha256=68FTWDrfXTAyFLte6wiRfwcFVJItU5F47_DebgF6hAc,3788
25
25
  siglab_py/tests/unit/market_data_util_tests.py,sha256=A1y83itISmMJdn6wLpfwcr4tGola8wTf1D1xbelMvgw,2026
26
- siglab_py/tests/unit/trading_util_tests.py,sha256=VywV-wvRBDoN7ZE6-SgUzYyyjnd6wv0HgQD2RWpkkZQ,2689
26
+ siglab_py/tests/unit/trading_util_tests.py,sha256=tyefqOTQOoXSlemSDonqmdHp61-1nuXb0_6oeLlaNSM,2689
27
27
  siglab_py/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- siglab_py/util/analytic_util.py,sha256=TunVYV4DhedRFk0dYhKdm4zh5ztGcORH8-MDBV2LLZg,44944
28
+ siglab_py/util/analytic_util.py,sha256=gEEKB0_qDbpoK7QbDAow5jm2Uo-Ij3wad9iGs1xI-KM,45225
29
29
  siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
30
30
  siglab_py/util/market_data_util.py,sha256=9Uze8DE5z90H4Qm15R55ZllAi5trUkwCAW-BWYbfaW8,19420
31
31
  siglab_py/util/notification_util.py,sha256=vySgHjpHgwFDLW0tHSi_AGh9JBbPc25IUgvWxmjAeT8,2658
32
32
  siglab_py/util/retry_util.py,sha256=mxYuRFZRZoaQQjENcwPmxhxixtd1TFvbxIdPx4RwfRc,743
33
33
  siglab_py/util/slack_notification_util.py,sha256=G27n-adbT3Q6oaHSMvu_Nom794rrda5PprSF-zvmzkM,1912
34
- siglab_py/util/trading_util.py,sha256=djE3_q6hAyFDuLMVsUmgbHZLzFxrlZHVqDcYRvM7n3c,3038
35
- siglab_py-0.3.1.dist-info/METADATA,sha256=5PVfvOBOGHHHAU_9IKXJ8_D5szXcYx87Y9dxw1xArrY,979
36
- siglab_py-0.3.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
37
- siglab_py-0.3.1.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
38
- siglab_py-0.3.1.dist-info/RECORD,,
34
+ siglab_py/util/trading_util.py,sha256=FmqsamuPhMjZUkz4lCyuE8MHFapXn6yNl8Isy7peQEs,3047
35
+ siglab_py-0.3.2.dist-info/METADATA,sha256=dbBew40mI924gqRR91kUk-hcFFZynmBDyt_PKINmorI,979
36
+ siglab_py-0.3.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
37
+ siglab_py-0.3.2.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
38
+ siglab_py-0.3.2.dist-info/RECORD,,