virgo-modules 0.0.32__tar.gz → 0.0.42__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.32 → virgo_modules-0.0.42}/PKG-INFO +1 -1
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/setup.py +1 -1
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/re_utils.py +45 -3
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/ticketer_source.py +10 -8
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -1
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/LICENSE +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/README.md +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/setup.cfg +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/requires.txt +0 -0
- {virgo_modules-0.0.32 → virgo_modules-0.0.42}/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.42",
|
|
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"),
|
|
@@ -2,6 +2,7 @@ import matplotlib.pyplot as plt
|
|
|
2
2
|
import matplotlib.gridspec as gridspec
|
|
3
3
|
import seaborn as sns; sns.set()
|
|
4
4
|
import matplotlib.patheffects as path_effects
|
|
5
|
+
from matplotlib.dates import DateFormatter
|
|
5
6
|
|
|
6
7
|
import plotly.express as px
|
|
7
8
|
from plotly.subplots import make_subplots
|
|
@@ -403,7 +404,7 @@ def rank_by_return(data, lag_days, top_n = 5):
|
|
|
403
404
|
|
|
404
405
|
return result
|
|
405
406
|
|
|
406
|
-
def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_available: object = False) -> object:
|
|
407
|
+
def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_available: object = False, data_window:str = '5y') -> object:
|
|
407
408
|
"""
|
|
408
409
|
this functions runs the stock_eda_panel
|
|
409
410
|
it is shared between train model and predictions
|
|
@@ -416,7 +417,7 @@ def get_data(ticker_name:str, ticket_settings:dict, n_days:int = False, hmm_avai
|
|
|
416
417
|
returns: stock eda panel
|
|
417
418
|
"""
|
|
418
419
|
|
|
419
|
-
object_stock = stock_eda_panel(ticker_name , n_days )
|
|
420
|
+
object_stock = stock_eda_panel(ticker_name , n_days, data_window)
|
|
420
421
|
object_stock.get_data()
|
|
421
422
|
|
|
422
423
|
# computing features if they exists in the ticketr settings
|
|
@@ -898,4 +899,45 @@ class produce_plotly_plots:
|
|
|
898
899
|
if self.show_plot:
|
|
899
900
|
fig.show()
|
|
900
901
|
if self.save_path and self.save_aws:
|
|
901
|
-
upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = f'market_plots/{self.ticket_name}/'+result_json_name ,input_path = self.save_path+result_json_name)
|
|
902
|
+
upload_file_to_aws(bucket = 'VIRGO_BUCKET', key = f'market_plots/{self.ticket_name}/'+result_json_name ,input_path = self.save_path+result_json_name)
|
|
903
|
+
|
|
904
|
+
def plot_hmm_analysis_logger(data_frame,test_data_size, save_path = False, show_plot = True):
|
|
905
|
+
|
|
906
|
+
df = data_frame
|
|
907
|
+
df_ = df[['Date','hmm_feature','Close',"chain_return"]].sort_values('Date')
|
|
908
|
+
fig, axs = plt.subplots(1,2,figsize=(10,4))
|
|
909
|
+
df__ = df_.iloc[:-test_data_size,]
|
|
910
|
+
sns.boxplot(data=df__, x="hmm_feature", y="chain_return",ax = axs[0]).set_title('train dist')
|
|
911
|
+
df__ = df_.iloc[-test_data_size:,]
|
|
912
|
+
sns.boxplot(data=df__ , x="hmm_feature", y="chain_return",ax = axs[1]).set_title('test dist')
|
|
913
|
+
if save_path:
|
|
914
|
+
plt.savefig(save_path)
|
|
915
|
+
if not show_plot:
|
|
916
|
+
plt.close()
|
|
917
|
+
|
|
918
|
+
def plot_hmm_tsanalysis_logger(data_frame, test_data_size,save_path = False, show_plot = True):
|
|
919
|
+
|
|
920
|
+
df = data_frame
|
|
921
|
+
df_ = df[['Date','hmm_feature','Close',"chain_return"]].sort_values('Date')
|
|
922
|
+
states = list(df_['hmm_feature'].unique())
|
|
923
|
+
states.sort()
|
|
924
|
+
|
|
925
|
+
if test_data_size:
|
|
926
|
+
df__ = df_.iloc[-test_data_size:,]
|
|
927
|
+
date_limit = pd.Timestamp(str(df__.Date.min().strftime('%Y-%m-%d')))
|
|
928
|
+
|
|
929
|
+
fig, ax1 = plt.subplots(figsize=(10,4))
|
|
930
|
+
ax1.plot(df_['Date'],df_["Close"])
|
|
931
|
+
|
|
932
|
+
for state in states:
|
|
933
|
+
df__ = df_[df_.hmm_feature == state]
|
|
934
|
+
ax1.scatter(df__['Date'],df__["Close"], label = state)
|
|
935
|
+
formatter = DateFormatter('%Y-%m-%d')
|
|
936
|
+
if test_data_size:
|
|
937
|
+
plt.axvline(x=date_limit, color = 'r')
|
|
938
|
+
fig.legend()
|
|
939
|
+
fig.autofmt_xdate()
|
|
940
|
+
if save_path:
|
|
941
|
+
plt.savefig(save_path)
|
|
942
|
+
if not show_plot:
|
|
943
|
+
plt.close()
|
{virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules/src/ticketer_source.py
RENAMED
|
@@ -152,12 +152,13 @@ def states_relevance_score(data, default_benchmark_sd = 0.00003, t_threshold = 2
|
|
|
152
152
|
|
|
153
153
|
class stock_eda_panel(object):
|
|
154
154
|
|
|
155
|
-
def __init__(self, stock_code, n_days):
|
|
155
|
+
def __init__(self, stock_code, n_days, data_window = '5y'):
|
|
156
156
|
self.stock_code = stock_code
|
|
157
157
|
self.n_days = n_days
|
|
158
158
|
self.today = datetime.date.today()
|
|
159
159
|
self.features = list()
|
|
160
160
|
self.signals = list()
|
|
161
|
+
self.data_window = data_window
|
|
161
162
|
|
|
162
163
|
def augmented_dickey_fuller_statistics(self,time_series, label):
|
|
163
164
|
result = adfuller(time_series.dropna().values)
|
|
@@ -168,8 +169,7 @@ class stock_eda_panel(object):
|
|
|
168
169
|
begin_date_str = begin_date.strftime('%Y-%m-%d')
|
|
169
170
|
|
|
170
171
|
stock = yf.Ticker(self.stock_code)
|
|
171
|
-
|
|
172
|
-
df = stock.history(period='5y')
|
|
172
|
+
df = stock.history(period=self.data_window)
|
|
173
173
|
|
|
174
174
|
df = df.sort_values('Date')
|
|
175
175
|
df.reset_index(inplace=True)
|
|
@@ -177,7 +177,12 @@ class stock_eda_panel(object):
|
|
|
177
177
|
df['Date'] = pd.to_datetime(df['Date'])
|
|
178
178
|
|
|
179
179
|
df = df[df.Date >= begin_date_str ]
|
|
180
|
-
self.settings_general = {
|
|
180
|
+
self.settings_general = {
|
|
181
|
+
'n_days':self.n_days,
|
|
182
|
+
'begin_date':begin_date_str,
|
|
183
|
+
'data_window': self.data_window,
|
|
184
|
+
'execution_date': self.today.strftime('%Y-%m-%d')
|
|
185
|
+
}
|
|
181
186
|
self.df = df
|
|
182
187
|
|
|
183
188
|
### cleaning volume
|
|
@@ -226,8 +231,6 @@ class stock_eda_panel(object):
|
|
|
226
231
|
df["lower"] = df['Close_roll_mean'] - df["Close_roll_std"]*2
|
|
227
232
|
|
|
228
233
|
df = df[df.Date >= begin_date_str ]
|
|
229
|
-
self.settings_general = {'n_days':self.n_days, 'begin_date':begin_date_str}
|
|
230
|
-
self.df = df
|
|
231
234
|
|
|
232
235
|
fig = make_subplots(rows=1, cols=1,vertical_spacing = 0.1,shared_xaxes=True,
|
|
233
236
|
subplot_titles=(
|
|
@@ -562,8 +565,7 @@ class stock_eda_panel(object):
|
|
|
562
565
|
begin_date_str = begin_date.strftime('%Y-%m-%d')
|
|
563
566
|
|
|
564
567
|
stock = yf.Ticker(self.pair_symbol)
|
|
565
|
-
|
|
566
|
-
df = stock.history(period='5y')
|
|
568
|
+
df = stock.history(period=self.data_window)
|
|
567
569
|
df = df.sort_values('Date')
|
|
568
570
|
df.reset_index(inplace=True)
|
|
569
571
|
df['Date'] = pd.to_datetime(df['Date'], format='mixed',utc=True).dt.date
|
|
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.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.0.32 → virgo_modules-0.0.42}/virgo_app/virgo_modules.egg-info/top_level.txt
RENAMED
|
File without changes
|