Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,7 +109,6 @@ st.title('Pattern Recognition in Asset Prices')
|
|
| 109 |
st.sidebar.title("Input Parameters")
|
| 110 |
|
| 111 |
with st.sidebar.expander("How to Use", expanded=False):
|
| 112 |
-
#st.sidebar.subheader("How to Use")
|
| 113 |
st.markdown("""
|
| 114 |
1. Select the pattern recognition method you want to use.
|
| 115 |
2. Set the stock ticker or crypto pair, date range, and other parameters.
|
|
@@ -289,11 +288,16 @@ def run_ta_dtw():
|
|
| 289 |
st.session_state.results_ta_dtw = figs
|
| 290 |
|
| 291 |
if st.sidebar.button('Run Analysis'):
|
| 292 |
-
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
st.session_state.price_data = st.session_state.data['Close']
|
| 295 |
st.session_state.price_data_pct_change = st.session_state.price_data.pct_change().dropna()
|
| 296 |
-
st.session_state.data_with_ta = add_ta_features(st.session_state.data)
|
| 297 |
st.session_state.reduced_features = extract_and_reduce_features(st.session_state.data_with_ta, n_components=2)
|
| 298 |
|
| 299 |
if selected == "DTW Pattern Recognition":
|
|
@@ -302,6 +306,8 @@ if st.sidebar.button('Run Analysis'):
|
|
| 302 |
run_corr()
|
| 303 |
elif selected == "TA-Enhanced DTW Pattern Recognition":
|
| 304 |
run_ta_dtw()
|
|
|
|
|
|
|
| 305 |
|
| 306 |
# Display results and descriptions based on the selected method
|
| 307 |
if selected == "DTW Pattern Recognition":
|
|
|
|
| 109 |
st.sidebar.title("Input Parameters")
|
| 110 |
|
| 111 |
with st.sidebar.expander("How to Use", expanded=False):
|
|
|
|
| 112 |
st.markdown("""
|
| 113 |
1. Select the pattern recognition method you want to use.
|
| 114 |
2. Set the stock ticker or crypto pair, date range, and other parameters.
|
|
|
|
| 288 |
st.session_state.results_ta_dtw = figs
|
| 289 |
|
| 290 |
if st.sidebar.button('Run Analysis'):
|
| 291 |
+
# Fetch data with auto_adjust=False and flatten columns if multi-indexed
|
| 292 |
+
data = yf.download(ticker, start=start_date, end=end_date, auto_adjust=False)
|
| 293 |
+
if isinstance(data.columns, pd.MultiIndex):
|
| 294 |
+
data.columns = data.columns.get_level_values(0)
|
| 295 |
+
|
| 296 |
+
if not data.empty:
|
| 297 |
+
st.session_state.data = data
|
| 298 |
st.session_state.price_data = st.session_state.data['Close']
|
| 299 |
st.session_state.price_data_pct_change = st.session_state.price_data.pct_change().dropna()
|
| 300 |
+
st.session_state.data_with_ta = add_ta_features(st.session_state.data.copy())
|
| 301 |
st.session_state.reduced_features = extract_and_reduce_features(st.session_state.data_with_ta, n_components=2)
|
| 302 |
|
| 303 |
if selected == "DTW Pattern Recognition":
|
|
|
|
| 306 |
run_corr()
|
| 307 |
elif selected == "TA-Enhanced DTW Pattern Recognition":
|
| 308 |
run_ta_dtw()
|
| 309 |
+
else:
|
| 310 |
+
st.error(f"No data returned for {ticker} from {start_date} to {end_date}")
|
| 311 |
|
| 312 |
# Display results and descriptions based on the selected method
|
| 313 |
if selected == "DTW Pattern Recognition":
|