virgo-modules 0.0.76__tar.gz → 0.0.78__tar.gz
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-0.0.76 → virgo_modules-0.0.78}/PKG-INFO +1 -1
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/setup.py +1 -1
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/re_utils.py +72 -1
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/ticketer_source.py +6 -6
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -1
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/LICENSE +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/README.md +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/setup.cfg +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/edge_utils.py +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/requires.txt +0 -0
- {virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@ with open("virgo_app/README.md", "r") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="virgo_modules",
|
|
8
|
-
version="0.0.
|
|
8
|
+
version="0.0.78",
|
|
9
9
|
description="data processing and statistical modeling using stock market data",
|
|
10
10
|
package_dir={"": "virgo_app"},
|
|
11
11
|
packages=find_packages(where="virgo_app"),
|
|
@@ -1389,6 +1389,7 @@ def save_edge_model(data, save_path = False, save_aws = False, show_result = Fal
|
|
|
1389
1389
|
if show_result:
|
|
1390
1390
|
print(curent_edge)
|
|
1391
1391
|
|
|
1392
|
+
## this function is going to be split and deprecated
|
|
1392
1393
|
def create_feature_edge(model, data,feature_name, threshold, target_variables):
|
|
1393
1394
|
'''
|
|
1394
1395
|
get latest edge execution and edge probability
|
|
@@ -1417,4 +1418,74 @@ def create_feature_edge(model, data,feature_name, threshold, target_variables):
|
|
|
1417
1418
|
result_df[f'signal_{type_use}_{feature_name}'] = np.where(result_df[pred_col] >= threshold,1,0)
|
|
1418
1419
|
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
1420
|
|
|
1420
|
-
return result_df
|
|
1421
|
+
return result_df
|
|
1422
|
+
|
|
1423
|
+
def produce_probas(model,data, target_variables):
|
|
1424
|
+
"""
|
|
1425
|
+
produce probabilities given a model
|
|
1426
|
+
|
|
1427
|
+
Parameters:
|
|
1428
|
+
model (obj): edge model artifact
|
|
1429
|
+
data (pd.DataFrame): asset data
|
|
1430
|
+
target_variables (list): names of the target columns
|
|
1431
|
+
|
|
1432
|
+
Returns:
|
|
1433
|
+
result_df (pd.DataFrame): result dataframe with edges
|
|
1434
|
+
label_prediction (list): list of resulting label columns
|
|
1435
|
+
"""
|
|
1436
|
+
label_prediction = ['proba_'+x for x in target_variables]
|
|
1437
|
+
predictions = model.predict_proba(data)
|
|
1438
|
+
predictions = pd.DataFrame(predictions, columns = label_prediction, index = data.index)
|
|
1439
|
+
|
|
1440
|
+
result_df = pd.concat([data, predictions], axis=1)
|
|
1441
|
+
result_df = result_df[['Date'] + target_variables + label_prediction]
|
|
1442
|
+
|
|
1443
|
+
return result_df, label_prediction
|
|
1444
|
+
|
|
1445
|
+
def produce_signals(result_df, feature_name, threshold, label_prediction):
|
|
1446
|
+
"""
|
|
1447
|
+
produce signals from probabilities
|
|
1448
|
+
|
|
1449
|
+
Parameters:
|
|
1450
|
+
result_df (pd.DataFrame): asset data with probabilities
|
|
1451
|
+
feature_name (str): edge feature name
|
|
1452
|
+
threshold (float): edge threshold
|
|
1453
|
+
label_prediction (list): list of resulting label columns
|
|
1454
|
+
|
|
1455
|
+
Returns:
|
|
1456
|
+
result_df (pd.DataFrame): result dataframe with edges and signals
|
|
1457
|
+
"""
|
|
1458
|
+
for pred_col in label_prediction:
|
|
1459
|
+
type_use = 'low'
|
|
1460
|
+
if 'down' in pred_col:
|
|
1461
|
+
type_use = 'up'
|
|
1462
|
+
|
|
1463
|
+
result_df[f'signal_{type_use}_{feature_name}'] = np.where(result_df[pred_col] >= threshold,1,0)
|
|
1464
|
+
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)
|
|
1465
|
+
|
|
1466
|
+
return result_df
|
|
1467
|
+
|
|
1468
|
+
def edge_probas_lines(data, threshold, plot = False, look_back = 750):
|
|
1469
|
+
"""
|
|
1470
|
+
produce a plotly plot of edges and closing prices
|
|
1471
|
+
|
|
1472
|
+
Parameters:
|
|
1473
|
+
data (pd.DataFrame): asset data with edge probabilities
|
|
1474
|
+
plot (boolean): if true, display plot
|
|
1475
|
+
threshold (float): edge threshold
|
|
1476
|
+
look_back (int): number of rows back to display
|
|
1477
|
+
|
|
1478
|
+
Returns:
|
|
1479
|
+
fig (obj): plotly go object
|
|
1480
|
+
"""
|
|
1481
|
+
df = data[['Date','Close','proba_target_down','proba_target_up']].iloc[-look_back:]
|
|
1482
|
+
|
|
1483
|
+
fig = make_subplots(specs=[[{"secondary_y": True}]])
|
|
1484
|
+
fig.add_trace(go.Scatter(x=df.Date, y=df.Close,mode='lines+markers',name='Close price'))
|
|
1485
|
+
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)
|
|
1486
|
+
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)
|
|
1487
|
+
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"),)
|
|
1488
|
+
fig.update_layout(title_text="sirius - edge probabilities",width=1200,height = 500)
|
|
1489
|
+
if plot:
|
|
1490
|
+
fig.show()
|
|
1491
|
+
return fig
|
{virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules/src/ticketer_source.py
RENAMED
|
@@ -2734,11 +2734,11 @@ class signal_analyser_object:
|
|
|
2734
2734
|
)
|
|
2735
2735
|
)
|
|
2736
2736
|
df = df[~df.signal_type.isna()]
|
|
2737
|
-
# df['Date'] = df.index
|
|
2738
2737
|
df['lag_Date'] = df['Date'].shift(1)
|
|
2738
|
+
df['lag_signal_type'] = df['signal_type'].shift(1)
|
|
2739
2739
|
df['span'] = (pd.to_datetime(df['Date']) - pd.to_datetime(df['lag_Date'])).dt.days - 1
|
|
2740
|
-
df['break'] = np.where(df['span'] > 3, 1, 0)
|
|
2741
|
-
df['break'] = np.where(df['
|
|
2740
|
+
df['break'] = np.where((df['span'] > 3) & (df['lag_signal_type'] == df['signal_type']), 1, 0)
|
|
2741
|
+
df['break'] = np.where((df['lag_signal_type'] != df['signal_type']), 1, df['break'])
|
|
2742
2742
|
|
|
2743
2743
|
df['chain_id'] = df.sort_values(['Date']).groupby(['break']).cumcount() + 1
|
|
2744
2744
|
df['chain_id'] = np.where(df['break'] == 1, df['chain_id'], np.nan )
|
|
@@ -2861,11 +2861,11 @@ class signal_analyser_object:
|
|
|
2861
2861
|
)
|
|
2862
2862
|
)
|
|
2863
2863
|
df2 = df2[~df2.signal_type.isna()]
|
|
2864
|
-
# df2['Date_'] = df2.index
|
|
2865
2864
|
df2['lag_Date'] = df2['Date'].shift(1)
|
|
2865
|
+
df2['lag_signal_type'] = df2['signal_type'].shift(1)
|
|
2866
2866
|
df2['span'] = (pd.to_datetime(df2['Date']) - pd.to_datetime(df2['lag_Date'])).dt.days - 1
|
|
2867
|
-
df2['break'] = np.where(df2['span'] > 3, 1, 0)
|
|
2868
|
-
df2['break'] = np.where(df2['
|
|
2867
|
+
df2['break'] = np.where((df2['span'] > 3) & (df2['lag_signal_type'] == df2['signal_type']), 1, 0)
|
|
2868
|
+
df2['break'] = np.where((df2['lag_signal_type'] != df2['signal_type']), 1, df2['break'])
|
|
2869
2869
|
|
|
2870
2870
|
df2['chain_id'] = df2.sort_values(['Date']).groupby(['break']).cumcount() + 1
|
|
2871
2871
|
df2['chain_id'] = np.where(df2['break'] == 1, df2['chain_id'], np.nan )
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.0.76 → virgo_modules-0.0.78}/virgo_app/virgo_modules.egg-info/top_level.txt
RENAMED
|
File without changes
|