Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,12 +107,14 @@ st.title('Pattern Recognition in Asset Prices')
|
|
| 107 |
|
| 108 |
# Sidebar for method selection
|
| 109 |
st.sidebar.title("Input Parameters")
|
| 110 |
-
|
| 111 |
-
st.sidebar.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
|
| 117 |
# Grouping and expanding sidebar options with tooltips
|
| 118 |
with st.sidebar.expander("Pattern Recognition Methods", expanded=True):
|
|
@@ -305,20 +307,24 @@ if st.sidebar.button('Run Analysis'):
|
|
| 305 |
if selected == "DTW Pattern Recognition":
|
| 306 |
st.markdown("""
|
| 307 |
### DTW Pattern Recognition
|
| 308 |
-
Dynamic Time Warping (DTW) is a method that measures the similarity between two time series that may vary in time or speed.
|
| 309 |
-
|
| 310 |
-
""
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
The left chart shows the entire stock price data with the identified patterns highlighted. The right chart shows the reindexed price patterns for comparison.
|
| 323 |
""")
|
| 324 |
if st.session_state.results_dtw:
|
|
|
|
| 107 |
|
| 108 |
# Sidebar for method selection
|
| 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.sidebar.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.
|
| 116 |
+
3. Click 'Run' to perform the analysis.
|
| 117 |
+
""")
|
| 118 |
|
| 119 |
# Grouping and expanding sidebar options with tooltips
|
| 120 |
with st.sidebar.expander("Pattern Recognition Methods", expanded=True):
|
|
|
|
| 307 |
if selected == "DTW Pattern Recognition":
|
| 308 |
st.markdown("""
|
| 309 |
### DTW Pattern Recognition
|
| 310 |
+
Dynamic Time Warping (DTW) is a method that measures the similarity between two time series that may vary in time or speed. """)
|
| 311 |
+
|
| 312 |
+
with st.expander("Click here to read more about the methodology"):
|
| 313 |
+
st.markdown("""DTW aligns the time series by warping the time axis to minimize the distance between them. This method could potentially identify historical periods that have similar patterns to the current stock price pattern by comparing their shapes, regardless of possible distortions in the time axis.
|
| 314 |
+
The DTW distance \( D \) between two time series \( X \) and \( Y \) is calculated as:
|
| 315 |
+
""")
|
| 316 |
+
st.latex(r'''
|
| 317 |
+
D(i, j) = \text{dist}(X_i, Y_j) + \min \begin{cases}
|
| 318 |
+
D(i-1, j) \\
|
| 319 |
+
D(i, j-1) \\
|
| 320 |
+
D(i-1, j-1)
|
| 321 |
+
\end{cases}
|
| 322 |
+
''')
|
| 323 |
+
st.markdown("""
|
| 324 |
+
where {dist}(Xi, Yj) is the distance between points (Xi) and (Yj), and D(i, j) is the accumulated cost.
|
| 325 |
+
""")
|
| 326 |
+
|
| 327 |
+
st.markdown("""**Results:**
|
| 328 |
The left chart shows the entire stock price data with the identified patterns highlighted. The right chart shows the reindexed price patterns for comparison.
|
| 329 |
""")
|
| 330 |
if st.session_state.results_dtw:
|