virgo-modules 0.2.2__py3-none-any.whl → 0.2.4__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.

@@ -760,7 +760,10 @@ def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_avai
760
760
  object_stock.cluster_hmm_analysis( n_clusters = ticket_settings['settings']['hmm']['n_clusters'],
761
761
  features_hmm = ticket_settings['settings']['hmm']['features_hmm'],
762
762
  test_data_size = ticket_settings['settings']['hmm']['test_data_size'],
763
- seed = ticket_settings['settings']['hmm']['seed'])
763
+ seed = ticket_settings['settings']['hmm']['seed'],
764
+ corr_threshold = ticket_settings['settings']['hmm'].get('corr_threshold',0.75),
765
+ lag_returns_state = ticket_settings['settings']['hmm'].get('lag_returns_state',7),
766
+ )
764
767
 
765
768
  return object_stock
766
769
 
@@ -173,6 +173,8 @@ class stock_eda_panel(object):
173
173
  perform additional asset ROC feature, then a new feature is created in the main dataframe
174
174
  produce_order_features(feature_name=str, save_features=boolean):
175
175
  perform a feature that captures high and low values in an index. this is usefull to know duration/persistence of a signal
176
+ compute_last_signal (feature_name=str, save_features=boolean):
177
+ perform a feature that captures high and low values in an index. this is usefull to know duration/persistence of a signal
176
178
  create_hmm_derived_features():
177
179
  create features derived from hmm states features. Features are the index of the state, the duration of the state, chain raturn
178
180
  cluster_hmm_analysis(n_clusters=int,features_hmm=list, test_data_size=int, seed=int, lag_returns_state=int, plot=boolean, save_features=boolean, model=obj):
@@ -1383,6 +1385,53 @@ class stock_eda_panel(object):
1383
1385
  self.signals.append(signal_feature_name)
1384
1386
  self.signals.append(order_feature_name)
1385
1387
 
1388
+ def compute_last_signal(self,feature, save_features = False):
1389
+ """
1390
+ perform two new features when signal is observed, one for the last duration of the previous chain, second for the last duration of the same sign signal
1391
+
1392
+ Parameters
1393
+ ----------
1394
+ feature_name (str): name of the feature
1395
+ save_features (boolean): True to save feature configuration and feature names
1396
+
1397
+ Returns
1398
+ -------
1399
+ None
1400
+ """
1401
+ def create_last_signal(df, feature, prefix, type ='0'):
1402
+ if type == '0':
1403
+ condition = df[f'order_signal_{feature}'] != 0
1404
+ elif type == '+':
1405
+ condition = df[f'order_signal_{feature}'] > 0
1406
+ elif type == '-':
1407
+ condition = df[f'order_signal_{feature}'] < 0
1408
+ df[f'last_maxorder_{feature}'] = np.where(condition, df[f'order_signal_{feature}'],np.nan)
1409
+ df['tmp_chain_index'] = df[f'last_maxorder_{feature}'].shift(-1)
1410
+ df['last'] = np.where((df[f'last_maxorder_{feature}'] != 0) & (df['tmp_chain_index'].isna()),df[f'last_maxorder_{feature}'], np.nan )
1411
+ df['last'] = df['last'].shift(1)
1412
+ df[f'last_maxorder_{feature}'] = df['last'].fillna(method = 'ffill')
1413
+ df = df.drop(columns = ['tmp_chain_index','last'])
1414
+ df[f'last_maxorder_{feature}'] = np.where(df[f'order_signal_{feature}'] != 0,df[f'last_maxorder_{feature}'],np.nan)
1415
+ df[f'last_maxorder_{feature}'] = df[f'last_maxorder_{feature}'].fillna(0)
1416
+ df = df.rename(columns = {f'last_maxorder_{feature}':f'{prefix}_{feature}'})
1417
+ return df
1418
+ prefix0, prefix1, prefix2 = 'ldur', 'pos', 'neg'
1419
+ self.df = create_last_signal(self.df, feature, prefix0, type ='0')
1420
+ self.df = create_last_signal(self.df, feature, prefix1, type ='+')
1421
+ self.df = create_last_signal(self.df, feature, prefix2, type ='-')
1422
+
1423
+ self.df[f'sldur_{feature}'] = np.where(
1424
+ self.df[f'order_signal_{feature}'] > 0, self.df[f'{prefix1}_{feature}'],
1425
+ np.where(
1426
+ self.df[f'order_signal_{feature}'] < 0, self.df[f'{prefix2}_{feature}'],
1427
+ 0
1428
+ )
1429
+ )
1430
+ self.df = self.df.drop(columns = [f'{prefix1}_{feature}',f'{prefix2}_{feature}'])
1431
+ if save_features:
1432
+ self.signals.append(f'sldur_{feature}')
1433
+ self.signals.append(f'ldur_{feature}')
1434
+
1386
1435
  def create_hmm_derived_features(self, lag_returns):
1387
1436
  """
1388
1437
  create features derived from hmm states features. Features are the index of the state, the duration of the state, chain raturn
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: virgo-modules
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -5,11 +5,11 @@ virgo_modules/src/backtester.py,sha256=OhiWyzDX0PthXGuhChyWUmDN3cLkzVYe95zS4nGti
5
5
  virgo_modules/src/edge_utils.py,sha256=XN2oEOwADXF9IGNUGx0Ai8B1yDAiU2WDateLnEJh5FE,14243
6
6
  virgo_modules/src/hmm_utils.py,sha256=fFWxmh9q3rjiKRHnxNk9k7O4fDrxVxkmp3pbpLvktjc,21116
7
7
  virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
8
- virgo_modules/src/re_utils.py,sha256=05pSVzGKBybPMFGm2wcbYgkSOZs3bZECLjyHvlPlFjM,72490
9
- virgo_modules/src/ticketer_source.py,sha256=8YInJJF_OzjWXaAuOjAzdaQrgkemmsIpQSTkCZs5VFA,95918
8
+ virgo_modules/src/re_utils.py,sha256=qkNe0BCT3lxm5zAHTEDdH0Cu8ID3A8j3OB39oGFpuDQ,72790
9
+ virgo_modules/src/ticketer_source.py,sha256=bm1I-a_mg80fgdH0Znx-qg0CTUxtVmkL6PWLTCeBTu8,98617
10
10
  virgo_modules/src/transformer_utils.py,sha256=LLwKYZRq5hrPVimnq3taD0Lh-q3Bq21fy1I4Icbnxi8,7677
11
- virgo_modules-0.2.2.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
12
- virgo_modules-0.2.2.dist-info/METADATA,sha256=4jz0IHgWzYOrvqW4UnCgHkZHJQWCD9wWWaEm2du9hRY,1428
13
- virgo_modules-0.2.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
14
- virgo_modules-0.2.2.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
15
- virgo_modules-0.2.2.dist-info/RECORD,,
11
+ virgo_modules-0.2.4.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
12
+ virgo_modules-0.2.4.dist-info/METADATA,sha256=jI0VJoMF2uIxH6wE4OIDLcOSTERnAETEqPLJecRhLb0,1428
13
+ virgo_modules-0.2.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
14
+ virgo_modules-0.2.4.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
15
+ virgo_modules-0.2.4.dist-info/RECORD,,