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

@@ -47,7 +47,7 @@ class AnalyticUtilTests(unittest.TestCase):
47
47
  'datetime', 'datetime_utc', 'year', 'month', 'day', 'hour', 'minute', 'dayofweek',
48
48
  'pct_chg_on_close', 'candle_height', 'candle_body_height',
49
49
  'week_of_month', 'apac_trading_hr', 'emea_trading_hr', 'amer_trading_hr',
50
- 'is_green', 'pct_change_close',
50
+ 'is_green', 'candle_class', 'pct_change_close',
51
51
  'sma_short_periods', 'sma_long_periods', 'ema_short_periods', 'ema_long_periods', 'ema_close',
52
52
  'std', 'std_percent',
53
53
  'vwap_short_periods', 'vwap_long_periods',
@@ -15,6 +15,33 @@ from siglab_py.util.simple_math import bucket_series, bucketize_val
15
15
  from siglab_py.util.market_data_util import fix_column_types
16
16
  from siglab_py.constants import TrendDirection
17
17
 
18
+ def classify_candle(
19
+ candle : pd.Series,
20
+ min_candle_height_ratio : float = 3
21
+ ) -> Union[str, None]:
22
+ candle_class : Union[str, None] = None
23
+ open = candle['open']
24
+ high = candle['high']
25
+ low = candle['low']
26
+ close = candle['close']
27
+ candle_full_height = high - low # always positive
28
+ candle_body_height = close - open # can be negative
29
+ candle_height_ratio = candle_full_height / abs(candle_body_height) if candle_body_height!=0 else float('inf')
30
+
31
+ if (
32
+ candle_height_ratio>=min_candle_height_ratio
33
+ and close>low
34
+ ):
35
+ candle_class = 'hammer'
36
+ elif (
37
+ candle_height_ratio>=min_candle_height_ratio
38
+ and close<high
39
+ ):
40
+ candle_class = 'shooting_star'
41
+ # Keep add more ...
42
+
43
+ return candle_class
44
+
18
45
  # Fibonacci
19
46
  MAGIC_FIB_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.00, 1.618, 2.618, 3.618, 4.236]
20
47
 
@@ -145,6 +172,8 @@ def compute_candles_stats(
145
172
 
146
173
  pd_candles['is_green'] = pd_candles['close'] >= pd_candles['open']
147
174
 
175
+ pd_candles['candle_class'] = pd_candles.apply(lambda row: classify_candle(row), axis=1)
176
+
148
177
  close_short_periods_rolling = pd_candles['close'].rolling(window=int(sliding_window_how_many_candles/slow_fast_interval_ratio))
149
178
  close_long_periods_rolling = pd_candles['close'].rolling(window=sliding_window_how_many_candles)
150
179
  close_short_periods_ewm = pd_candles['close'].ewm(span=int(sliding_window_how_many_candles/slow_fast_interval_ratio), adjust=False)
@@ -447,7 +476,7 @@ def compute_candles_stats(
447
476
  mitigated = pd_candles.iloc[idx + 1:row.name]['close'].lt(row['fvg_high']).any()
448
477
  return mitigated
449
478
 
450
- pd_candles['fvg_mitigated'] = pd_candles.apply(lambda row: compute_fvg_mitigated(row, pd_candles), axis=1)
479
+ pd_candles['fvg_mitigated'] = pd_candles.apply(lambda row: compute_fvg_mitigated(row, pd_candles), axis=1) # type: ignore
451
480
 
452
481
  '''
453
482
  RSI
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: siglab_py
3
- Version: 0.5.73
3
+ Version: 0.5.78
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,12 +23,12 @@ siglab_py/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  siglab_py/tests/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  siglab_py/tests/integration/market_data_util_tests.py,sha256=XKO8CX9AF7xRjRvt4lb938v_s89d2IBLAXKfZDdUxdY,8705
25
25
  siglab_py/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- siglab_py/tests/unit/analytic_util_tests.py,sha256=wbasww0ZN9Kb-6e8V_q4o4hpstzVBvQ6Bop_0HZQUtw,5926
26
+ siglab_py/tests/unit/analytic_util_tests.py,sha256=tV7MsItlidwqdAQ_kD1000PsG4zIoQyQY1RdOn5XQAQ,5942
27
27
  siglab_py/tests/unit/market_data_util_tests.py,sha256=A1y83itISmMJdn6wLpfwcr4tGola8wTf1D1xbelMvgw,2026
28
28
  siglab_py/tests/unit/simple_math_tests.py,sha256=rWqq93W4Vlqmu0UeZCmSOfLirr0gPh2ASVIZ8O77qXY,9653
29
29
  siglab_py/tests/unit/trading_util_tests.py,sha256=LiflZrduWXyLMbpSFQCaydA7jdJx3vFR-3KuKRRGhjQ,2927
30
30
  siglab_py/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- siglab_py/util/analytic_util.py,sha256=ywp-VI8UlmoYVej2SaJMrOyheFwyh9KVjsnfw55dpMU,63785
31
+ siglab_py/util/analytic_util.py,sha256=tm5DNoy71uCnZy5d4V62dCz_WqnZbTSHQNCfwLoKjYg,64708
32
32
  siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
33
33
  siglab_py/util/market_data_util.py,sha256=udu7EN8wsESznoA68HBBKlMqZdv66FkQaRCketoFhfo,33165
34
34
  siglab_py/util/notification_util.py,sha256=tNZMUkkjz4q1CKqcQq62oEmZgHgNIwz2Iw9J22V22Zw,2668
@@ -36,7 +36,7 @@ siglab_py/util/retry_util.py,sha256=g-UU6pkPouWZZRZEqP99R2Z0lX5xzckYkzjwqqSDpVQ,
36
36
  siglab_py/util/simple_math.py,sha256=F7vGj0O2Y9EAGcMFR6SN1tTjBWO_a7YZeiTzk3eHaVI,8518
37
37
  siglab_py/util/slack_notification_util.py,sha256=G27n-adbT3Q6oaHSMvu_Nom794rrda5PprSF-zvmzkM,1912
38
38
  siglab_py/util/trading_util.py,sha256=dlIOzoMGnddLSFODcJ61EBH1Aeruq4IT2MsxIdFkV9I,5252
39
- siglab_py-0.5.73.dist-info/METADATA,sha256=HirdcX03gRL8bt7NPykg2WqZSA1vsi5Q3GXDGR7UR30,829
40
- siglab_py-0.5.73.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- siglab_py-0.5.73.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
42
- siglab_py-0.5.73.dist-info/RECORD,,
39
+ siglab_py-0.5.78.dist-info/METADATA,sha256=pq3mYKI0HpMbxfuQBljClBHZAWM0LZdnckv30nkgr5Y,829
40
+ siglab_py-0.5.78.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ siglab_py-0.5.78.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
42
+ siglab_py-0.5.78.dist-info/RECORD,,