Victorlopo21 commited on
Commit
61a2d96
·
1 Parent(s): 2f897d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -1
app.py CHANGED
@@ -120,7 +120,41 @@ st.write("""
120
  Shown is the historical data of the prices (can be adapted with the values from the sidebar)
121
  """)
122
 
123
- temp_df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
 
126
 
 
120
  Shown is the historical data of the prices (can be adapted with the values from the sidebar)
121
  """)
122
 
123
+ today = date.today()
124
+ days_ago = today - timedelta(days=25)
125
+
126
+ # we get the last 30 days and keep just the last working days, which have prices
127
+ nasdaq = yf.Ticker("^IXIC")
128
+ hist = nasdaq.history(start=days_ago, end=today)
129
+ hist = hist.drop(columns=['Dividends', 'Stock Splits'])
130
+
131
+ # keeping the last working days data points
132
+ hist = hist[-working_days:]
133
+
134
+
135
+ inflation = []
136
+ for t in hist.index:
137
+ inflation.append(get_rate("USD", "EUR", t))
138
+
139
+ cpi_items_df = cpi.series.get(seasonally_adjusted=False).to_dataframe()
140
+ cpi_items_df = cpi_items_df[cpi_items_df['period_type']=='monthly']
141
+ cpi_items_df['date'] = pd.to_datetime(cpi_items_df['date'])
142
+ cpi_items_df = cpi_items_df.set_index('date')
143
+ cpi_df = cpi_items_df['value'].loc['2022':'2023']
144
+
145
+ cpi_col = []
146
+ for x in hist.index:
147
+ # ts = datetime(x.year, x.month, 1)
148
+
149
+ # just adding the latest inflation rate
150
+ cpi_col.append(cpi_df[-1])
151
+
152
+ hist['Inflation'] = inflation
153
+ hist['CPI'] = cpi_col
154
+ hist['Quarter_end'] = np.where(hist.index.month%3==0,1,0)
155
+
156
+ hist
157
+
158
 
159
 
160