siglab-py 0.5.35__py3-none-any.whl → 0.5.37__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 -1
- siglab_py/util/analytic_util.py +21 -20
- siglab_py/util/notification_util.py +1 -1
- {siglab_py-0.5.35.dist-info → siglab_py-0.5.37.dist-info}/METADATA +1 -1
- {siglab_py-0.5.35.dist-info → siglab_py-0.5.37.dist-info}/RECORD +7 -7
- {siglab_py-0.5.35.dist-info → siglab_py-0.5.37.dist-info}/WHEEL +0 -0
- {siglab_py-0.5.35.dist-info → siglab_py-0.5.37.dist-info}/top_level.txt +0 -0
|
@@ -38,7 +38,7 @@ class AnalyticUtilTests(unittest.TestCase):
|
|
|
38
38
|
pd_candles=pd_candles,
|
|
39
39
|
boillenger_std_multiples=2,
|
|
40
40
|
sliding_window_how_many_candles=20,
|
|
41
|
-
pypy_compat=True
|
|
41
|
+
pypy_compat=True # Slopes calculation? Set pypy_compat to False
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
expected_columns : List[str] = [
|
siglab_py/util/analytic_util.py
CHANGED
|
@@ -141,7 +141,6 @@ def compute_candles_stats(
|
|
|
141
141
|
close_short_periods_ewm = pd_candles['close'].ewm(span=int(sliding_window_how_many_candles/slow_fast_interval_ratio), adjust=False)
|
|
142
142
|
close_long_periods_ewm = pd_candles['close'].ewm(span=sliding_window_how_many_candles, adjust=False)
|
|
143
143
|
|
|
144
|
-
|
|
145
144
|
pd_candles['pct_change_close'] = pd_candles['close'].pct_change() * 100
|
|
146
145
|
pd_candles['sma_short_periods'] = close_short_periods_rolling.mean()
|
|
147
146
|
pd_candles['sma_long_periods'] = close_long_periods_rolling.mean()
|
|
@@ -168,6 +167,8 @@ def compute_candles_stats(
|
|
|
168
167
|
pd_candles['annualized_volatility'] = (
|
|
169
168
|
pd_candles['interval_historical_volatility'] * annualization_factor
|
|
170
169
|
)
|
|
170
|
+
|
|
171
|
+
Why log return? Trading Dude https://python.plainenglish.io/stop-using-percentage-returns-logarithmic-returns-explained-with-code-64a4634b883a
|
|
171
172
|
'''
|
|
172
173
|
pd_candles['log_return'] = np.log(pd_candles['close'] / pd_candles['close'].shift(1))
|
|
173
174
|
pd_candles['interval_hist_vol'] = pd_candles['log_return'].rolling(window=sliding_window_how_many_candles).std()
|
|
@@ -203,25 +204,25 @@ def compute_candles_stats(
|
|
|
203
204
|
bearish_indices = pd.Series(pd_candles.index.where(pd_candles['ema_cross'] == -1), index=pd_candles.index).astype('Int64')
|
|
204
205
|
pd_candles['ema_bullish_cross_last_id'] = bullish_indices.rolling(window=pd_candles.shape[0], min_periods=1).max().astype('Int64')
|
|
205
206
|
pd_candles['ema_bearish_cross_last_id'] = bearish_indices.rolling(window=pd_candles.shape[0], min_periods=1).max().astype('Int64')
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
'
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
207
|
+
conditions = [
|
|
208
|
+
(pd_candles['ema_bullish_cross_last_id'].notna() &
|
|
209
|
+
pd_candles['ema_bearish_cross_last_id'].notna() &
|
|
210
|
+
(pd_candles['ema_bullish_cross_last_id'] > pd_candles['ema_bearish_cross_last_id'])),
|
|
211
|
+
|
|
212
|
+
(pd_candles['ema_bullish_cross_last_id'].notna() &
|
|
213
|
+
pd_candles['ema_bearish_cross_last_id'].notna() &
|
|
214
|
+
(pd_candles['ema_bearish_cross_last_id'] > pd_candles['ema_bullish_cross_last_id'])),
|
|
215
|
+
|
|
216
|
+
(pd_candles['ema_bullish_cross_last_id'].notna() &
|
|
217
|
+
pd_candles['ema_bearish_cross_last_id'].isna()),
|
|
218
|
+
|
|
219
|
+
(pd_candles['ema_bearish_cross_last_id'].notna() &
|
|
220
|
+
pd_candles['ema_bullish_cross_last_id'].isna())
|
|
221
|
+
]
|
|
222
|
+
choices = ['bullish', 'bearish', 'bullish', 'bearish']
|
|
223
|
+
pd_candles['ema_cross_last'] = np.select(conditions, choices, default=None) # type: ignore
|
|
224
|
+
pd_candles.loc[bullish_ema_crosses, 'ema_cross'] = 'bullish'
|
|
225
|
+
pd_candles.loc[bearish_ema_crosses, 'ema_cross'] = 'bearish'
|
|
225
226
|
|
|
226
227
|
pd_candles['max_short_periods'] = close_short_periods_rolling.max()
|
|
227
228
|
pd_candles['max_long_periods'] = close_long_periods_rolling.max()
|
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from tabulate import tabulate
|
|
7
7
|
|
|
8
|
-
from util.slack_notification_util import slack_dispatch_notification
|
|
8
|
+
from siglab_py.util.slack_notification_util import slack_dispatch_notification
|
|
9
9
|
|
|
10
10
|
from siglab_py.constants import LogLevel
|
|
11
11
|
|
|
@@ -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=9tAg7cLDEJ3ueYIQxMYMtPKtZQValKAbRfFgVY_L8dQ,4413
|
|
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=lOQoObczb6Z4AZGevKOwuSTdNVKA2QhwAKa36LrMf7w,56524
|
|
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
|
-
siglab_py/util/notification_util.py,sha256=
|
|
32
|
+
siglab_py/util/notification_util.py,sha256=tNZMUkkjz4q1CKqcQq62oEmZgHgNIwz2Iw9J22V22Zw,2668
|
|
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.37.dist-info/METADATA,sha256=jaOC_0EKsjoghv2MUr397p7alkxIUGx5WS1OHxM7_IE,829
|
|
37
|
+
siglab_py-0.5.37.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
|
38
|
+
siglab_py-0.5.37.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
|
|
39
|
+
siglab_py-0.5.37.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|