siglab-py 0.5.28__py3-none-any.whl → 0.5.29__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.
- siglab_py/tests/unit/analytic_util_tests.py +1 -0
- siglab_py/util/analytic_util.py +34 -0
- {siglab_py-0.5.28.dist-info → siglab_py-0.5.29.dist-info}/METADATA +1 -1
- {siglab_py-0.5.28.dist-info → siglab_py-0.5.29.dist-info}/RECORD +6 -6
- {siglab_py-0.5.28.dist-info → siglab_py-0.5.29.dist-info}/WHEEL +0 -0
- {siglab_py-0.5.28.dist-info → siglab_py-0.5.29.dist-info}/top_level.txt +0 -0
|
@@ -55,6 +55,7 @@ class AnalyticUtilTests(unittest.TestCase):
|
|
|
55
55
|
'log_return', 'interval_hist_vol', 'annualized_hist_vol',
|
|
56
56
|
'chop_against_ema',
|
|
57
57
|
'ema_volume_short_periods', 'ema_volume_long_periods',
|
|
58
|
+
'ema_cross', 'ema_cross_last', 'ema_bullish_cross_last_id', 'ema_bearish_cross_last_id',
|
|
58
59
|
'max_short_periods', 'max_long_periods', 'idmax_short_periods', 'idmax_long_periods', 'min_short_periods', 'min_long_periods', 'idmin_short_periods', 'idmin_long_periods',
|
|
59
60
|
'price_swing_short_periods', 'price_swing_long_periods',
|
|
60
61
|
'trend_from_highs_long_periods', 'trend_from_lows_long_periods', 'trend_from_highs_short_periods', 'trend_from_lows_short_periods',
|
siglab_py/util/analytic_util.py
CHANGED
|
@@ -187,6 +187,40 @@ def compute_candles_stats(
|
|
|
187
187
|
pd_candles['ema_volume_short_periods'] = pd_candles['volume'].ewm(span=sliding_window_how_many_candles/slow_fast_interval_ratio, adjust=False).mean()
|
|
188
188
|
pd_candles['ema_volume_long_periods'] = pd_candles['volume'].ewm(span=sliding_window_how_many_candles, adjust=False).mean()
|
|
189
189
|
|
|
190
|
+
pd_candles['ema_cross'] = None
|
|
191
|
+
pd_candles['ema_cross_last'] = None
|
|
192
|
+
pd_candles['ema_bullish_cross_last_id'] = None
|
|
193
|
+
pd_candles['ema_bearish_cross_last_id'] = None
|
|
194
|
+
ema_short_periods_prev = pd_candles['ema_short_periods'].shift(1)
|
|
195
|
+
ema_long_periods_prev = pd_candles['ema_long_periods'].shift(1)
|
|
196
|
+
ema_short_periods_curr = pd_candles['ema_short_periods']
|
|
197
|
+
ema_long_periods_curr = pd_candles['ema_long_periods']
|
|
198
|
+
bullish_ema_crosses = (ema_short_periods_prev <= ema_long_periods_prev) & (ema_short_periods_curr > ema_long_periods_curr)
|
|
199
|
+
bearish_ema_crosses = (ema_short_periods_prev >= ema_long_periods_prev) & (ema_short_periods_curr < ema_long_periods_curr)
|
|
200
|
+
pd_candles.loc[bullish_ema_crosses, 'ema_cross'] = 1
|
|
201
|
+
pd_candles.loc[bearish_ema_crosses, 'ema_cross'] = -1
|
|
202
|
+
pd_candles['ema_bullish_cross_last_id'] = pd_candles['ema_cross'].rolling(window=sliding_window_how_many_candles).apply(lambda x : x.idxmax())
|
|
203
|
+
pd_candles['ema_bearish_cross_last_id'] = pd_candles['ema_cross'].rolling(window=sliding_window_how_many_candles).apply(lambda x : x.idxmin())
|
|
204
|
+
pd_candles.loc[bullish_ema_crosses, 'ema_cross'] = np.where(
|
|
205
|
+
pd_candles.loc[bullish_ema_crosses, 'ema_cross']==1,
|
|
206
|
+
'bullish',
|
|
207
|
+
pd_candles.loc[bullish_ema_crosses, 'ema_cross']
|
|
208
|
+
)
|
|
209
|
+
pd_candles['ema_cross_last'] = np.where(
|
|
210
|
+
pd_candles['ema_bullish_cross_last_id'] > pd_candles['ema_bearish_cross_last_id'],
|
|
211
|
+
'bullish',
|
|
212
|
+
np.where(
|
|
213
|
+
pd_candles['ema_bearish_cross_last_id'] > pd_candles['ema_bullish_cross_last_id'],
|
|
214
|
+
'bearish',
|
|
215
|
+
None # type: ignore
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
pd_candles['ema_cross_last'] = pd_candles['ema_cross_last'].where(
|
|
220
|
+
pd_candles['ema_bullish_cross_last_id'].isnull() & pd_candles['ema_bearish_cross_last_id'].isnull(),
|
|
221
|
+
None
|
|
222
|
+
)
|
|
223
|
+
|
|
190
224
|
pd_candles['max_short_periods'] = close_short_periods_rolling.max()
|
|
191
225
|
pd_candles['max_long_periods'] = close_long_periods_rolling.max()
|
|
192
226
|
pd_candles['idmax_short_periods'] = close_short_periods_rolling.apply(lambda x : x.idxmax())
|
|
@@ -22,18 +22,18 @@ siglab_py/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
22
22
|
siglab_py/tests/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
siglab_py/tests/integration/market_data_util_tests.py,sha256=p-RWIJZLyj0lAdfi4QTIeAttCm_e8mEVWFKh4OWuogU,7189
|
|
24
24
|
siglab_py/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
siglab_py/tests/unit/analytic_util_tests.py,sha256=
|
|
25
|
+
siglab_py/tests/unit/analytic_util_tests.py,sha256=5Vic-lwuGvgLfjcP1gmrdBizMn0hXPMnixYKAF3y-fI,4366
|
|
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=
|
|
29
|
+
siglab_py/util/analytic_util.py,sha256=RlUtLPDYTMrola8Dnh5msCLzAKgIq2Ee_DzLTEoJEIM,55899
|
|
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.
|
|
37
|
-
siglab_py-0.5.
|
|
38
|
-
siglab_py-0.5.
|
|
39
|
-
siglab_py-0.5.
|
|
36
|
+
siglab_py-0.5.29.dist-info/METADATA,sha256=uTBwQ7QfJc3IYjoDCZwjvktRaKI88suhSV4DgC6Q-Ew,829
|
|
37
|
+
siglab_py-0.5.29.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
|
38
|
+
siglab_py-0.5.29.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
|
|
39
|
+
siglab_py-0.5.29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|