Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -135,36 +135,35 @@ def stock_insight(company_name):
|
|
135 |
global chart_data
|
136 |
symbol = get_stock_symbol(company_name)
|
137 |
if not symbol:
|
138 |
-
return f"β Could not find stock symbol for '{company_name}'.", "", "", "", "", ""
|
139 |
|
140 |
price, last_trade = get_stock_quote(symbol)
|
141 |
if not price:
|
142 |
-
return f"β Could not fetch price for symbol {symbol}.", "", "", "", "", ""
|
143 |
|
144 |
overview = get_financial_overview(symbol)
|
145 |
if not overview:
|
146 |
-
return f"β Could not fetch financial data for {symbol}.", "", "", "", "", ""
|
147 |
|
148 |
chart_data = overview # Store for later chart use
|
149 |
summary = ask_gpt_summary(company_name, overview)
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
)
|
160 |
-
|
161 |
# π¨ Chart render on button click
|
162 |
def generate_chart(chart_data_input):
|
163 |
if chart_data_input:
|
164 |
return plot_financials(chart_data_input)
|
165 |
return None
|
166 |
|
167 |
-
|
168 |
# π₯οΈ Gradio UI
|
169 |
with gr.Blocks() as demo:
|
170 |
gr.Markdown("# π Stock Market Assistant")
|
@@ -194,11 +193,10 @@ with gr.Blocks() as demo:
|
|
194 |
outputs=[
|
195 |
symbol_output, price_output, trade_output,
|
196 |
financial_output, company_summary, gpt_output,
|
197 |
-
chart_data_state
|
198 |
]
|
199 |
)
|
200 |
|
201 |
generate_chart_button.click(generate_chart, inputs=chart_data_state, outputs=chart_output)
|
202 |
|
203 |
-
|
204 |
-
demo.launch()
|
|
|
135 |
global chart_data
|
136 |
symbol = get_stock_symbol(company_name)
|
137 |
if not symbol:
|
138 |
+
return f"β Could not find stock symbol for '{company_name}'.", "", "", "", "", "", ""
|
139 |
|
140 |
price, last_trade = get_stock_quote(symbol)
|
141 |
if not price:
|
142 |
+
return f"β Could not fetch price for symbol {symbol}.", "", "", "", "", "", ""
|
143 |
|
144 |
overview = get_financial_overview(symbol)
|
145 |
if not overview:
|
146 |
+
return f"β Could not fetch financial data for {symbol}.", "", "", "", "", "", ""
|
147 |
|
148 |
chart_data = overview # Store for later chart use
|
149 |
summary = ask_gpt_summary(company_name, overview)
|
150 |
|
151 |
+
return (
|
152 |
+
f"β
Symbol: {symbol}",
|
153 |
+
f"π² Price: ${price}",
|
154 |
+
f"ποΈ Last Trading Day: {last_trade}",
|
155 |
+
f"π P/E Ratio: {overview['P/E Ratio']}\nEPS: {overview['EPS']}\nMarket Cap: ${overview['Market Cap']}",
|
156 |
+
f"π Company Summary: {overview['Description'][:300]}...",
|
157 |
+
f"π€ GPT Insight: {summary}",
|
158 |
+
overview
|
159 |
)
|
160 |
+
|
161 |
# π¨ Chart render on button click
|
162 |
def generate_chart(chart_data_input):
|
163 |
if chart_data_input:
|
164 |
return plot_financials(chart_data_input)
|
165 |
return None
|
166 |
|
|
|
167 |
# π₯οΈ Gradio UI
|
168 |
with gr.Blocks() as demo:
|
169 |
gr.Markdown("# π Stock Market Assistant")
|
|
|
193 |
outputs=[
|
194 |
symbol_output, price_output, trade_output,
|
195 |
financial_output, company_summary, gpt_output,
|
196 |
+
chart_data_state
|
197 |
]
|
198 |
)
|
199 |
|
200 |
generate_chart_button.click(generate_chart, inputs=chart_data_state, outputs=chart_output)
|
201 |
|
202 |
+
demo.launch()
|
|