From 1c57e0c6e9686a5403d61c88e400821ae5471626 Mon Sep 17 00:00:00 2001 From: Suchismit Ghosh Date: Fri, 27 Dec 2024 22:21:48 -0500 Subject: [PATCH] Code exit bug --- example_yfinance.py | 101 ------------------ .../__pycache__/base.cpython-312.pyc | Bin 10097 -> 10138 bytes src/data/abstracts/base.py | 2 +- src/data/core/struct.py | 2 +- 4 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 example_yfinance.py diff --git a/example_yfinance.py b/example_yfinance.py deleted file mode 100644 index c62e62e..0000000 --- a/example_yfinance.py +++ /dev/null @@ -1,101 +0,0 @@ -# hindsight/main.py - -import xarray as xr -import xarray_jax as xj -import numpy as np -import pandas as pd -import jax.numpy as jnp -import equinox as eqx -from functools import partial - -from src import DataManager - -def main(): - data_manager = DataManager() - - print(data_manager.list_available_data_paths()) - - # Define data requests with configurations - data_requests = [ - { - 'data_path': 'yfinance/equities/market/historical', - 'config': { - 'symbols': [ - 'AAPL', 'MSFT', 'AMZN', 'GOOGL', 'FB', 'TSLA', 'BRK.B', 'JPM', - 'JNJ', 'V', 'UNH', 'NVDA', 'HD', 'PG', 'MA', 'DIS', 'PYPL', - 'VZ', 'ADBE', 'NFLX', 'INTC', 'KO', 'PFE', 'T', 'CMCSA', - 'PEP', 'MRK', 'ABT', 'XOM', 'CSCO', 'CVX', 'NKE', 'WMT', - 'ORCL', 'TMO', 'ACN', 'ABBV', 'LLY', 'DHR', 'CRM', 'TXN', - 'COST', 'AVGO', 'QCOM', 'MDT', 'PM', 'AMGN', 'NEE', 'HON', - 'UNP', 'MS', 'BAC', 'BA', 'BMY', 'SBUX', 'C', 'LOW', 'IBM', - 'MMM', 'RTX', 'LMT', 'INTU', 'GE', 'BLK', 'AXP', 'SPGI', - 'GS', 'CAT', 'PLD', 'MDLZ', 'ISRG', 'CVS', 'NOW', 'MO', - 'CHTR', 'BKNG', 'TGT', 'AMAT', 'SYK', 'ZTS', 'DE', 'ADP', - 'GM', 'ADI', 'GILD', 'ADSK', 'F', 'MU', 'ATVI', 'APD', - 'EL', 'CSX', 'BSX', 'PNC', 'EW', 'CI', 'FDX', 'MMC', 'SHW', - 'HUM', 'DUK', 'SO', 'ICE', 'LRCX', 'KLAC', 'TRV', 'SPG', - 'COF', 'AIG', 'ECL', 'WM', 'ITW', 'REGN', 'BIIB', 'BK', - 'MET', 'MCO', 'NSC', 'AON', 'IDXX', 'SLB', 'PRU', 'APTV', - 'D', 'PSA', 'PH', 'DD', 'VLO', 'EXC', 'PEG', 'ROP', 'MAR', - 'SBAC', 'OXY', 'VRSK', 'CTAS', 'TDG', 'FTNT', 'ANET', 'FRC', - ], - 'start_date': '2021-01-01', - 'end_date': '2023-01-31', - 'frequency': '1d', - } - } - ] - - dataset = data_manager.get_data( - data_requests=data_requests - ) - - print(dataset) - - # Define a function to compute Exponential Moving Average (EMA) - # This function will be used with the u_roll method for efficient computation - # @partial(jax.jit, static_argnames=['window_size']) - # def ema(i: int, carry, block: jnp.ndarray, window_size: int): - # """ - # Compute the Exponential Moving Average (EMA) for a given window. - - # This function is designed to work with JAX's JIT compilation and - # the u_roll method defined in the Tensor class. It computes the EMA - # efficiently over a rolling window of data. - - # Args: - # i (int): Current index in the time series - # state (tuple): Contains current values, carry (previous EMA), and data block - # window_size (int): Size of the moving window - - # Returns: - # tuple: Updated state (new EMA value, carry, and data block) - # """ - - # # Initialize the first value - # if carry is None: - # # Compute the sum of the first window - # current_window_sum = block[:window_size].reshape(-1, - # block.shape[1], - # block.shape[2]).sum(axis=0) - - - # return (current_window_sum * (1/window_size), current_window_sum * (1/window_size)) - - # # Get the current price - # current_price = block[i] - - # # Compute the new EMA - # # EMA = α * current_price + (1 - α) * previous_EMA - # # where α = 1 / (window_size) - # alpha = 1 / window_size - - # new_ema = alpha * current_price + (1 - alpha) * carry - - # return (new_ema, new_ema) - - # rolled = dataset.dt.rolling(dim='time', window=10).reduce(func=ema) - - -if __name__ == "__main__": - main() diff --git a/src/data/abstracts/__pycache__/base.cpython-312.pyc b/src/data/abstracts/__pycache__/base.cpython-312.pyc index 2ebcbf97f4ca2348f5d8e18fcf373c84e45db7f4..056fd3a05605749b6a648e487e21613a6333d488 100644 GIT binary patch delta 400 zcmez9H_M;*G%qg~0}#y2%TF)g$SWYjxMi}OOtVx8J4h4+Qdn0rLRgFpoD4OLlMg70 zOn%BOGWo0wzcVjH2AQm3NnuN2PvKa@xtay0uY@0_qJ}kvZ8Z~wXUb5^Rw6igFON)p z4RZ}!3fCI$)yyz0DLfzuQ_9Ft$)n6*$WY8!&cw(N$-oGNl{^*9kqqUG$_ynUFymDi ziX>{;ksQxk!#tG~5Qn6b7V{xR4iH<5)ybIskUlerZ44&OIGx3r583lM3o#!SVs#eZ?5JqK F1_1kLPS5}V delta 361 zcmbQ`|Iv^4G%qg~0}#aL=BLMQ19L}C0Co*MSq z40D-QGs4V`WJuwzWv^qe1ey+_%NffVfab6Q4btS@d|ftyak7(q)8v!#`bB-00$$r}|~O&D#Qv>6WCN;=6i9}?pLvJc6#I%%*UQeg(M cHNd1cr!x=pArn4lcILzEtj;`}vlI>30LrUHnE(I) diff --git a/src/data/abstracts/base.py b/src/data/abstracts/base.py index 5959f53..c57143f 100644 --- a/src/data/abstracts/base.py +++ b/src/data/abstracts/base.py @@ -182,7 +182,7 @@ def save_to_cache( netcdf_path = base_path.with_suffix('.nc') metadata_path = base_path.with_suffix('.json') netcdf_path.parent.mkdir(parents=True, exist_ok=True) - + print('saving...') try: # Add params to ds.attrs ds.attrs.update(params) diff --git a/src/data/core/struct.py b/src/data/core/struct.py index 32461e0..e89478e 100644 --- a/src/data/core/struct.py +++ b/src/data/core/struct.py @@ -235,7 +235,7 @@ def from_table( if (i > 3): break - quit(0) + # quit(0) # OVERLOOK STOP data = data.reindex(full_index)