Skip to content

Commit 8a747f8

Browse files
DJIA became ^DJI - Some major changes in data_generation - Some markdown and dates in notebook
1 parent e1afdc9 commit 8a747f8

File tree

4 files changed

+7877
-8824
lines changed

4 files changed

+7877
-8824
lines changed

data_generation.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@
1010
start_date = '1988-01-01'
1111

1212
# Dealing with some missing values in Dow Jones index
13-
DowJones_df = yf.download('DJIA',start_date,str(yesterday))
14-
Nasdaq_df = yf.download('^IXIC',start_date,str(yesterday))
15-
diff = Nasdaq_df.index.difference(DowJones_df.index)
16-
# Display Dow Jones missing values
17-
print(diff)
18-
19-
DowJones = np.asarray(DowJones_df.Close).reshape(-1,1)
20-
Nasdaq = np.asarray(Nasdaq_df.drop(diff).Close).reshape(-1,1)
21-
Russell = np.asarray(yf.download('^RUT',start_date,str(yesterday)).drop(diff).Close).reshape(-1,1)
22-
SP500 = np.asarray(yf.download('^GSPC',start_date,str(yesterday)).drop(diff).Close).reshape(-1,1)
23-
24-
# Ensure the data have the same shape
25-
assert DowJones.shape == Nasdaq.shape == Russell.shape == SP500.shape
26-
27-
ts = np.concatenate((DowJones, Nasdaq, Russell, SP500), axis=1)
13+
df = yf.download('^DJI ^IXIC ^GSPC ^RUT',start_date,str(yesterday))
14+
# Dealing with some missing values
15+
df = df.Close.dropna(axis=0)
16+
ts = np.asarray(df)
2817

2918
# Calculate the log returns
3019
ratios = np.log(ts / np.roll(ts, -1, axis=0))[:-1]
3120

3221
# Put the returns in a dataframe
33-
tsdf = pd.DataFrame(ratios, index = DowJones_df.index[:-1])
22+
tsdf = pd.DataFrame(ratios, index = df.index[:-1])
3423
tsdf.to_csv("latest.csv")

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: tda_financial_time_series
22
channels:
33
- conda-forge
44
dependencies:
5-
- gudhi==3.5.0
5+
- gudhi>=3.5.0
66
- scikit-learn
77
- plotly
88
- numpy

0 commit comments

Comments
 (0)