virgo-modules 0.2.7__tar.gz → 0.2.9__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.7 → virgo_modules-0.2.9}/PKG-INFO +1 -1
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/setup.py +1 -1
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/re_utils.py +22 -7
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -1
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/LICENSE +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/README.md +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/setup.cfg +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/backtester.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/edge_utils.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/hmm_utils.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/ticketer_source.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/transformer_utils.py +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/requires.txt +0 -0
- {virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/top_level.txt +0 -0
|
@@ -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.9",
|
|
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"),
|
|
@@ -907,7 +907,7 @@ class produce_plotly_plots:
|
|
|
907
907
|
self.aws_credentials = aws_credentials
|
|
908
908
|
self.return_figs = return_figs
|
|
909
909
|
|
|
910
|
-
def plot_asset_signals(self, feature_list,spread_column, date_intervals = False):
|
|
910
|
+
def plot_asset_signals(self, feature_list,spread_column, date_intervals = False, look_back = 800):
|
|
911
911
|
"""
|
|
912
912
|
Display signals and hmm states over closing prices and feature time series
|
|
913
913
|
|
|
@@ -923,6 +923,8 @@ class produce_plotly_plots:
|
|
|
923
923
|
"""
|
|
924
924
|
result_json_name = 'panel_signals.json'
|
|
925
925
|
df = self.data_frame
|
|
926
|
+
if look_back:
|
|
927
|
+
df = df.iloc[-look_back:,:]
|
|
926
928
|
ma1 = self.settings['settings'][spread_column]['ma1']
|
|
927
929
|
ma2 = self.settings['settings'][spread_column]['ma2']
|
|
928
930
|
hmm_n_clust = self.settings['settings']['hmm']['n_clusters']
|
|
@@ -1209,18 +1211,26 @@ class produce_plotly_plots:
|
|
|
1209
1211
|
if self.return_figs:
|
|
1210
1212
|
return fig, messages
|
|
1211
1213
|
|
|
1212
|
-
def produce_forecasting_plot(self,predictions):
|
|
1214
|
+
def produce_forecasting_plot(self,predictions, window=30):
|
|
1213
1215
|
"""
|
|
1214
1216
|
display forecasting plots
|
|
1215
1217
|
|
|
1216
1218
|
Parameters
|
|
1217
1219
|
----------
|
|
1218
1220
|
predictions (pd.DataFrame): asset predictions
|
|
1221
|
+
window (int): historical data to display
|
|
1219
1222
|
|
|
1220
1223
|
Returns
|
|
1221
1224
|
-------
|
|
1222
1225
|
None
|
|
1223
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
|
+
|
|
1224
1234
|
result_json_name = 'forecast_plot.json'
|
|
1225
1235
|
hmm_n_clust = self.settings['settings']['hmm']['n_clusters']
|
|
1226
1236
|
model_type = self.settings.get('model_type',False)
|
|
@@ -1236,8 +1246,6 @@ class produce_plotly_plots:
|
|
|
1236
1246
|
[{"type": "scatter"}, {"type": "scatter"}]],
|
|
1237
1247
|
subplot_titles = [f'asset returns {lags} lags', 'closing prices', 'hidden states']
|
|
1238
1248
|
)
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
1249
|
predictions = predictions[predictions.StockCode == self.ticket_name]
|
|
1242
1250
|
if len(predictions) > 1:
|
|
1243
1251
|
|
|
@@ -1253,12 +1261,18 @@ class produce_plotly_plots:
|
|
|
1253
1261
|
last_exe_prediction_date = predictions.ExecutionDate.unique()
|
|
1254
1262
|
last_date = max(last_exe_prediction_date)
|
|
1255
1263
|
|
|
1256
|
-
history =
|
|
1264
|
+
history = self.data_frame.sort_values('Date').iloc[-window:,:]
|
|
1257
1265
|
cut_date = history.loc[history.iloc[-1:,:].index[0]:,'Date'].item()
|
|
1258
|
-
|
|
1259
1266
|
prediction = predictions[predictions.Type == 'Prediction']
|
|
1260
1267
|
|
|
1261
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)
|
|
1262
1276
|
|
|
1263
1277
|
fig.add_trace(go.Scatter(x=history.Date, y=history.log_return, mode='lines',marker_color ='blue',showlegend=False),row=1, col=1)
|
|
1264
1278
|
|
|
@@ -1270,9 +1284,9 @@ class produce_plotly_plots:
|
|
|
1270
1284
|
fig.add_trace(go.Scatter(x=df.Date, y=df.log_return, mode='lines',marker_color ='#ff7f0e',showlegend=False),row=1, col=1)
|
|
1271
1285
|
fig.add_trace(go.Scatter(x=df.Date, y=df.log_return, mode='markers',marker_color ='#ff7f0e',showlegend=False),row=1, col=1)
|
|
1272
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)
|
|
1273
1288
|
|
|
1274
1289
|
## closing prices
|
|
1275
|
-
|
|
1276
1290
|
fig.add_trace(go.Scatter(x=history.Date, y=history.Close, mode='lines',marker_color ='blue',showlegend=False),row=1, col=2)
|
|
1277
1291
|
for i,datex in enumerate([x for x in last_exe_prediction_date if x != last_date]):
|
|
1278
1292
|
df = prediction[prediction.ExecutionDate == datex]
|
|
@@ -1282,6 +1296,7 @@ class produce_plotly_plots:
|
|
|
1282
1296
|
fig.add_trace(go.Scatter(x=df.Date, y=df.Close, mode='lines',marker_color ='#ff7f0e',showlegend=False),row=1, col=2)
|
|
1283
1297
|
fig.add_trace(go.Scatter(x=df.Date, y=df.Close, mode='markers',marker_color ='#ff7f0e',showlegend=False),row=1, col=2)
|
|
1284
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)
|
|
1285
1300
|
else:
|
|
1286
1301
|
print('no forecasting history')
|
|
1287
1302
|
|
|
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
|
|
File without changes
|
{virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules/src/transformer_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.2.7 → virgo_modules-0.2.9}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|