Spaces:
Running
on
Zero
Running
on
Zero
attempts to fix plotly layout issues
Browse files
app.py
CHANGED
|
@@ -1828,7 +1828,7 @@ def make_prediction_enhanced(symbol: str, timeframe: str = "1d", prediction_days
|
|
| 1828 |
# Create enhanced visualization with uncertainties integrated
|
| 1829 |
fig = make_subplots(rows=3, cols=1,
|
| 1830 |
shared_xaxes=True,
|
| 1831 |
-
vertical_spacing=0.
|
| 1832 |
subplot_titles=('Price Prediction with Uncertainty', 'Technical Indicators with Uncertainty', 'Volume with Uncertainty'))
|
| 1833 |
|
| 1834 |
# Add historical price
|
|
@@ -2057,38 +2057,67 @@ def make_prediction_enhanced(symbol: str, timeframe: str = "1d", prediction_days
|
|
| 2057 |
fig.add_hline(y=avg_volume, line_dash="dash", line_color="blue",
|
| 2058 |
annotation_text=f"Avg Volume: {avg_volume:,.0f}", row=3, col=1)
|
| 2059 |
|
| 2060 |
-
|
| 2061 |
fig.update_layout(
|
| 2062 |
-
title=
|
| 2063 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2064 |
showlegend=True,
|
| 2065 |
legend=dict(
|
| 2066 |
orientation="h",
|
| 2067 |
yanchor="bottom",
|
| 2068 |
-
y=
|
| 2069 |
xanchor="right",
|
| 2070 |
-
x=1
|
| 2071 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2072 |
)
|
| 2073 |
|
| 2074 |
-
|
| 2075 |
-
|
| 2076 |
-
|
| 2077 |
-
|
| 2078 |
-
|
| 2079 |
-
|
| 2080 |
-
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
-
|
| 2084 |
-
|
| 2085 |
-
|
| 2086 |
-
|
| 2087 |
-
|
| 2088 |
-
|
| 2089 |
-
|
| 2090 |
-
)
|
| 2091 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2092 |
|
| 2093 |
# Create comprehensive trading signals
|
| 2094 |
trading_signals = {
|
|
@@ -3411,7 +3440,12 @@ The **Advanced Stock Prediction System** is a cutting-edge AI-powered platform w
|
|
| 3411 |
""")
|
| 3412 |
|
| 3413 |
with gr.Column():
|
| 3414 |
-
daily_plot = gr.Plot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3415 |
daily_historical_json = gr.JSON(label="Historical Data")
|
| 3416 |
daily_predicted_json = gr.JSON(label="Predicted Data")
|
| 3417 |
|
|
@@ -3479,7 +3513,12 @@ The **Advanced Stock Prediction System** is a cutting-edge AI-powered platform w
|
|
| 3479 |
""")
|
| 3480 |
|
| 3481 |
with gr.Column():
|
| 3482 |
-
hourly_plot = gr.Plot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3483 |
hourly_signals = gr.JSON(label="Trading Signals")
|
| 3484 |
hourly_historical_json = gr.JSON(label="Historical Data")
|
| 3485 |
hourly_predicted_json = gr.JSON(label="Predicted Data")
|
|
@@ -3546,7 +3585,12 @@ The **Advanced Stock Prediction System** is a cutting-edge AI-powered platform w
|
|
| 3546 |
""")
|
| 3547 |
|
| 3548 |
with gr.Column():
|
| 3549 |
-
min15_plot = gr.Plot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3550 |
min15_signals = gr.JSON(label="Trading Signals")
|
| 3551 |
min15_historical_json = gr.JSON(label="Historical Data")
|
| 3552 |
min15_predicted_json = gr.JSON(label="Predicted Data")
|
|
|
|
| 1828 |
# Create enhanced visualization with uncertainties integrated
|
| 1829 |
fig = make_subplots(rows=3, cols=1,
|
| 1830 |
shared_xaxes=True,
|
| 1831 |
+
vertical_spacing=0.12,
|
| 1832 |
subplot_titles=('Price Prediction with Uncertainty', 'Technical Indicators with Uncertainty', 'Volume with Uncertainty'))
|
| 1833 |
|
| 1834 |
# Add historical price
|
|
|
|
| 2057 |
fig.add_hline(y=avg_volume, line_dash="dash", line_color="blue",
|
| 2058 |
annotation_text=f"Avg Volume: {avg_volume:,.0f}", row=3, col=1)
|
| 2059 |
|
| 2060 |
+
|
| 2061 |
fig.update_layout(
|
| 2062 |
+
title=dict(
|
| 2063 |
+
text=f'Enhanced Stock Prediction for {symbol}',
|
| 2064 |
+
x=0.5,
|
| 2065 |
+
xanchor='center',
|
| 2066 |
+
font=dict(size=20, color='black'),
|
| 2067 |
+
y=0.98
|
| 2068 |
+
),
|
| 2069 |
+
height=1000,
|
| 2070 |
showlegend=True,
|
| 2071 |
legend=dict(
|
| 2072 |
orientation="h",
|
| 2073 |
yanchor="bottom",
|
| 2074 |
+
y=0.99,
|
| 2075 |
xanchor="right",
|
| 2076 |
+
x=1,
|
| 2077 |
+
bgcolor='rgba(255,255,255,0.8)',
|
| 2078 |
+
bordercolor='black',
|
| 2079 |
+
borderwidth=1
|
| 2080 |
+
),
|
| 2081 |
+
margin=dict(t=120, b=80, l=80, r=80),
|
| 2082 |
+
autosize=True,
|
| 2083 |
+
hovermode='x unified'
|
| 2084 |
)
|
| 2085 |
|
| 2086 |
+
fig.update_xaxes(
|
| 2087 |
+
title_text="Date",
|
| 2088 |
+
row=3, col=1,
|
| 2089 |
+
title_font=dict(size=12, color='black'),
|
| 2090 |
+
tickfont=dict(size=10)
|
| 2091 |
+
)
|
| 2092 |
+
fig.update_yaxes(
|
| 2093 |
+
title_text="Price ($)",
|
| 2094 |
+
row=1, col=1,
|
| 2095 |
+
title_font=dict(size=12, color='black'),
|
| 2096 |
+
tickfont=dict(size=10)
|
| 2097 |
+
)
|
| 2098 |
+
fig.update_yaxes(
|
| 2099 |
+
title_text="Technical Indicators",
|
| 2100 |
+
row=2, col=1,
|
| 2101 |
+
title_font=dict(size=12, color='black'),
|
| 2102 |
+
tickfont=dict(size=10)
|
| 2103 |
)
|
| 2104 |
+
fig.update_yaxes(
|
| 2105 |
+
title_text="Volume",
|
| 2106 |
+
row=3, col=1,
|
| 2107 |
+
title_font=dict(size=12, color='black'),
|
| 2108 |
+
tickfont=dict(size=10)
|
| 2109 |
+
)
|
| 2110 |
+
|
| 2111 |
+
for i in range(len(fig.layout.annotations)):
|
| 2112 |
+
if i < 3:
|
| 2113 |
+
fig.layout.annotations[i].update(
|
| 2114 |
+
font=dict(size=14, color='darkblue', family='Arial, sans-serif'),
|
| 2115 |
+
y=fig.layout.annotations[i].y + 0.02,
|
| 2116 |
+
bgcolor='rgba(255,255,255,0.8)',
|
| 2117 |
+
bordercolor='lightgray',
|
| 2118 |
+
borderwidth=1
|
| 2119 |
+
)
|
| 2120 |
+
|
| 2121 |
|
| 2122 |
# Create comprehensive trading signals
|
| 2123 |
trading_signals = {
|
|
|
|
| 3440 |
""")
|
| 3441 |
|
| 3442 |
with gr.Column():
|
| 3443 |
+
daily_plot = gr.Plot(
|
| 3444 |
+
label="Analysis and Prediction",
|
| 3445 |
+
container=True,
|
| 3446 |
+
scale=1,
|
| 3447 |
+
height=600
|
| 3448 |
+
)
|
| 3449 |
daily_historical_json = gr.JSON(label="Historical Data")
|
| 3450 |
daily_predicted_json = gr.JSON(label="Predicted Data")
|
| 3451 |
|
|
|
|
| 3513 |
""")
|
| 3514 |
|
| 3515 |
with gr.Column():
|
| 3516 |
+
hourly_plot = gr.Plot(
|
| 3517 |
+
label="Analysis and Prediction",
|
| 3518 |
+
container=True,
|
| 3519 |
+
scale=1,
|
| 3520 |
+
height=600
|
| 3521 |
+
)
|
| 3522 |
hourly_signals = gr.JSON(label="Trading Signals")
|
| 3523 |
hourly_historical_json = gr.JSON(label="Historical Data")
|
| 3524 |
hourly_predicted_json = gr.JSON(label="Predicted Data")
|
|
|
|
| 3585 |
""")
|
| 3586 |
|
| 3587 |
with gr.Column():
|
| 3588 |
+
min15_plot = gr.Plot(
|
| 3589 |
+
label="Analysis and Prediction",
|
| 3590 |
+
container=True,
|
| 3591 |
+
scale=1,
|
| 3592 |
+
height=600
|
| 3593 |
+
)
|
| 3594 |
min15_signals = gr.JSON(label="Trading Signals")
|
| 3595 |
min15_historical_json = gr.JSON(label="Historical Data")
|
| 3596 |
min15_predicted_json = gr.JSON(label="Predicted Data")
|