omniverse1 commited on
Commit
9b9ec8f
Β·
verified Β·
1 Parent(s): 48cacc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -40
app.py CHANGED
@@ -66,7 +66,7 @@ def update_analysis(symbol, prediction_days):
66
  "0", "0", "0", ""
67
  )
68
 
69
- summary_text = f"""
70
  ### 🏒 {fundamental_info.get('name', 'N/A')} ({symbol.upper()})
71
  **Current Price:** Rp{fundamental_info.get('current_price', 0):,.2f}
72
  **Market Cap:** {fundamental_info.get('market_cap', 0):,}
@@ -75,22 +75,22 @@ def update_analysis(symbol, prediction_days):
75
  **Volume:** {fundamental_info.get('volume', 0):,}
76
  """
77
 
78
- signal_text = f"""
79
- ### πŸ“ˆ Technical Trading Signal
80
- **Overall Signal:** {signals.get('overall', 'N/A')}
81
- **Strength:** {signals.get('strength', 0):.2f}%
82
  **Support:** {signals.get('support', 0):,.2f}
83
  **Resistance:** {signals.get('resistance', 0):,.2f}
84
  **Stop Loss:** {signals.get('stop_loss', 0):,.2f}
85
 
86
- **Signal Details:**
87
  {signals.get('details', '')}
88
  """
89
 
90
- prediction_text = f"""
91
- ### πŸ€– AI Forecast (Amazon Chronos-Bolt)
92
- **Predicted High (30d):** Rp{predictions.get('high_30d', 0):,.2f}
93
- **Predicted Low (30d):** Rp{predictions.get('low_30d', 0):,.2f}
94
  **Expected Change:** {predictions.get('change_pct', 0):.2f}%
95
 
96
  🧠 **Model Insight:**
@@ -98,83 +98,85 @@ def update_analysis(symbol, prediction_days):
98
  """
99
 
100
  return (
101
- summary_text,
 
102
  fig_price,
103
  fig_technical,
104
  fig_prediction,
105
- signal_text,
106
  f"{predictions.get('high_30d', 0):,.2f}",
107
  f"{predictions.get('low_30d', 0):,.2f}",
108
  f"{predictions.get('change_pct', 0):.2f}%",
109
- prediction_text,
110
  )
111
 
112
  with gr.Blocks(
113
- title="AI Stock Forecast Dashboard",
114
- theme=gr.themes.Soft(primary_hue="blue", secondary_hue="gray"),
115
  css="""
116
- #dashboard {padding: 20px; max-width: 1300px; margin: auto;}
117
- .gradio-container {font-family: 'Inter', sans-serif;}
118
- h1, h2, h3 {color: #1e293b;}
119
- .gr-button {font-weight: 600; border-radius: 8px;}
120
- .gr-markdown {background: #f8fafc; border-radius: 10px; padding: 15px;}
 
 
121
  """
122
  ) as app:
123
- gr.Markdown("# ⚑ AI Stock Analysis Dashboard β€” Chronos-Bolt Edition", elem_id="dashboard")
124
- gr.Markdown("Enter any **Indonesian stock ticker** (e.g., `BBCA`, `ADRO`, `TLKM`, `BMRI`) to get live market insights and AI-based 30-day forecasts.", elem_id="dashboard")
125
 
126
- with gr.Row():
127
  symbol = gr.Textbox(
128
- label="Stock Symbol",
129
  value="BBCA",
130
- placeholder="Type e.g. BBCA, ADRO, TLKM ...",
131
  interactive=True,
132
- lines=1
133
  )
134
  prediction_days = gr.Slider(
135
- label="Prediction Period (Days)",
136
  minimum=5,
137
  maximum=60,
138
  step=5,
139
  value=30,
140
  interactive=True,
141
  )
142
- analyze_button = gr.Button("πŸš€ Analyze Stock")
143
 
144
  gr.Markdown("---")
145
 
146
  with gr.Row():
147
- with gr.Column():
148
- fundamentals_output = gr.Markdown(label="Fundamentals")
149
- with gr.Column():
150
- signal_output = gr.Markdown(label="Trading Signals")
151
 
152
  gr.Markdown("---")
153
 
154
- with gr.Tab("πŸ“Š Charts Overview"):
155
  with gr.Row():
156
  price_chart = gr.Plot(label="Price & Moving Averages")
157
- technical_chart = gr.Plot(label="Technical Indicators")
158
  gr.Markdown("---")
159
  prediction_chart = gr.Plot(label="AI Forecast Projection")
160
 
161
- with gr.Tab("πŸ€– AI Forecast Results"):
162
  with gr.Row():
163
- predicted_high = gr.Textbox(label="Predicted High (30d)")
164
- predicted_low = gr.Textbox(label="Predicted Low (30d)")
165
- predicted_change = gr.Textbox(label="Expected Change (%)")
166
  gr.Markdown("---")
167
- prediction_summary = gr.Markdown(label="Prediction Analysis")
168
 
