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

@@ -414,4 +414,52 @@ def edge_probas_lines(data, threshold, plot = False, look_back = 750):
414
414
  fig.update_layout(title_text="sirius - edge probabilities",width=1200,height = 500)
415
415
  if plot:
416
416
  fig.show()
417
+ return fig
418
+
419
+ def get_rolling_probs(data, window = 3,plot = False, look_back = 750):
420
+ """
421
+ produce a plotly plot of smoothed edges and closing prices
422
+
423
+ Parameters:
424
+ data (pd.DataFrame): asset data with edge probabilities
425
+ window (int): window size
426
+ plot (boolean): if true, display plot
427
+ look_back (int): number of rows back to display
428
+
429
+ Returns:
430
+ fig (obj): plotly go object
431
+ """
432
+ prob_cols = ['proba_target_down','proba_target_up']
433
+ df = data[prob_cols+['Date','log_return','Close']].iloc[-look_back:]
434
+ for colx in prob_cols:
435
+ df[f'roll_{colx}'] = df.sort_values('Date')[colx].rolling(window, min_periods=1).mean()
436
+ df['roll_edge'] = np.where(df['roll_proba_target_up'] > df['roll_proba_target_down'],'up','down')
437
+ #order chaining
438
+ df['lag'] = df['roll_edge'].shift(1)
439
+ df['change'] = np.where(df['roll_edge']!=df['lag'],1,np.nan)
440
+ df['rn'] = df.sort_values('Date').groupby('change').cumcount() + 1
441
+ df['rn'] = np.where(df['change']==1,df['rn'],np.nan)
442
+ df['chain'] = df.sort_values('Date')['rn'].fillna(method='ffill')
443
+ df['chain_id'] = df.sort_values(['Date']).groupby(['chain','chain']).cumcount() + 1
444
+
445
+ colors = {'up':'blue','down':'red'}
446
+ fig = make_subplots(
447
+ rows=2, cols=2,shared_xaxes=False,vertical_spacing=0.08,
448
+ specs=[[{"colspan": 2, "secondary_y":True}, None],[{}, {}]],
449
+ subplot_titles=("Smooth edge probabilities", "expected log return", "Duration"))
450
+ fig.add_trace(go.Scatter(x=df.Date, y=df.Close,mode='lines+markers',name='Close price'))
451
+ fig.add_trace(go.Scatter(x=df.Date, y=df.roll_proba_target_down,mode='lines',marker = dict(color = 'coral'),name='go down'),secondary_y=True,col=1,row=1)
452
+ fig.add_trace(go.Scatter(x=df.Date, y=df.roll_proba_target_up,mode='lines',marker = dict(opacity=0.1,size=80), name='go up'),secondary_y=True,col=1,row=1)
453
+
454
+ for re in df['roll_edge'].unique():
455
+ fig.add_trace(go.Box(x=df[df['roll_edge']==re]["log_return"],name=re,marker_color=colors.get(re),showlegend=False),col=1,row=2)
456
+
457
+ df_ = df.groupby(['roll_edge','chain'],as_index=False).agg(max_duration = ('chain_id','max'))
458
+ for re in df_['roll_edge'].unique():
459
+ fig.add_trace(go.Box(x=df_[df_['roll_edge']==re]["max_duration"],name=re,marker_color=colors.get(re),showlegend=False),col=2,row=2)
460
+
461
+ fig.update_layout(title_text="sirius - smooth edge probabilities",width=1200,height = 1000)
462
+ if plot:
463
+ fig.show()
464
+
417
465
  return fig
@@ -749,6 +749,7 @@ def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_avai
749
749
  if len(discrete_features) > 0:
750
750
  for feature_name in discrete_features:
751
751
  object_stock.produce_order_features(feature_name)
752
+ object_stock.get_order_feature_nosignal(feature_name)
752
753
 
753
754
  if hmm_available:
754
755
  object_stock.cluster_hmm_analysis( n_clusters = None,
@@ -1400,6 +1401,7 @@ def extract_data_traintest(object_stock,features_to_search,configs, target_confi
1400
1401
  getattr(object_stock, method_to_use)(**arguments_to_use, plot = False, save_features = False)
1401
1402
  if method_to_use not in ['minmax_pricefeature']:
1402
1403
  object_stock.produce_order_features(feature_name)
1404
+ object_stock.get_order_feature_nosignal(feature_name)
1403
1405
  last_signal_featlist = configs.get('custom_transformations',{}).get('compute_last_signal', False)
1404
1406
  if last_signal_featlist:
1405
1407
  last_signal_featlist = last_signal_featlist
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: virgo-modules
3
- Version: 0.3.6
3
+ Version: 0.4.0
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
@@ -4,15 +4,15 @@ virgo_modules/src/aws_utils.py,sha256=q0l7D7ofo09Lu1QQjv-esheQ06uiSy1Pdq3xMul8zv
4
4
  virgo_modules/src/backtester.py,sha256=OhiWyzDX0PthXGuhChyWUmDN3cLkzVYe95zS4nGtia8,22106
5
5
  virgo_modules/src/hmm_utils.py,sha256=fFWxmh9q3rjiKRHnxNk9k7O4fDrxVxkmp3pbpLvktjc,21116
6
6
  virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
7
- virgo_modules/src/re_utils.py,sha256=Exqe5eVGOpyb2j3veAsnFzXh-hXMwHe1zGTa_hO0wjI,73970
7
+ virgo_modules/src/re_utils.py,sha256=_wkDIKwUQFX_OT0kNA_zgDgoe808aEvSc4ZtviY2FMY,74104
8
8
  virgo_modules/src/ticketer_source.py,sha256=jxP-OOeoyN2JxRQg-mX6t6WNJXiIrhWKDywDxpYANxU,101977
9
9
  virgo_modules/src/transformer_utils.py,sha256=LLwKYZRq5hrPVimnq3taD0Lh-q3Bq21fy1I4Icbnxi8,7677
10
10
  virgo_modules/src/edge_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  virgo_modules/src/edge_utils/conformal_utils.py,sha256=4gAOh2vxeWGR7iMF3TKnfQcLHlaH9M5B2lcmzo7V8AY,3755
12
- virgo_modules/src/edge_utils/edge_utils.py,sha256=U3GVyLgz0gEaR7AGjWseFcWt-IOusZvXJjwpBFknxNs,15643
12
+ virgo_modules/src/edge_utils/edge_utils.py,sha256=2K7-Ve8f0ywUeQCwOTDR8v0p7-ow3qV_2ME0w9oB3oc,18273
13
13
  virgo_modules/src/edge_utils/shap_utils.py,sha256=OMKVO-4gtOng9GeSuhEgAEQe4FF3AtqXjm-GUBLqYFc,3349
14
- virgo_modules-0.3.6.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
15
- virgo_modules-0.3.6.dist-info/METADATA,sha256=yCCV7zH-x7ht6hIFlwwp5VSZKp3Wt78G9mAGSIciDVM,883
16
- virgo_modules-0.3.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
17
- virgo_modules-0.3.6.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
18
- virgo_modules-0.3.6.dist-info/RECORD,,
14
+ virgo_modules-0.4.0.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
15
+ virgo_modules-0.4.0.dist-info/METADATA,sha256=eovX4zgi_zHRVzaCXQk66cu62CuLUu9-Oq4LhZ5gcTA,883
16
+ virgo_modules-0.4.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
17
+ virgo_modules-0.4.0.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
18
+ virgo_modules-0.4.0.dist-info/RECORD,,