Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,21 +55,21 @@ with st.expander("Click here to read more about the methodology", expanded=False
|
|
| 55 |
""")
|
| 56 |
|
| 57 |
if st.sidebar.button('Run Analysis'):
|
| 58 |
-
|
| 59 |
-
def get_data(ticker, start, end):
|
| 60 |
-
data = yf.download(ticker, start=start, end=end)
|
| 61 |
-
return data['Close'].squeeze()
|
| 62 |
-
|
| 63 |
-
stock_data = get_data(ticker, start_date, end_date)
|
| 64 |
|
| 65 |
if not stock_data.empty:
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
current_price = stock_data.iloc[-1]
|
| 68 |
|
| 69 |
# Method 1: Volatility over dynamic periods
|
| 70 |
fig1 = go.Figure()
|
| 71 |
plot_data = stock_data[-rolling_window:]
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
st.markdown("""
|
| 75 |
### Method 1: Dynamic Volatility
|
|
|
|
| 55 |
""")
|
| 56 |
|
| 57 |
if st.sidebar.button('Run Analysis'):
|
| 58 |
+
stock_data = yf.download(ticker, start=start_date, end=end_date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
if not stock_data.empty:
|
| 61 |
+
# Use "Close" since adjusted close no longer exists
|
| 62 |
+
stock_data = stock_data['Close'].squeeze()
|
| 63 |
+
stock_data = pd.Series(stock_data) # ensure it is a Series
|
| 64 |
+
stock_data['Returns'] = stock_data.pct_change()
|
| 65 |
current_price = stock_data.iloc[-1]
|
| 66 |
|
| 67 |
# Method 1: Volatility over dynamic periods
|
| 68 |
fig1 = go.Figure()
|
| 69 |
plot_data = stock_data[-rolling_window:]
|
| 70 |
+
# Convert last date to Timestamp before adding DateOffset
|
| 71 |
+
last_date = pd.to_datetime(plot_data.index[-1])
|
| 72 |
+
date_range = pd.date_range(last_date + pd.DateOffset(1), periods=time_horizon, freq='D')
|
| 73 |
|
| 74 |
st.markdown("""
|
| 75 |
### Method 1: Dynamic Volatility
|