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

@@ -520,6 +520,53 @@ def produce_dashboard(data, columns , ticket_list, show_plot = True, nrows = 150
520
520
  # upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = f'multi_dashboards/'+save_name+'.json',input_path = save_path+save_name+'.json')
521
521
  upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = save_aws + save_name + '.json', input_path = save_path + save_name + '.json', aws_credentials = aws_credential)
522
522
 
523
+ def produce_edges_dashboard(dataframe, ticket_list, save_name, show_plot = False, save_path = False, save_aws = False, aws_credentials = False):
524
+ '''
525
+ produce dashboard using signals and list of assets
526
+
527
+ Parameters:
528
+ dataframe (pd.Dataframe): base data
529
+ ticket_list (list): list of assets
530
+ save_name (str): dashboad name resulting file
531
+ show_plot (boolean): if true, display plot
532
+ save_path (str): local path for saving e.g r'C:/path/to/the/file/'
533
+ save_aws (str): remote key in s3 bucket path e.g. 'path/to/file/'
534
+ aws_credential (dict): aws credentials
535
+
536
+ Returns:
537
+ None
538
+ '''
539
+ n_assets = len(ticket_list)
540
+
541
+ result_json_name = save_name
542
+ cols_length = 4
543
+ rows_length = math.ceil(n_assets/2)
544
+
545
+ subtitles = list()
546
+ for x in ticket_list:
547
+ subtitles.append(x)
548
+ subtitles.append(x + ' signal')
549
+
550
+ fig = make_subplots(rows=rows_length, cols=cols_length,vertical_spacing = 0.01, horizontal_spacing = 0.03, shared_xaxes=True, subplot_titles = subtitles)
551
+
552
+ for i,ticket in enumerate(ticket_list):
553
+ j = i%2*2 +1
554
+ i = i+1
555
+ i_r = math.ceil(i/2)
556
+
557
+ show_legend = True if i == 1 else False
558
+
559
+ df = dataframe[dataframe.asset == ticket]
560
+ fig.add_trace(go.Scatter(x=df['Date'], y=df['Close'],legendgroup="Close",showlegend = show_legend , mode='lines',name = 'Close', marker_color = 'blue'),col = j, row = i_r)
561
+ fig.add_trace(go.Scatter(x=df['Date'], y=df['proba_target_up'],legendgroup="proba",showlegend = show_legend , mode='lines',name = 'proba_target_up', marker_color = 'orange'),col = j+1, row = i_r)
562
+ fig.update_layout(height=rows_length*300, width=1500, title_text = f'dashboard top {n_assets} tickets')
563
+
564
+ if save_path:
565
+ fig.write_json(save_path+result_json_name)
566
+ if show_plot:
567
+ fig.show()
568
+ if save_path and save_aws:
569
+ upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = save_aws + result_json_name, input_path = save_path + result_json_name, aws_credentials = aws_credentials)
523
570
 
524
571
  def rank_by_return(data, lag_days, top_n = 5):
525
572
  '''
@@ -1389,6 +1436,7 @@ def save_edge_model(data, save_path = False, save_aws = False, show_result = Fal
1389
1436
  if show_result:
1390
1437
  print(curent_edge)
1391
1438
 
1439
+ ## this function is going to be split and deprecated
1392
1440
  def create_feature_edge(model, data,feature_name, threshold, target_variables):
1393
1441
  '''
1394
1442
  get latest edge execution and edge probability
@@ -1417,4 +1465,74 @@ def create_feature_edge(model, data,feature_name, threshold, target_variables):
1417
1465
  result_df[f'signal_{type_use}_{feature_name}'] = np.where(result_df[pred_col] >= threshold,1,0)
1418
1466
  result_df[f'acc_{type_use}_{feature_name}'] = np.where(result_df[f'signal_{type_use}_{feature_name}'] == result_df[pred_col.replace('proba_','')],1,0)
1419
1467
 
