Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,8 +47,8 @@ def analyze_stocks(stocks_filepath, index_symbol, years=5):
|
|
| 47 |
start_date = end_date - timedelta(days=365 * years)
|
| 48 |
|
| 49 |
stock_symbols_df = pd.read_csv(stocks_filepath)
|
| 50 |
-
# Filter out USD
|
| 51 |
-
stock_symbols_df = stock_symbols_df[~stock_symbols_df['
|
| 52 |
stock_symbols = stock_symbols_df['Symbol'].tolist()
|
| 53 |
|
| 54 |
index_data = fetch_data(index_symbol, start_date, end_date)
|
|
@@ -118,9 +118,9 @@ def analyze_stocks(stocks_filepath, index_symbol, years=5):
|
|
| 118 |
traces.append(trace)
|
| 119 |
|
| 120 |
layout = go.Layout(title=f'S&P500 Index Stock Clustering based on Beta and R-Squared',
|
| 121 |
-
xaxis=dict(title='β (Risk)', tickmode='linear', dtick=0.25),
|
| 122 |
yaxis=dict(title='R² (Market Dependency)'),
|
| 123 |
-
width=
|
| 124 |
height=800)
|
| 125 |
|
| 126 |
fig = go.Figure(data=traces, layout=layout)
|
|
@@ -131,7 +131,7 @@ def analyze_stocks(stocks_filepath, index_symbol, years=5):
|
|
| 131 |
mode="lines", line=dict(color="black", width=2), showlegend=False))
|
| 132 |
|
| 133 |
latest_date = end_date.strftime('%d/%m/%Y')
|
| 134 |
-
fig.add_annotation(x=
|
| 135 |
text=f"Valid Stocks: {valid_stocks_count} | Date: {latest_date}",
|
| 136 |
showarrow=False, font=dict(size=14, color="black"))
|
| 137 |
|
|
@@ -164,7 +164,7 @@ with gr.Blocks() as iface:
|
|
| 164 |
<style>
|
| 165 |
#large-plot {
|
| 166 |
height: 800px !important;
|
| 167 |
-
width:
|
| 168 |
}
|
| 169 |
</style>
|
| 170 |
""")
|
|
|
|
| 47 |
start_date = end_date - timedelta(days=365 * years)
|
| 48 |
|
| 49 |
stock_symbols_df = pd.read_csv(stocks_filepath)
|
| 50 |
+
# Filter out USD and GBP
|
| 51 |
+
stock_symbols_df = stock_symbols_df[~stock_symbols_df['Symbol'].isin(['USD', 'GBP'])]
|
| 52 |
stock_symbols = stock_symbols_df['Symbol'].tolist()
|
| 53 |
|
| 54 |
index_data = fetch_data(index_symbol, start_date, end_date)
|
|
|
|
| 118 |
traces.append(trace)
|
| 119 |
|
| 120 |
layout = go.Layout(title=f'S&P500 Index Stock Clustering based on Beta and R-Squared',
|
| 121 |
+
xaxis=dict(title='β (Risk)', tickmode='linear', dtick=0.25, range=[0, 3.5]),
|
| 122 |
yaxis=dict(title='R² (Market Dependency)'),
|
| 123 |
+
width=1200,
|
| 124 |
height=800)
|
| 125 |
|
| 126 |
fig = go.Figure(data=traces, layout=layout)
|
|
|
|
| 131 |
mode="lines", line=dict(color="black", width=2), showlegend=False))
|
| 132 |
|
| 133 |
latest_date = end_date.strftime('%d/%m/%Y')
|
| 134 |
+
fig.add_annotation(x=3.4, y=results_df['R-Squared'].max(),
|
| 135 |
text=f"Valid Stocks: {valid_stocks_count} | Date: {latest_date}",
|
| 136 |
showarrow=False, font=dict(size=14, color="black"))
|
| 137 |
|
|
|
|
| 164 |
<style>
|
| 165 |
#large-plot {
|
| 166 |
height: 800px !important;
|
| 167 |
+
width: 1200px !important;
|
| 168 |
}
|
| 169 |
</style>
|
| 170 |
""")
|