virgo-modules 0.0.86__py3-none-any.whl → 0.0.88__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 virgo-modules might be problematic. Click here for more details.
- virgo_modules/src/re_utils.py +12 -3
- virgo_modules/src/ticketer_source.py +69 -1
- {virgo_modules-0.0.86.dist-info → virgo_modules-0.0.88.dist-info}/METADATA +1 -1
- {virgo_modules-0.0.86.dist-info → virgo_modules-0.0.88.dist-info}/RECORD +7 -7
- {virgo_modules-0.0.86.dist-info → virgo_modules-0.0.88.dist-info}/LICENSE +0 -0
- {virgo_modules-0.0.86.dist-info → virgo_modules-0.0.88.dist-info}/WHEEL +0 -0
- {virgo_modules-0.0.86.dist-info → virgo_modules-0.0.88.dist-info}/top_level.txt +0 -0
virgo_modules/src/re_utils.py
CHANGED
|
@@ -700,7 +700,11 @@ def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_avai
|
|
|
700
700
|
'stochastic_feature':'stochastic_feature',
|
|
701
701
|
'william_feature':'william_feature',
|
|
702
702
|
'vortex_feature':'vortex_feature',
|
|
703
|
-
'pair_index_feature':'pair_index_feature' # this has a diff structure!
|
|
703
|
+
'pair_index_feature':'pair_index_feature', # this has a diff structure!
|
|
704
|
+
'min_distance_pricefeature':'minmax_pricefeature',
|
|
705
|
+
'min_relprice_pricefeature':'minmax_pricefeature',
|
|
706
|
+
'max_distance_pricefeature':'minmax_pricefeature',
|
|
707
|
+
'max_relprice_pricefeature':'minmax_pricefeature',
|
|
704
708
|
}
|
|
705
709
|
exceptions = ['pair_feature','pair_index_feature']
|
|
706
710
|
### standar feature
|
|
@@ -1028,7 +1032,6 @@ class produce_plotly_plots:
|
|
|
1028
1032
|
if len(states_subtitles)%2 == 1:
|
|
1029
1033
|
states_subtitles = states_subtitles + [None]
|
|
1030
1034
|
|
|
1031
|
-
|
|
1032
1035
|
fig = make_subplots(
|
|
1033
1036
|
rows= rows_subplot, cols=2,
|
|
1034
1037
|
specs = [[{"type": "scatter"},{"type": "scatter"}]]*state_rows,
|
|
@@ -1107,6 +1110,11 @@ class produce_plotly_plots:
|
|
|
1107
1110
|
df_ = df[['Date','hmm_feature','Close',"chain_return"]].sort_values('Date')
|
|
1108
1111
|
df_['Daily_Returns'] = df['Close'].pct_change(7)
|
|
1109
1112
|
|
|
1113
|
+
df_agg_returns = df_.groupby('hmm_feature', as_index = False).agg(median =('Daily_Returns','median')).copy()
|
|
1114
|
+
current_state = df_.iloc[-1,:].hmm_feature
|
|
1115
|
+
medain_state_return = df_agg_returns[ df_agg_returns.hmm_feature == current_state]['median'].values[0]
|
|
1116
|
+
type_state = 'low state' if medain_state_return < 0 else 'high state'
|
|
1117
|
+
|
|
1110
1118
|
for state in states:
|
|
1111
1119
|
dfi = df_[df_.hmm_feature == state]
|
|
1112
1120
|
fig.add_trace(go.Box(y = dfi.chain_return, name=str(state),showlegend=False, marker_color = color_map[state] ),row=1, col=1)
|
|
@@ -1151,7 +1159,6 @@ class produce_plotly_plots:
|
|
|
1151
1159
|
fig.add_trace(go.Box(x = dfi.importance, name=str(feature),showlegend=False ),row=2, col=2)
|
|
1152
1160
|
fig.update_yaxes(visible=False, title="feature",row=2, col=2)
|
|
1153
1161
|
|
|
1154
|
-
|
|
1155
1162
|
fig.update_layout(height=height_plot, width=1600, title_text = f'State model analysis: {self.ticket_name}', coloraxis=dict(colorbar_len=0.50))
|
|
1156
1163
|
|
|
1157
1164
|
date_execution = datetime.datetime.today().strftime('%Y-%m-%d')
|
|
@@ -1165,6 +1172,7 @@ class produce_plotly_plots:
|
|
|
1165
1172
|
'current state':message1,
|
|
1166
1173
|
'current step in state': message2,
|
|
1167
1174
|
'execution date':message3,
|
|
1175
|
+
'type state':type_state,
|
|
1168
1176
|
}
|
|
1169
1177
|
|
|
1170
1178
|
if self.show_plot:
|
|
@@ -1196,6 +1204,7 @@ class produce_plotly_plots:
|
|
|
1196
1204
|
|
|
1197
1205
|
if self.return_figs:
|
|
1198
1206
|
return fig, messages
|
|
1207
|
+
|
|
1199
1208
|
def produce_forecasting_plot(self,predictions):
|
|
1200
1209
|
"""
|
|
1201
1210
|
display forecasting plots
|
|
@@ -383,6 +383,8 @@ class stock_eda_panel(object):
|
|
|
383
383
|
perfom fast stochastic oscilator or william indicator
|
|
384
384
|
vortex_feature(window=int, threshold=float, plot=boolean, save_features=boolean):
|
|
385
385
|
perform vortex oscilator
|
|
386
|
+
minmax_pricefeature(type_func=str, window=int, distance=bolean, save_features=boolean)
|
|
387
|
+
get relative price/ distance feature with respect to the min/max price in a given window
|
|
386
388
|
pair_index_feature(pair_symbol=str, feature_label=str, window=int, threshold=float, plot=boolean, save_features=boolean):
|
|
387
389
|
perform additional asset ROC feature, then a new feature is created in the main dataframe
|
|
388
390
|
produce_order_features(feature_name=str, save_features=boolean):
|
|
@@ -1698,6 +1700,70 @@ class stock_eda_panel(object):
|
|
|
1698
1700
|
if plot:
|
|
1699
1701
|
self.signal_plotter(feature_name)
|
|
1700
1702
|
|
|
1703
|
+
def minmax_pricefeature(self, type_func, window, distance = False, save_features = False):
|
|
1704
|
+
"""
|
|
1705
|
+
perform relative price/distance with respect to the min/max price in a given time scope
|
|
1706
|
+
|
|
1707
|
+
Parameters
|
|
1708
|
+
----------
|
|
1709
|
+
type_func (str): either min or max
|
|
1710
|
+
window (int): window scope
|
|
1711
|
+
distance (boolean): if true, get distance feature else relative feature
|
|
1712
|
+
save_features (boolean): True to save feature configuration and feature names
|
|
1713
|
+
|
|
1714
|
+
Returns
|
|
1715
|
+
-------
|
|
1716
|
+
None
|
|
1717
|
+
"""
|
|
1718
|
+
if type_func == 'min':
|
|
1719
|
+
self.df['Price_ref'] = self.df[['Open','High', 'Low','Close']].min(axis = 1)
|
|
1720
|
+
elif type_func == 'max':
|
|
1721
|
+
self.df['Price_ref'] = self.df[['Open','High', 'Low','Close']].max(axis = 1)
|
|
1722
|
+
|
|
1723
|
+
init_shape = self.df.shape[0]
|
|
1724
|
+
df_date = self.df[['Date','Price_ref']].rename(columns = {'Date':'Date_ref'}).copy()
|
|
1725
|
+
|
|
1726
|
+
self.df = self.df.rename(columns = {'Price_ref':'Price_to_use'})
|
|
1727
|
+
|
|
1728
|
+
if type_func == 'min':
|
|
1729
|
+
self.df[f'window_price'] = (self.df.sort_values("Date")["Price_to_use"].transform(lambda x: x.rolling(window, min_periods=1).min()))
|
|
1730
|
+
elif type_func == 'max':
|
|
1731
|
+
self.df[f'window_price'] = (self.df.sort_values("Date")["Price_to_use"].transform(lambda x: x.rolling(window, min_periods=1).max()))
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
self.df = self.df.merge(df_date, left_on = 'window_price', right_on = 'Price_ref', how = 'left')
|
|
1735
|
+
self.df['date_span'] = self.df['Date'] - self.df['Date_ref']
|
|
1736
|
+
|
|
1737
|
+
self.df['RN'] = self.df.sort_values(['date_span'], ascending=False).groupby(['Date']).cumcount() + 1
|
|
1738
|
+
self.df = self.df[self.df['RN'] == 1]
|
|
1739
|
+
|
|
1740
|
+
if distance:
|
|
1741
|
+
self.df[f'{type_func}_distance_to_price'] = pd.to_numeric(self.df['date_span'].dt.days, downcast='integer')
|
|
1742
|
+
|
|
1743
|
+
if not distance:
|
|
1744
|
+
if type_func == 'min':
|
|
1745
|
+
self.df[f'{type_func}_relprice'] = self.df['Price_to_use']/self.df['window_price']-1
|
|
1746
|
+
|
|
1747
|
+
if type_func == 'max':
|
|
1748
|
+
self.df[f'{type_func}_relprice'] = self.df['window_price']/self.df['Price_to_use']-1
|
|
1749
|
+
|
|
1750
|
+
self.df = self.df.drop(columns = ['RN', 'date_span', 'Price_to_use', 'window_price', 'Date_ref','Price_ref'])
|
|
1751
|
+
|
|
1752
|
+
end_shape = self.df.shape[0]
|
|
1753
|
+
|
|
1754
|
+
if init_shape != end_shape:
|
|
1755
|
+
raise Exception("shapes are not the same")
|
|
1756
|
+
|
|
1757
|
+
if save_features:
|
|
1758
|
+
if distance:
|
|
1759
|
+
self.features.append(f'{type_func}_distance_to_price')
|
|
1760
|
+
name_attr = f'{type_func}_distance'
|
|
1761
|
+
if not distance:
|
|
1762
|
+
self.features.append(f'{type_func}_relprice')
|
|
1763
|
+
name_attr = f'{type_func}_relprice'
|
|
1764
|
+
|
|
1765
|
+
setattr(self,f'settings_{name_attr}_pricefeature' , {'type_func': type_func, 'window': window, 'distance': distance})
|
|
1766
|
+
|
|
1701
1767
|
def pair_index_feature(self, pair_symbol, feature_label, window, threshold, plot = False, save_features = False):
|
|
1702
1768
|
"""
|
|
1703
1769
|
perform additional asset ROC feature, then a new feature is created in the main dataframe
|
|
@@ -2297,7 +2363,9 @@ class stock_eda_panel(object):
|
|
|
2297
2363
|
## for now this is hard coded
|
|
2298
2364
|
feature_list = ['spread_ma','relative_spread_ma','pair_feature','count_features','bidirect_count_features','price_range','relative_price_range','rsi_feature',
|
|
2299
2365
|
'rsi_feature_v2', 'days_features','days_features_v2', 'volume_feature','smooth_volume', 'roc_feature', 'stoch_feature', 'stochastic_feature',
|
|
2300
|
-
'william_feature', 'vortex_feature', 'pair_index_feature','hmm'
|
|
2366
|
+
'william_feature', 'vortex_feature', 'pair_index_feature','hmm',
|
|
2367
|
+
'min_distance_pricefeature', 'min_relprice_pricefeature', 'max_distance_pricefeature','max_relprice_pricefeature'
|
|
2368
|
+
]
|
|
2301
2369
|
|
|
2302
2370
|
for feature in feature_list:
|
|
2303
2371
|
try:
|
|
@@ -3,10 +3,10 @@ virgo_modules/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
3
3
|
virgo_modules/src/aws_utils.py,sha256=q0l7D7ofo09Lu1QQjv-esheQ06uiSy1Pdq3xMul8zvk,2571
|
|
4
4
|
virgo_modules/src/edge_utils.py,sha256=tMpt0bfnoOyD_qqh4wD6TQeOhaMcGE59DbvIj3qnp-0,13732
|
|
5
5
|
virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
|
|
6
|
-
virgo_modules/src/re_utils.py,sha256=
|
|
7
|
-
virgo_modules/src/ticketer_source.py,sha256=
|
|
8
|
-
virgo_modules-0.0.
|
|
9
|
-
virgo_modules-0.0.
|
|
10
|
-
virgo_modules-0.0.
|
|
11
|
-
virgo_modules-0.0.
|
|
12
|
-
virgo_modules-0.0.
|
|
6
|
+
virgo_modules/src/re_utils.py,sha256=ndPUW3F0QkljtKLR1dqtBm2I2LtceduSgLRIk3HszWk,72244
|
|
7
|
+
virgo_modules/src/ticketer_source.py,sha256=mhNPWbluKYVqpX0E8Uh6fTXi1Bn7zsG6rHIp_TklZr0,146629
|
|
8
|
+
virgo_modules-0.0.88.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
|
|
9
|
+
virgo_modules-0.0.88.dist-info/METADATA,sha256=C1I5H8ceh1-j9gZW7nykhZvzs952oy0Aqx9dWXkufBY,1429
|
|
10
|
+
virgo_modules-0.0.88.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
+
virgo_modules-0.0.88.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
|
|
12
|
+
virgo_modules-0.0.88.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|