1420
- return result_df
1468
+ return result_df
1469
+
1470
+ def produce_probas(model,data, target_variables):
1471
+ """
1472
+ produce probabilities given a model
1473
+
1474
+ Parameters:
1475
+ model (obj): edge model artifact
1476
+ data (pd.DataFrame): asset data
1477
+ target_variables (list): names of the target columns
1478
+
1479
+ Returns:
1480
+ result_df (pd.DataFrame): result dataframe with edges
1481
+ label_prediction (list): list of resulting label columns
1482
+ """
1483
+ label_prediction = ['proba_'+x for x in target_variables]
1484
+ predictions = model.predict_proba(data)
1485
+ predictions = pd.DataFrame(predictions, columns = label_prediction, index = data.index)
1486
+
1487
+ result_df = pd.concat([data, predictions], axis=1)
1488
+ result_df = result_df[['Date'] + target_variables + label_prediction]
1489
+
1490
+ return result_df, label_prediction
1491
+
1492
+ def produce_signals(result_df, feature_name, threshold, label_prediction):
1493
+ """
1494
+ produce signals from probabilities
1495
+
1496
+ Parameters:
1497
+ result_df (pd.DataFrame): asset data with probabilities
1498
+ feature_name (str): edge feature name
1499
+ threshold (float): edge threshold
1500
+ label_prediction (list): list of resulting label columns
1501
+
1502
+ Returns:
1503
+ result_df (pd.DataFrame): result dataframe with edges and signals
1504
+ """
1505
+ for pred_col in label_prediction:
1506
+ type_use = 'low'
1507
+ if 'down' in pred_col:
1508
+ type_use = 'up'
1509
+
1510
+ result_df[f'signal_{type_use}_{feature_name}'] = np.where(result_df[pred_col] >= threshold,1,0)
1511
+ result_df[f'acc_{type_use}_{feature_name}'] = np.where(result_df[f'signal_{type_use}_{feature_name}'] == result_df[pred_col.replace('proba_','')],1,0)
1512
+
1513
+ return result_df
1514
+
1515
+ def edge_probas_lines(data, threshold, plot = False, look_back = 750):
1516
+ """
1517
+ produce a plotly plot of edges and closing prices
1518
+
1519
+ Parameters:
1520
+ data (pd.DataFrame): asset data with edge probabilities
1521
+ plot (boolean): if true, display plot
1522
+ threshold (float): edge threshold
1523
+ look_back (int): number of rows back to display
1524
+
1525
+ Returns:
1526
+ fig (obj): plotly go object
1527
+ """
1528
+ df = data[['Date','Close','proba_target_down','proba_target_up']].iloc[-look_back:]
1529
+
1530
+ fig = make_subplots(specs=[[{"secondary_y": True}]])
1531
+ fig.add_trace(go.Scatter(x=df.Date, y=df.Close,mode='lines+markers',name='Close price'))
1532
+ fig.add_trace(go.Scatter(x=df.Date, y=df.proba_target_down,mode='lines',marker = dict(color = 'coral'),name='go down'),secondary_y=True)
1533
+ fig.add_trace(go.Scatter(x=df.Date, y=df.proba_target_up,mode='lines',marker = dict(opacity=0.1,size=80), name='go up'),secondary_y=True)
1534
+ fig.add_shape(type="line", xref="paper", yref="y2",x0=0.02, y0=threshold, x1=0.9, y1=threshold,line=dict(color="red",dash="dash"),)
1535
+ fig.update_layout(title_text="sirius - edge probabilities",width=1200,height = 500)
1536
+ if plot:
1537
+ fig.show()
1538
+ return fig
@@ -1,37 +1,36 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: virgo-modules
3
- Version: 0.0.77
3
+ Version: 0.0.79
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
7
7
  Author-email: miguelmayhem92@gmail.com
8
8
  License: MIT
9
- Platform: UNKNOWN
10
9
  Classifier: License :: OSI Approved :: MIT License
11
10
  Classifier: Programming Language :: Python :: 3.9
12
11
  Classifier: Operating System :: OS Independent
13
12
  Requires-Python: >=3.9, <3.10
