Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -107,7 +107,8 @@ def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
|
|
107 |
elif ratios['P/E Ratio'] > 30 or ratios['Debt/Equity Ratio'] > 2.0 or ratios['Return on Equity (%)'] < 5:
|
108 |
recommendation = "Sell"
|
109 |
|
110 |
-
|
|
|
111 |
report = (
|
112 |
f"Company Overview:\n"
|
113 |
f"Name: {info['Name']}\n"
|
@@ -125,17 +126,21 @@ def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
|
|
125 |
f"Free Cash Flow: ${ratios['Free Cash Flow ($)']:,.2f}\n"
|
126 |
f"Beta (Volatility): {ratios['Beta (Volatility)']}\n"
|
127 |
)
|
128 |
-
|
129 |
-
# Summarize
|
130 |
summary_prompt = f"Summarize this financial report clearly and briefly:\n\n{report}"
|
131 |
-
|
132 |
ai_summary = query_mistral(summary_prompt)
|
133 |
-
|
134 |
-
# Add recommendation
|
135 |
-
financial_health =
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
return ai_summary, info_table, ratios_table, financial_health, sector_comp, fig
|
138 |
|
|
|
139 |
# Theme Selection
|
140 |
selected_theme = os.getenv("APP_THEME", "light")
|
141 |
if selected_theme == "dark":
|
|
|
107 |
elif ratios['P/E Ratio'] > 30 or ratios['Debt/Equity Ratio'] > 2.0 or ratios['Return on Equity (%)'] < 5:
|
108 |
recommendation = "Sell"
|
109 |
|
110 |
+
# Detailed report for summarization
|
111 |
+
# Build a full report
|
112 |
report = (
|
113 |
f"Company Overview:\n"
|
114 |
f"Name: {info['Name']}\n"
|
|
|
126 |
f"Free Cash Flow: ${ratios['Free Cash Flow ($)']:,.2f}\n"
|
127 |
f"Beta (Volatility): {ratios['Beta (Volatility)']}\n"
|
128 |
)
|
129 |
+
|
130 |
+
# Summarize using Mistral
|
131 |
summary_prompt = f"Summarize this financial report clearly and briefly:\n\n{report}"
|
|
|
132 |
ai_summary = query_mistral(summary_prompt)
|
133 |
+
|
134 |
+
# Add recommendation into financial health table
|
135 |
+
financial_health = pd.concat([
|
136 |
+
financial_health,
|
137 |
+
pd.DataFrame([{\"Metric\": \"Recommendation\", \"Value\": recommendation}])
|
138 |
+
], ignore_index=True)
|
139 |
+
|
140 |
+
# Return everything
|
141 |
return ai_summary, info_table, ratios_table, financial_health, sector_comp, fig
|
142 |
|
143 |
+
|
144 |
# Theme Selection
|
145 |
selected_theme = os.getenv("APP_THEME", "light")
|
146 |
if selected_theme == "dark":
|