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

@@ -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()
@@ -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
- #df = stock.history(period="max")
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 = {'n_days':self.n_days, 'begin_date':begin_date_str}
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
- #df = stock.history(period="max")
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: virgo-modules
3
- Version: 0.0.32
3
+ Version: 0.0.42
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
@@ -0,0 +1,11 @@
1
+ virgo_modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ virgo_modules/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ virgo_modules/src/aws_utils.py,sha256=zvCV_bfN8o8H3iSD-V_aYHtoKqXRD4Kt_T8HIji23WA,965
4
+ virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
5
+ virgo_modules/src/re_utils.py,sha256=KJSFqxl982OKjJk-qtyJPEB-ZcggNPYo5mloNeWrf2c,44873
6
+ virgo_modules/src/ticketer_source.py,sha256=NiK_uILuqkCM_TdBEetphtYgSjmo7WsGMmsWmAOQazs,94469
7
+ virgo_modules-0.0.42.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
8
+ virgo_modules-0.0.42.dist-info/METADATA,sha256=BDXW-DRp_lWmbelKSsjZJOg5UPei3_g-OO4LZqsetnE,1429
9
+ virgo_modules-0.0.42.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
+ virgo_modules-0.0.42.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
11
+ virgo_modules-0.0.42.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- virgo_modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- virgo_modules/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- virgo_modules/src/aws_utils.py,sha256=zvCV_bfN8o8H3iSD-V_aYHtoKqXRD4Kt_T8HIji23WA,965
4
- virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
5
- virgo_modules/src/re_utils.py,sha256=yj44T--q9F-tQWisRkelp_oIce1h3KGE0AjuSJQSZ0U,43251
6
- virgo_modules/src/ticketer_source.py,sha256=hVT2P6LD_h9GFExQfyNimxPuETsWaC-kuVU_qlomp7I,94431
7
- virgo_modules-0.0.32.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
8
- virgo_modules-0.0.32.dist-info/METADATA,sha256=zRBSYCNq2-M7V-ido3uV6KhX8QaIkYggcdUtJIiavhY,1429
9
- virgo_modules-0.0.32.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
- virgo_modules-0.0.32.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
11
- virgo_modules-0.0.32.dist-info/RECORD,,