Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -97,21 +97,27 @@ def generate_summary(info, ratios):
|
|
97 |
elif ratios['P/E Ratio'] > 30 and ratios['P/B Ratio'] > 5 and ratios['PEG Ratio'] > 2.0:
|
98 |
recommendation = "Sell"
|
99 |
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
f"Industry: {info['Industry']}\n"
|
103 |
f"Sector: {info['Sector']}\n"
|
104 |
-
f"Market Cap: ${info['Market Cap']:,.2f}\n"
|
|
|
105 |
f"P/E Ratio: {ratios['P/E Ratio']:.2f}\n"
|
106 |
f"P/S Ratio: {ratios['P/S Ratio']:.2f}\n"
|
107 |
f"P/B Ratio: {ratios['P/B Ratio']:.2f}\n"
|
108 |
f"PEG Ratio: {ratios['PEG Ratio']:.2f}\n"
|
109 |
-
f"Dividend Yield: {ratios['Dividend Yield (%)']:.2f}%\n"
|
110 |
-
f"
|
|
|
111 |
)
|
112 |
-
|
|
|
113 |
return summary
|
114 |
|
|
|
115 |
# (Rest of the code remains the same)
|
116 |
def calculate_ratios(market_cap, total_revenue, price, dividend_amount, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
|
117 |
pe_ratio = price / assumed_eps if assumed_eps else 0
|
|
|
97 |
elif ratios['P/E Ratio'] > 30 and ratios['P/B Ratio'] > 5 and ratios['PEG Ratio'] > 2.0:
|
98 |
recommendation = "Sell"
|
99 |
|
100 |
+
# Much better structured prompt
|
101 |
+
report = (
|
102 |
+
f"Company Overview:\n"
|
103 |
+
f"Name: {info['Name']}\n"
|
104 |
f"Industry: {info['Industry']}\n"
|
105 |
f"Sector: {info['Sector']}\n"
|
106 |
+
f"Market Cap: ${info['Market Cap']:,.2f}\n\n"
|
107 |
+
f"Financial Metrics:\n"
|
108 |
f"P/E Ratio: {ratios['P/E Ratio']:.2f}\n"
|
109 |
f"P/S Ratio: {ratios['P/S Ratio']:.2f}\n"
|
110 |
f"P/B Ratio: {ratios['P/B Ratio']:.2f}\n"
|
111 |
f"PEG Ratio: {ratios['PEG Ratio']:.2f}\n"
|
112 |
+
f"Dividend Yield: {ratios['Dividend Yield (%)']:.2f}%\n\n"
|
113 |
+
f"Recommended Investment Action: {recommendation}.\n\n"
|
114 |
+
f"Please provide a detailed financial analysis based on the information above."
|
115 |
)
|
116 |
+
|
117 |
+
summary = summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
|
118 |
return summary
|
119 |
|
120 |
+
|
121 |
# (Rest of the code remains the same)
|
122 |
def calculate_ratios(market_cap, total_revenue, price, dividend_amount, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
|
123 |
pe_ratio = price / assumed_eps if assumed_eps else 0
|