169
  analyze_button.click(
170
  fn=update_analysis,
171
  inputs=[symbol, prediction_days],
172
  outputs=[
173
  fundamentals_output,
 
174
  price_chart,
175
  technical_chart,
176
  prediction_chart,
177
- signal_output,
178
  predicted_high,
179
  predicted_low,
180
  predicted_change,
 
66
  "0", "0", "0", ""
67
  )
68
 
69
+ fundamentals = f"""
70
  ### 🏒 {fundamental_info.get('name', 'N/A')} ({symbol.upper()})
71
  **Current Price:** Rp{fundamental_info.get('current_price', 0):,.2f}
72
  **Market Cap:** {fundamental_info.get('market_cap', 0):,}
 
75
  **Volume:** {fundamental_info.get('volume', 0):,}
76
  """
77
 
78
+ trading_signal = f"""
79
+ ### πŸ“Š Technical Signal Summary
80
+ **Overall Trend:** {signals.get('overall', 'N/A')}
81
+ **Signal Strength:** {signals.get('strength', 0):.2f}%
82
  **Support:** {signals.get('support', 0):,.2f}
83
  **Resistance:** {signals.get('resistance', 0):,.2f}
84
  **Stop Loss:** {signals.get('stop_loss', 0):,.2f}
85
 
86
+ **Detailed Insights:**
87
  {signals.get('details', '')}
88
  """
89
 
90
+ prediction = f"""
91
+ ### πŸ€– 30-Day AI Forecast (Amazon Chronos-Bolt)
92
+ **Predicted High:** Rp{predictions.get('high_30d', 0):,.2f}
93
+ **Predicted Low:** Rp{predictions.get('low_30d', 0):,.2f}
94
  **Expected Change:** {predictions.get('change_pct', 0):.2f}%
95
 
96
  🧠 **Model Insight:**
 
98
  """
99
 
100
  return (
101
+ fundamentals,
102
+ trading_signal,
103
  fig_price,
104
  fig_technical,
105
  fig_prediction,
 
106
  f"{predictions.get('high_30d', 0):,.2f}",
107
  f"{predictions.get('low_30d', 0):,.2f}",
108
  f"{predictions.get('change_pct', 0):.2f}%",
109
+ prediction,
110
  )
111
 
112
  with gr.Blocks(
113
+ title="RexPro Financial AI Dashboard",
114
+ theme=gr.themes.Soft(primary_hue="cyan", secondary_hue="emerald"),
115
  css="""
116
+ body {background-color: #0f172a; color: #e2e8f0; font-family: 'Inter', sans-serif;}
117
+ h1, h2, h3 {color: #22d3ee;}
118
+ .gr-markdown {background-color: #1e293b; border-radius: 12px; padding: 18px; color: #e2e8f0;}
119
+ .gr-button {background: linear-gradient(90deg, #06b6d4, #14b8a6); color: white !important; font-weight: 600; border-radius: 10px;}
120
+ .gr-textbox label, .gr-slider label {color: #a5f3fc;}
121
+ .gr-textbox input, .gr-slider {background-color: #1e293b; color: white;}
122
+ .gr-plot {background-color: #1e293b; border-radius: 12px;}
123
  """
124
  ) as app:
125
+ gr.Markdown("# πŸ’Ή REXPRO FINANCIAL AI DASHBOARD")
126
+ gr.Markdown("Smart market insights powered by **Chronos-Bolt AI** β€” for serious investors and analysts.", elem_id="subheader")
127
 
128
+ with gr.Row(equal_height=True):
129
  symbol = gr.Textbox(
130
+ label="Stock Symbol (IDX)",
131
  value="BBCA",
132
+ placeholder="Example: BBCA, TLKM, ADRO, BMRI ...",
133
  interactive=True,
134
+ lines=1,
135
  )
136
  prediction_days = gr.Slider(
137
+ label="Forecast Period (Days)",
138
  minimum=5,
139
  maximum=60,
140
  step=5,
141
  value=30,
142
  interactive=True,
143
  )
144
+ analyze_button = gr.Button("πŸš€ Run Analysis")
145
 
146
  gr.Markdown("---")
147
 
148
  with gr.Row():
149
+ with gr.Column(scale=1):
150
+ fundamentals_output = gr.Markdown()
151
+ with gr.Column(scale=1):
152
+ signal_output = gr.Markdown()
153
 
154
  gr.Markdown("---")
155
 
156
+ with gr.Tab("πŸ“ˆ Market Charts"):
157
  with gr.Row():
158
  price_chart = gr.Plot(label="Price & Moving Averages")
159
+ technical_chart = gr.Plot(label="Technical Indicators Overview")
160
  gr.Markdown("---")
161
  prediction_chart = gr.Plot(label="AI Forecast Projection")
162
 
163
+ with gr.Tab("πŸ€– AI Forecast Summary"):
164
  with gr.Row():
165
+ predicted_high = gr.Textbox(label="Predicted High (30d)", interactive=False)
166
+ predicted_low = gr.Textbox(label="Predicted Low (30d)", interactive=False)
167
+ predicted_change = gr.Textbox(label="Expected Change (%)", interactive=False)
168
  gr.Markdown("---")
169
+ prediction_summary = gr.Markdown()
170
 
171
  analyze_button.click(
172
  fn=update_analysis,
173
  inputs=[symbol, prediction_days],
174
  outputs=[
175
  fundamentals_output,
176
+ signal_output,
177
  price_chart,
178
  technical_chart,
179
  prediction_chart,
 
180
  predicted_high,
181
  predicted_low,
182
  predicted_change,