virgo-modules 0.0.87__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 +5 -1
- virgo_modules/src/ticketer_source.py +69 -1
- {virgo_modules-0.0.87.dist-info → virgo_modules-0.0.88.dist-info}/METADATA +1 -1
- {virgo_modules-0.0.87.dist-info → virgo_modules-0.0.88.dist-info}/RECORD +7 -7
- {virgo_modules-0.0.87.dist-info → virgo_modules-0.0.88.dist-info}/LICENSE +0 -0
- {virgo_modules-0.0.87.dist-info → virgo_modules-0.0.88.dist-info}/WHEEL +0 -0
- {virgo_modules-0.0.87.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
|
|
@@ -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
|