14
13
  Description-Content-Type: text/markdown
15
14
  License-File: LICENSE
16
- Requires-Dist: feature-engine (==1.6.1)
17
- Requires-Dist: matplotlib (==3.6.3)
18
- Requires-Dist: mlflow (==2.1.1)
19
- Requires-Dist: numpy (==1.23.5)
20
- Requires-Dist: optuna (==3.1.0)
21
- Requires-Dist: pandas (==1.5.3)
22
- Requires-Dist: plotly (==5.15.0)
23
- Requires-Dist: rsa (==4.9)
24
- Requires-Dist: scikit-learn (==1.2.1)
25
- Requires-Dist: scipy (==1.10.0)
26
- Requires-Dist: seaborn (==0.12.2)
27
- Requires-Dist: starlette (==0.22.0)
28
- Requires-Dist: statsmodels (==0.13.5)
29
- Requires-Dist: ta (==0.10.2)
30
- Requires-Dist: yfinance (==0.2.9)
31
- Requires-Dist: hmmlearn (==0.3.0)
15
+ Requires-Dist: feature-engine ==1.6.1
16
+ Requires-Dist: matplotlib ==3.6.3
17
+ Requires-Dist: mlflow ==2.1.1
18
+ Requires-Dist: numpy ==1.23.5
19
+ Requires-Dist: optuna ==3.1.0
20
+ Requires-Dist: pandas ==1.5.3
21
+ Requires-Dist: plotly ==5.15.0
22
+ Requires-Dist: rsa ==4.9
23
+ Requires-Dist: scikit-learn ==1.2.1
24
+ Requires-Dist: scipy ==1.10.0
25
+ Requires-Dist: seaborn ==0.12.2
26
+ Requires-Dist: starlette ==0.22.0
27
+ Requires-Dist: statsmodels ==0.13.5
28
+ Requires-Dist: ta ==0.10.2
29
+ Requires-Dist: yfinance ==0.2.9
30
+ Requires-Dist: hmmlearn ==0.3.0
32
31
  Requires-Dist: boto3
33
32
  Provides-Extra: dev
34
- Requires-Dist: pytest (>=7.0) ; extra == 'dev'
33
+ Requires-Dist: pytest >=7.0 ; extra == 'dev'
35
34
 
36
35
  # Virgo Package
37
36
 
@@ -52,4 +51,3 @@ obj = stock_eda_panel(stock_code = 'PEP', n_days = 20)
52
51
  obj.get_data()
53
52
  print(obj.df.shape)
54
53
  ```
55
-
@@ -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=ll5pRs9EE20IsE5A1vA589TKzobkeA-b0d68jNTsu1U,13268
5
5
  virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
6
- virgo_modules/src/re_utils.py,sha256=fprzdQPKXdfZhWaWjuAHmTzc7BXuoPSWFny2ng-Qea0,64053
6
+ virgo_modules/src/re_utils.py,sha256=Af2ktNS-Z3Pdnp5tUAq-3N6mr0MWMd3gfsY1lPYvQe0,69517
7
7
  virgo_modules/src/ticketer_source.py,sha256=4J0y51Tv0dGzFU7qZarGBIJSFsFWfY_NDNWZI6VN2Ws,142729
8
- virgo_modules-0.0.77.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
9
- virgo_modules-0.0.77.dist-info/METADATA,sha256=ntnzAoT5-GpgQpFcqjFDcpXtT9TUV1FOO8pIsHes4tY,1484
10
- virgo_modules-0.0.77.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
11
- virgo_modules-0.0.77.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
12
- virgo_modules-0.0.77.dist-info/RECORD,,
8
+ virgo_modules-0.0.79.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
9
+ virgo_modules-0.0.79.dist-info/METADATA,sha256=OcsRxZIrV4o_tqiJ4Gb49UN4Z2iU9rlTJPc_a3I16S0,1429
10
+ virgo_modules-0.0.79.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
11
+ virgo_modules-0.0.79.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
12
+ virgo_modules-0.0.79.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5