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

@@ -83,7 +83,8 @@ def compute_candles_stats(
83
83
  rsi_ema : bool = True,
84
84
  boillenger_ema : bool = False,
85
85
  slow_fast_interval_ratio : float = 3,
86
- rsi_sliding_window_how_many_candles : Union[int, None] = None, # RSI standard 14
86
+ rsi_sliding_window_how_many_candles : int = 14, # RSI standard 14
87
+ rsi_trend_sliding_window_how_many_candles : int = 24*7, # This is for purpose of RSI trend identification (Locating local peaks/troughs in RSI). This should typically be multiples of 'rsi_sliding_window_how_many_candles'.
87
88
  hurst_exp_window_how_many_candles : Union[int, None] = None, # Hurst exp standard 100-200
88
89
  boillenger_std_multiples_for_aggressive_moves_detect : int = 3, # Aggressive moves if candle low/high breaches boillenger bands from 3 standard deviations.
89
90
  target_fib_level : float = 0.618,
@@ -346,9 +347,9 @@ def compute_candles_stats(
346
347
  if rsi_ema == True:
347
348
  # Use exponential moving average
348
349
  lo_ma_up = lo_up.ewm(
349
- com = (rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles) - 1,
350
+ com = rsi_sliding_window_how_many_candles -1,
350
351
  adjust=True,
351
- min_periods = rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles).mean()
352
+ min_periods = rsi_sliding_window_how_many_candles).mean()
352
353
  lo_ma_down = lo_down.ewm(
353
354
  com = (rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles) - 1,
354
355
  adjust=True,
@@ -356,16 +357,16 @@ def compute_candles_stats(
356
357
 
357
358
  else:
358
359
  # Use simple moving average
359
- lo_ma_up = lo_up.rolling(window = rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles).mean()
360
- lo_ma_down = lo_down.rolling(window = rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles).mean()
360
+ lo_ma_up = lo_up.rolling(window = rsi_sliding_window_how_many_candles).mean()
361
+ lo_ma_down = lo_down.rolling(window = rsi_sliding_window_how_many_candles).mean()
361
362
 
362
363
  lo_rs = lo_ma_up / lo_ma_down
363
364
  pd_candles.loc[:,'rsi'] = 100 - (100/(1 + lo_rs))
364
365
  pd_candles['ema_rsi'] = pd_candles['rsi'].ewm(
365
- span=rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles,
366
+ span=rsi_sliding_window_how_many_candles,
366
367
  adjust=False).mean()
367
368
 
368
- rsi_rolling = pd_candles['rsi'].rolling(window=int(rsi_sliding_window_how_many_candles if rsi_sliding_window_how_many_candles else sliding_window_how_many_candles))
369
+ rsi_rolling = pd_candles['rsi'].rolling(window=int(rsi_trend_sliding_window_how_many_candles))
369
370
  pd_candles['rsi_max'] = rsi_rolling.max()
370
371
  pd_candles['rsi_idmax'] = rsi_rolling.apply(lambda x : x.idxmax())
371
372
  pd_candles['rsi_min'] = rsi_rolling.min()
@@ -375,6 +376,8 @@ def compute_candles_stats(
375
376
  row,
376
377
  rsi_upper_threshold : float = 70,
377
378
  rsi_lower_threshold : float = 30):
379
+ if pd.isna(row['rsi_idmax']) or pd.isna(row['rsi_idmin']):
380
+ return np.nan
378
381
  if row['rsi_idmax'] > row['rsi_idmin']:
379
382
  return 'down' if row.name > row['rsi_idmax'] and row['rsi'] <= rsi_upper_threshold else 'up'
380
383
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: siglab_py
3
- Version: 0.5.18
3
+ Version: 0.5.20
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -26,14 +26,14 @@ siglab_py/tests/unit/analytic_util_tests.py,sha256=vt6DKH-Flf9Og3gqivZ9W-sz5z-Kc
26
26
  siglab_py/tests/unit/market_data_util_tests.py,sha256=A1y83itISmMJdn6wLpfwcr4tGola8wTf1D1xbelMvgw,2026
27
27
  siglab_py/tests/unit/trading_util_tests.py,sha256=9DZmTZlW55lPtNfTCukgDdiyBiMYv9R4mEFWJIJiTNg,3870
28
28
  siglab_py/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- siglab_py/util/analytic_util.py,sha256=gA3kj-C18sqG1DGf6cr-6dx3DPERfpDtzv08ZIFO49A,49107
29
+ siglab_py/util/analytic_util.py,sha256=Do_H30Dt-ISTPnNQ6JcLhBnIgvu3NGV6WYGWnplvgtY,48965
30
30
  siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
31
31
  siglab_py/util/market_data_util.py,sha256=mUXg4uaiX3b6_klgJWIEgnUQU4IUd6CwTOqKLiQWRlU,31307
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
35
  siglab_py/util/trading_util.py,sha256=-TGNgJdy4HMDPgq31KQn_lRawFxuXnFU5NnLRb1XM5o,5757
36
- siglab_py-0.5.18.dist-info/METADATA,sha256=M5SseNFH6bf_4JDo33YDDsVibWmvxi30sZZRlT4400I,829
37
- siglab_py-0.5.18.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
38
- siglab_py-0.5.18.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
- siglab_py-0.5.18.dist-info/RECORD,,
36
+ siglab_py-0.5.20.dist-info/METADATA,sha256=05smcq4TjV5yqXk9cI6GwzA2-4eDf2YQx7VYDJmNVVg,829
37
+ siglab_py-0.5.20.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
38
+ siglab_py-0.5.20.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
+ siglab_py-0.5.20.dist-info/RECORD,,