virgo-modules 0.0.78__py3-none-any.whl → 0.0.80__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 +101 -0
- {virgo_modules-0.0.78.dist-info → virgo_modules-0.0.80.dist-info}/METADATA +1 -1
- {virgo_modules-0.0.78.dist-info → virgo_modules-0.0.80.dist-info}/RECORD +6 -6
- {virgo_modules-0.0.78.dist-info → virgo_modules-0.0.80.dist-info}/LICENSE +0 -0
- {virgo_modules-0.0.78.dist-info → virgo_modules-0.0.80.dist-info}/WHEEL +0 -0
- {virgo_modules-0.0.78.dist-info → virgo_modules-0.0.80.dist-info}/top_level.txt +0 -0
virgo_modules/src/re_utils.py
CHANGED
|
@@ -455,6 +455,60 @@ def ranking(data, weighted_features, top = 5, window = 5):
|
|
|
455
455
|
|
|
456
456
|
return top_up, top_low
|
|
457
457
|
|
|
458
|
+
def ranking_first(data, weighted_features, top = 5, window = 5):
|
|
459
|
+
'''
|
|
460
|
+
Create a ranking of assets given current signals and weighted average importance
|
|
461
|
+
|
|
462
|
+
Parameters:
|
|
463
|
+
data (pd.Dataframe): base data
|
|
464
|
+
weighted_features (dict): configuration dictionary
|
|
465
|
+
top (int): top n to get result
|
|
466
|
+
window (int): number of days to assess
|
|
467
|
+
|
|
468
|
+
Returns:
|
|
469
|
+
top_up (list): top roof signal asset
|
|
470
|
+
top_low (list): top botton signal asset
|
|
471
|
+
'''
|
|
472
|
+
features = weighted_features.keys()
|
|
473
|
+
up_columns = ['signal_up_' + x for x in features]
|
|
474
|
+
low_columns = ['signal_low_' + x for x in features]
|
|
475
|
+
|
|
476
|
+
def compute_score(df,col,window):
|
|
477
|
+
score = 0
|
|
478
|
+
for i in range(window):
|
|
479
|
+
row = df.iloc[i]
|
|
480
|
+
if (row[col] == 1) and (i == 0):
|
|
481
|
+
score += 1000
|
|
482
|
+
elif (row[col] == 1) and (i == 1):
|
|
483
|
+
score -= 200
|
|
484
|
+
elif (row[col] == 1) and (i >= 2):
|
|
485
|
+
score -= 50
|
|
486
|
+
return score
|
|
487
|
+
|
|
488
|
+
ticket_list= list(data.Ticket.unique())
|
|
489
|
+
result = dict()
|
|
490
|
+
for ticket in ticket_list:
|
|
491
|
+
result[ticket] = dict()
|
|
492
|
+
df = data[data.Ticket == ticket].sort_values('Date').iloc[-window:]
|
|
493
|
+
|
|
494
|
+
for col in low_columns:
|
|
495
|
+
df = df.sort_values('Date', ascending = False)
|
|
496
|
+
score = compute_score(df,col,window)
|
|
497
|
+
result[ticket][col] = score
|
|
498
|
+
for col in up_columns:
|
|
499
|
+
score = 0
|
|
500
|
+
df = df.sort_values('Date', ascending = False)
|
|
501
|
+
score = compute_score(df,col,window)
|
|
502
|
+
result[ticket][col] = score
|
|
503
|
+
|
|
504
|
+
df = pd.DataFrame(result).T
|
|
505
|
+
df['up_signas'] = df[up_columns].sum(axis=1)
|
|
506
|
+
df['low_signas'] = df[low_columns].sum(axis=1)
|
|
507
|
+
|
|
508
|
+
top_up = list(df.sort_values('up_signas', ascending = False).index)[:top]
|
|
509
|
+
top_low = list(df.sort_values('low_signas', ascending = False).index)[:top]
|
|
510
|
+
return top_up, top_low, df
|
|
511
|
+
|
|
458
512
|
def produce_dashboard(data, columns , ticket_list, show_plot = True, nrows = 150,save_name = False, save_path = False, save_aws = False, aws_credential = False):
|
|
459
513
|
'''
|
|
460
514
|
produce dashboard using signals and list of assets
|
|
@@ -520,6 +574,53 @@ def produce_dashboard(data, columns , ticket_list, show_plot = True, nrows = 150
|
|
|
520
574
|
# upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = f'multi_dashboards/'+save_name+'.json',input_path = save_path+save_name+'.json')
|
|
521
575
|
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
576
|
|
|
577
|
+
def produce_edges_dashboard(dataframe, ticket_list, save_name, show_plot = False, save_path = False, save_aws = False, aws_credentials = False):
|
|
578
|
+
'''
|
|
579
|
+
produce dashboard using signals and list of assets
|
|
580
|
+
|
|
581
|
+
Parameters:
|
|
582
|
+
dataframe (pd.Dataframe): base data
|
|
583
|
+
ticket_list (list): list of assets
|
|
584
|
+
save_name (str): dashboad name resulting file
|
|
585
|
+
show_plot (boolean): if true, display plot
|
|
586
|
+
save_path (str): local path for saving e.g r'C:/path/to/the/file/'
|
|
587
|
+
save_aws (str): remote key in s3 bucket path e.g. 'path/to/file/'
|
|
588
|
+
aws_credential (dict): aws credentials
|
|
589
|
+
|
|
590
|
+
Returns:
|
|
591
|
+
None
|
|
592
|
+
'''
|
|
593
|
+
n_assets = len(ticket_list)
|
|
594
|
+
|
|
595
|
+
result_json_name = save_name
|
|
596
|
+
cols_length = 4
|
|
597
|
+
rows_length = math.ceil(n_assets/2)
|
|
598
|
+
|
|
599
|
+
subtitles = list()
|
|
600
|
+
for x in ticket_list:
|
|
601
|
+
subtitles.append(x)
|
|
602
|
+
subtitles.append(x + ' signal')
|
|
603
|
+
|
|
604
|
+
fig = make_subplots(rows=rows_length, cols=cols_length,vertical_spacing = 0.01, horizontal_spacing = 0.03, shared_xaxes=True, subplot_titles = subtitles)
|
|
605
|
+
|
|
606
|
+
for i,ticket in enumerate(ticket_list):
|
|
607
|
+
j = i%2*2 +1
|
|
608
|
+
i = i+1
|
|
609
|
+
i_r = math.ceil(i/2)
|
|
610
|
+
|
|
611
|
+
show_legend = True if i == 1 else False
|
|
612
|
+
|
|
613
|
+
df = dataframe[dataframe.asset == ticket]
|
|
614
|
+
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)
|
|
615
|
+
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)
|
|
616
|
+
fig.update_layout(height=rows_length*300, width=1500, title_text = f'dashboard top {n_assets} tickets')
|
|
617
|
+
|
|
618
|
+
if save_path:
|
|
619
|
+
fig.write_json(save_path+result_json_name)
|
|
620
|
+
if show_plot:
|
|
621
|
+
fig.show()
|
|
622
|
+
if save_path and save_aws:
|
|
623
|
+
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
624
|
|
|
524
625
|
def rank_by_return(data, lag_days, top_n = 5):
|
|
525
626
|
'''
|
|
@@ -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=
|
|
6
|
+
virgo_modules/src/re_utils.py,sha256=aOWtQTUusAjIYEQdCEWezQbfB4kOOohczIhNbWGne5Q,71586
|
|
7
7
|
virgo_modules/src/ticketer_source.py,sha256=4J0y51Tv0dGzFU7qZarGBIJSFsFWfY_NDNWZI6VN2Ws,142729
|
|
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.
|
|
8
|
+
virgo_modules-0.0.80.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
|
|
9
|
+
virgo_modules-0.0.80.dist-info/METADATA,sha256=8XxXUCdtdAP4PotfMIAFshmWofJ6WKmcnTeNqEPYNUY,1429
|
|
10
|
+
virgo_modules-0.0.80.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
+
virgo_modules-0.0.80.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
|
|
12
|
+
virgo_modules-0.0.80.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|