Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,34 @@ This application analyzes asset price data using Wasserstein distances to detect
|
|
| 43 |
Wasserstein distances, derived from persistence diagrams in Topological Data Analysis (TDA), help identify significant shifts in asset price behaviors for both stocks and cryptocurrencies.
|
| 44 |
""")
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Sidebar for "How to Use" instructions inside an expander, closed by default
|
| 47 |
with st.sidebar.expander("How to Use", expanded=False):
|
| 48 |
st.write("""
|
|
@@ -98,33 +126,6 @@ if st.sidebar.button('Run Analysis'):
|
|
| 98 |
fig.update_layout(title='Wasserstein Distances Over Time', xaxis_title='Date', yaxis_title='Wasserstein Distance')
|
| 99 |
st.plotly_chart(fig, use_container_width=True)
|
| 100 |
|
| 101 |
-
# Explanation of the Wasserstein Distance method
|
| 102 |
-
st.subheader("Wasserstein Distance Methodology")
|
| 103 |
-
st.write("""
|
| 104 |
-
The Wasserstein distance is a measure from optimal transport theory, used here to compare distributions of log returns in different time windows.
|
| 105 |
-
A high Wasserstein distance indicates a significant change in the price dynamics, which might suggest a market event or shift in investor sentiment.
|
| 106 |
-
""")
|
| 107 |
-
|
| 108 |
-
st.latex(r'''
|
| 109 |
-
W(P, Q) = \inf_{\gamma \in \Pi(P, Q)} \mathbb{E}_{(x,y) \sim \gamma} [d(x, y)]
|
| 110 |
-
''')
|
| 111 |
-
|
| 112 |
-
st.write("""
|
| 113 |
-
- Where \( W(P, Q) \) is the Wasserstein distance between distributions \( P \) and \( Q \).
|
| 114 |
-
- \( d(x, y) \) is the distance between points \( x \) and \( y \).
|
| 115 |
-
- \( \gamma \) is a joint distribution with marginals \( P \) and \( Q \).
|
| 116 |
-
""")
|
| 117 |
-
|
| 118 |
-
# Interpretation of results
|
| 119 |
-
st.subheader("Interpretation of Results")
|
| 120 |
-
st.write("""
|
| 121 |
-
**Wasserstein Distance Analysis:**
|
| 122 |
-
The Wasserstein distance quantifies changes in the log returns of asset prices over time.
|
| 123 |
-
A high distance indicates a significant shift in price dynamics, potentially due to a market event or a change in investor behavior.
|
| 124 |
-
""")
|
| 125 |
-
|
| 126 |
-
st.write(f"Threshold: {threshold}")
|
| 127 |
-
|
| 128 |
st.write("""
|
| 129 |
**Plot Interpretation:**
|
| 130 |
- The first plot shows the asset price over time with alerts marked in red.
|
|
|
|
| 43 |
Wasserstein distances, derived from persistence diagrams in Topological Data Analysis (TDA), help identify significant shifts in asset price behaviors for both stocks and cryptocurrencies.
|
| 44 |
""")
|
| 45 |
|
| 46 |
+
with st.expander("Wasserstein Distance Methodology", expanded=False):
|
| 47 |
+
# Explanation of the Wasserstein Distance method
|
| 48 |
+
st.subheader("Wasserstein Distance Methodology")
|
| 49 |
+
st.write("""
|
| 50 |
+
The Wasserstein distance is a measure from optimal transport theory, used here to compare distributions of log returns in different time windows.
|
| 51 |
+
A high Wasserstein distance indicates a significant change in the price dynamics, which might suggest a market event or shift in investor sentiment.
|
| 52 |
+
""")
|
| 53 |
+
|
| 54 |
+
st.latex(r'''
|
| 55 |
+
W(P, Q) = \inf_{\gamma \in \Pi(P, Q)} \mathbb{E}_{(x,y) \sim \gamma} [d(x, y)]
|
| 56 |
+
''')
|
| 57 |
+
|
| 58 |
+
st.write("""
|
| 59 |
+
- Where \( W(P, Q) \) is the Wasserstein distance between distributions \( P \) and \( Q \).
|
| 60 |
+
- \( d(x, y) \) is the distance between points \( x \) and \( y \).
|
| 61 |
+
- \( \gamma \) is a joint distribution with marginals \( P \) and \( Q \).
|
| 62 |
+
""")
|
| 63 |
+
|
| 64 |
+
# Interpretation of results
|
| 65 |
+
st.subheader("Interpretation of Results")
|
| 66 |
+
st.write("""
|
| 67 |
+
**Wasserstein Distance Analysis:**
|
| 68 |
+
The Wasserstein distance quantifies changes in the log returns of asset prices over time.
|
| 69 |
+
A high distance indicates a significant shift in price dynamics, potentially due to a market event or a change in investor behavior.
|
| 70 |
+
""")
|
| 71 |
+
|
| 72 |
+
st.write(f"Threshold: {threshold}")
|
| 73 |
+
|
| 74 |
# Sidebar for "How to Use" instructions inside an expander, closed by default
|
| 75 |
with st.sidebar.expander("How to Use", expanded=False):
|
| 76 |
st.write("""
|
|
|
|
| 126 |
fig.update_layout(title='Wasserstein Distances Over Time', xaxis_title='Date', yaxis_title='Wasserstein Distance')
|
| 127 |
st.plotly_chart(fig, use_container_width=True)
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
st.write("""
|
| 130 |
**Plot Interpretation:**
|
| 131 |
- The first plot shows the asset price over time with alerts marked in red.
|