Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -55,19 +55,18 @@ with st.expander("Click here to read more about the methodology", expanded=False
|
|
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" column; adjusted close no longer exists. Squeeze to ensure a 1D Series.
|
62 |
stock_data = stock_data['Close'].squeeze()
|
63 |
-
|
64 |
-
|
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 |
-
#
|
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 |
|
|
|
55 |
""")
|
56 |
|
57 |
if st.sidebar.button('Run Analysis'):
|
58 |
+
# Download data; use "Close" and squeeze to ensure a 1D Series.
|
59 |
stock_data = yf.download(ticker, start=start_date, end=end_date)
|
|
|
60 |
if not stock_data.empty:
|
|
|
61 |
stock_data = stock_data['Close'].squeeze()
|
62 |
+
# Compute returns separately (do not add to stock_data to avoid modifying the index)
|
63 |
+
returns = stock_data.pct_change()
|
64 |
current_price = stock_data.iloc[-1]
|
65 |
|
66 |
# Method 1: Volatility over dynamic periods
|
67 |
fig1 = go.Figure()
|
68 |
plot_data = stock_data[-rolling_window:]
|
69 |
+
# Ensure the last index is a Timestamp (avoid concatenation error)
|
70 |
last_date = pd.to_datetime(plot_data.index[-1])
|
71 |
date_range = pd.date_range(last_date + pd.DateOffset(1), periods=time_horizon, freq='D')
|
72 |
|