virgo-modules 0.2.8__tar.gz → 0.2.10__tar.gz
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 virgo-modules might be problematic. Click here for more details.
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/PKG-INFO +1 -18
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/setup.py +4 -4
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/re_utils.py +19 -6
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/ticketer_source.py +18 -3
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -18
- virgo_modules-0.2.10/virgo_app/virgo_modules.egg-info/requires.txt +3 -0
- virgo_modules-0.2.8/virgo_app/virgo_modules.egg-info/requires.txt +0 -20
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/LICENSE +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/README.md +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/setup.cfg +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/backtester.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/edge_utils.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/hmm_utils.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/transformer_utils.py +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: virgo_modules
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: data processing and statistical modeling using stock market data
|
|
5
5
|
Home-page: https://github.com/miguelmayhem92/virgo_module
|
|
6
6
|
Author: Miguel Mayhuire
|
|
@@ -12,23 +12,6 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.9, <3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: feature-engine==1.6.1
|
|
16
|
-
Requires-Dist: matplotlib==3.6.3
|
|
17
|
-
Requires-Dist: mlflow==2.1.1
|
|
18
|
-
Requires-Dist: numpy==1.23.5
|
|
19
|
-
Requires-Dist: optuna==3.1.0
|
|
20
|
-
Requires-Dist: pandas==1.5.3
|
|
21
|
-
Requires-Dist: plotly==5.15.0
|
|
22
|
-
Requires-Dist: rsa==4.9
|
|
23
|
-
Requires-Dist: scikit-learn==1.2.1
|
|
24
|
-
Requires-Dist: scipy==1.10.0
|
|
25
|
-
Requires-Dist: seaborn==0.12.2
|
|
26
|
-
Requires-Dist: starlette==0.22.0
|
|
27
|
-
Requires-Dist: statsmodels==0.13.5
|
|
28
|
-
Requires-Dist: ta==0.10.2
|
|
29
|
-
Requires-Dist: yfinance==0.2.9
|
|
30
|
-
Requires-Dist: hmmlearn==0.3.0
|
|
31
|
-
Requires-Dist: boto3
|
|
32
15
|
Provides-Extra: dev
|
|
33
16
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
34
17
|
|
|
@@ -5,7 +5,7 @@ with open("virgo_app/README.md", "r") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="virgo_modules",
|
|
8
|
-
version="0.2.
|
|
8
|
+
version="0.2.10",
|
|
9
9
|
description="data processing and statistical modeling using stock market data",
|
|
10
10
|
package_dir={"": "virgo_app"},
|
|
11
11
|
packages=find_packages(where="virgo_app"),
|
|
@@ -20,9 +20,9 @@ setup(
|
|
|
20
20
|
"Programming Language :: Python :: 3.9",
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
22
|
],
|
|
23
|
-
install_requires=["feature-engine==1.6.1","matplotlib==3.6.3","mlflow==2.1.1","numpy==1.23.5","optuna==3.1.0","pandas==1.5.3",
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
# install_requires=["feature-engine==1.6.1","matplotlib==3.6.3","mlflow==2.1.1","numpy==1.23.5","optuna==3.1.0","pandas==1.5.3",
|
|
24
|
+
# "plotly==5.15.0","rsa==4.9","scikit-learn==1.2.1","scipy==1.10.0","seaborn==0.12.2","starlette==0.22.0","statsmodels==0.13.5",
|
|
25
|
+
# "ta==0.10.2","yfinance==0.2.9","hmmlearn==0.3.0","boto3"],
|
|
26
26
|
extras_require={
|
|
27
27
|
"dev": ["pytest>=7.0"],
|
|
28
28
|
},
|
|
@@ -1211,18 +1211,26 @@ class produce_plotly_plots:
|
|
|
1211
1211
|
if self.return_figs:
|
|
1212
1212
|
return fig, messages
|
|
1213
1213
|
|
|
1214
|
-
def produce_forecasting_plot(self,predictions):
|
|
1214
|
+
def produce_forecasting_plot(self,predictions, window=30):
|
|
1215
1215
|
"""
|
|
1216
1216
|
display forecasting plots
|
|
1217
1217
|
|
|
1218
1218
|
Parameters
|
|
1219
1219
|
----------
|
|
1220
1220
|
predictions (pd.DataFrame): asset predictions
|
|
1221
|
+
window (int): historical data to display
|
|
1221
1222
|
|
|
1222
1223
|
Returns
|
|
1223
1224
|
-------
|
|
1224
1225
|
None
|
|
1225
1226
|
"""
|
|
1227
|
+
def qs(x):
|
|
1228
|
+
return x.quantile(0.05)
|
|
1229
|
+
def qm(x):
|
|
1230
|
+
return x.quantile(0.50)
|
|
1231
|
+
def ql(x):
|
|
1232
|
+
return x.quantile(0.95)
|
|
1233
|
+
|
|
1226
1234
|
result_json_name = 'forecast_plot.json'
|
|
1227
1235
|
hmm_n_clust = self.settings['settings']['hmm']['n_clusters']
|
|
1228
1236
|
model_type = self.settings.get('model_type',False)
|
|
@@ -1238,8 +1246,6 @@ class produce_plotly_plots:
|
|
|
1238
1246
|
[{"type": "scatter"}, {"type": "scatter"}]],
|
|
1239
1247
|
subplot_titles = [f'asset returns {lags} lags', 'closing prices', 'hidden states']
|
|
1240
1248
|
)
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
1249
|
predictions = predictions[predictions.StockCode == self.ticket_name]
|
|
1244
1250
|
if len(predictions) > 1:
|
|
1245
1251
|
|
|
@@ -1255,12 +1261,18 @@ class produce_plotly_plots:
|
|
|
1255
1261
|
last_exe_prediction_date = predictions.ExecutionDate.unique()
|
|
1256
1262
|
last_date = max(last_exe_prediction_date)
|
|
1257
1263
|
|
|
1258
|
-
history =
|
|
1264
|
+
history = self.data_frame.sort_values('Date').iloc[-window:,:]
|
|
1259
1265
|
cut_date = history.loc[history.iloc[-1:,:].index[0]:,'Date'].item()
|
|
1260
|
-
|
|
1261
1266
|
prediction = predictions[predictions.Type == 'Prediction']
|
|
1262
1267
|
|
|
1263
1268
|
## log returns
|
|
1269
|
+
def add_intervals(data,feature,i,w=5):
|
|
1270
|
+
df_qs = data.sort_values('Date')[['Date',feature]].rolling(3,min_periods = 1,on='Date').apply(qs).groupby('Date',as_index=False)[feature].max()
|
|
1271
|
+
df_qm = data.sort_values('Date')[['Date',feature]].rolling(3,min_periods = 1,on='Date').apply(qm).groupby('Date',as_index=False)[feature].max()
|
|
1272
|
+
df_ql = data.sort_values('Date')[['Date',feature]].rolling(3,min_periods = 1,on='Date').apply(ql).groupby('Date',as_index=False)[feature].max()
|
|
1273
|
+
fig.add_trace(go.Scatter(x=df_qs.Date, y=df_qs[feature], mode='lines',marker_color ='#D0D0D0',showlegend=False,opacity=0.05),row=1, col=i)
|
|
1274
|
+
fig.add_trace(go.Scatter(x=df_qm.Date, y=df_qm[feature], mode='lines',marker_color ='#D0D0D0',showlegend=False,opacity=0.05, fill='tonexty'),row=1, col=i)
|
|
1275
|
+
fig.add_trace(go.Scatter(x=df_ql.Date, y=df_ql[feature], mode='lines',marker_color ='#D0D0D0',showlegend=False,opacity=0.05, fill='tonexty'),row=1, col=i)
|
|
1264
1276
|
|
|
1265
1277
|
fig.add_trace(go.Scatter(x=history.Date, y=history.log_return, mode='lines',marker_color ='blue',showlegend=False),row=1, col=1)
|
|
1266
1278
|
|
|
@@ -1272,9 +1284,9 @@ class produce_plotly_plots:
|
|
|
1272
1284
|
fig.add_trace(go.Scatter(x=df.Date, y=df.log_return, mode='lines',marker_color ='#ff7f0e',showlegend=False),row=1, col=1)
|
|
1273
1285
|
fig.add_trace(go.Scatter(x=df.Date, y=df.log_return, mode='markers',marker_color ='#ff7f0e',showlegend=False),row=1, col=1)
|
|
1274
1286
|
fig.add_hline(y=0, line_width=2, line_dash="dash", line_color="grey",col = 1, row = 1)
|
|
1287
|
+
add_intervals(data=prediction,feature='log_return',i=1)
|
|
1275
1288
|
|
|
1276
1289
|
## closing prices
|
|
1277
|
-
|
|
1278
1290
|
fig.add_trace(go.Scatter(x=history.Date, y=history.Close, mode='lines',marker_color ='blue',showlegend=False),row=1, col=2)
|
|
1279
1291
|
for i,datex in enumerate([x for x in last_exe_prediction_date if x != last_date]):
|
|
1280
1292
|
df = prediction[prediction.ExecutionDate == datex]
|
|
@@ -1284,6 +1296,7 @@ class produce_plotly_plots:
|
|
|
1284
1296
|
fig.add_trace(go.Scatter(x=df.Date, y=df.Close, mode='lines',marker_color ='#ff7f0e',showlegend=False),row=1, col=2)
|
|
1285
1297
|
fig.add_trace(go.Scatter(x=df.Date, y=df.Close, mode='markers',marker_color ='#ff7f0e',showlegend=False),row=1, col=2)
|
|
1286
1298
|
fig.update_layout(height=height_plot, width=1600, title_text = f'forecasts: {self.ticket_name}')
|
|
1299
|
+
add_intervals(data=prediction,feature='Close',i=2)
|
|
1287
1300
|
else:
|
|
1288
1301
|
print('no forecasting history')
|
|
1289
1302
|
|
|
@@ -1287,7 +1287,7 @@ class stock_eda_panel(object):
|
|
|
1287
1287
|
|
|
1288
1288
|
setattr(self,f'settings_{name_attr}_pricefeature' , {'type_func': type_func, 'window': window, 'distance': distance})
|
|
1289
1289
|
|
|
1290
|
-
def pair_index_feature(self, pair_symbol, feature_label, window
|
|
1290
|
+
def pair_index_feature(self, pair_symbol, feature_label,threshold, window = None,ta_method='ROC',param_set=False,plot = False, save_features = False):
|
|
1291
1291
|
"""
|
|
1292
1292
|
perform additional asset ROC feature, then a new feature is created in the main dataframe
|
|
1293
1293
|
|
|
@@ -1295,8 +1295,10 @@ class stock_eda_panel(object):
|
|
|
1295
1295
|
----------
|
|
1296
1296
|
pair_symbol (str): symbol of the asset to extract the data
|
|
1297
1297
|
feature_label (str): name of the resulting feature
|
|
1298
|
-
window (int): window to apply to the feature
|
|
1298
|
+
window (int): window to apply to the feature as default (this parameter is going to be deprecated)
|
|
1299
1299
|
threshold (float): alpha or z thrsholds for the normalized feature
|
|
1300
|
+
param_set (dict): parameter set in case ta_method is other than ROC
|
|
1301
|
+
ta_method (str): method to use, available RSI, ROC, VORTEX, STOCH
|
|
1300
1302
|
plot (boolean): True to display plot
|
|
1301
1303
|
save_features (boolean): True to save feature configuration and feature names
|
|
1302
1304
|
|
|
@@ -1326,7 +1328,20 @@ class stock_eda_panel(object):
|
|
|
1326
1328
|
self.pair_index_df = self.pair_index_df.fillna(method = 'bfill')
|
|
1327
1329
|
self.pair_index_df = self.pair_index_df.fillna(method = 'ffill')
|
|
1328
1330
|
|
|
1329
|
-
|
|
1331
|
+
if ta_method == 'ROC':
|
|
1332
|
+
window = window if window else param_set.get('window')
|
|
1333
|
+
roc = ROCIndicator(close = self.pair_index_df['Close'], window = window).roc()
|
|
1334
|
+
self.pair_index_df[feature_label] = roc.replace([np.inf, -np.inf], 0).fillna(method = 'ffill')
|
|
1335
|
+
elif ta_method == 'RSI':
|
|
1336
|
+
rsi = RSIIndicator(close = self.pair_index_df['Close'], **param_set).rsi()
|
|
1337
|
+
self.pair_index_df[feature_label] = rsi.replace([np.inf, -np.inf], 0).fillna(method = 'ffill')
|
|
1338
|
+
elif ta_method == 'VORTEX':
|
|
1339
|
+
vortex = VortexIndicator(close = self.pair_index_df['Close'], high = self.pair_index_df['High'], low = self.pair_index_df['Low'], **param_set).vortex_indicator_diff()
|
|
1340
|
+
self.pair_index_df[feature_label] = vortex.replace([np.inf, -np.inf], 0).fillna(method = 'ffill')
|
|
1341
|
+
elif ta_method == 'STOCH':
|
|
1342
|
+
stoch = StochRSIIndicator(close = self.pair_index_df['Close'], **param_set).stochrsi()
|
|
1343
|
+
self.pair_index_df[feature_label] = stoch.replace([np.inf, -np.inf], 0).fillna(method = 'ffill')
|
|
1344
|
+
|
|
1330
1345
|
df_to_merge = self.pair_index_df[['Date',feature_label]]
|
|
1331
1346
|
self.df = self.df.merge(df_to_merge, on ='Date',how = 'left')
|
|
1332
1347
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: virgo-modules
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: data processing and statistical modeling using stock market data
|
|
5
5
|
Home-page: https://github.com/miguelmayhem92/virgo_module
|
|
6
6
|
Author: Miguel Mayhuire
|
|
@@ -12,23 +12,6 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.9, <3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: feature-engine==1.6.1
|
|
16
|
-
Requires-Dist: matplotlib==3.6.3
|
|
17
|
-
Requires-Dist: mlflow==2.1.1
|
|
18
|
-
Requires-Dist: numpy==1.23.5
|
|
19
|
-
Requires-Dist: optuna==3.1.0
|
|
20
|
-
Requires-Dist: pandas==1.5.3
|
|
21
|
-
Requires-Dist: plotly==5.15.0
|
|
22
|
-
Requires-Dist: rsa==4.9
|
|
23
|
-
Requires-Dist: scikit-learn==1.2.1
|
|
24
|
-
Requires-Dist: scipy==1.10.0
|
|
25
|
-
Requires-Dist: seaborn==0.12.2
|
|
26
|
-
Requires-Dist: starlette==0.22.0
|
|
27
|
-
Requires-Dist: statsmodels==0.13.5
|
|
28
|
-
Requires-Dist: ta==0.10.2
|
|
29
|
-
Requires-Dist: yfinance==0.2.9
|
|
30
|
-
Requires-Dist: hmmlearn==0.3.0
|
|
31
|
-
Requires-Dist: boto3
|
|
32
15
|
Provides-Extra: dev
|
|
33
16
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
34
17
|
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
feature-engine==1.6.1
|
|
2
|
-
matplotlib==3.6.3
|
|
3
|
-
mlflow==2.1.1
|
|
4
|
-
numpy==1.23.5
|
|
5
|
-
optuna==3.1.0
|
|
6
|
-
pandas==1.5.3
|
|
7
|
-
plotly==5.15.0
|
|
8
|
-
rsa==4.9
|
|
9
|
-
scikit-learn==1.2.1
|
|
10
|
-
scipy==1.10.0
|
|
11
|
-
seaborn==0.12.2
|
|
12
|
-
starlette==0.22.0
|
|
13
|
-
statsmodels==0.13.5
|
|
14
|
-
ta==0.10.2
|
|
15
|
-
yfinance==0.2.9
|
|
16
|
-
hmmlearn==0.3.0
|
|
17
|
-
boto3
|
|
18
|
-
|
|
19
|
-
[dev]
|
|
20
|
-
pytest>=7.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules/src/transformer_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.2.8 → virgo_modules-0.2.10}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|