CCockrum commited on
Commit
67ed81c
·
verified ·
1 Parent(s): 91d4d53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -25
app.py CHANGED
@@ -113,31 +113,13 @@ def generate_summary(info, ratios):
113
  summary = summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
114
  return summary
115
 
116
- # (Rest of the code remains the same)
117
- def calculate_ratios(market_cap, total_revenue, price, dividend_amount, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
118
- pe_ratio = price / assumed_eps if assumed_eps else 0
119
- ps_ratio = market_cap / total_revenue if total_revenue else 0
120
- pb_ratio = market_cap / book_value if book_value else 0
121
- peg_ratio = pe_ratio / (growth_rate * 100) if growth_rate else 0
122
- dividend_yield = (dividend_amount / price) * 100 if price else 0
123
- return {
124
- 'P/E Ratio': pe_ratio,
125
- 'P/S Ratio': ps_ratio,
126
- 'P/B Ratio': pb_ratio,
127
- 'PEG Ratio': peg_ratio,
128
- 'Dividend Yield (%)': dividend_yield
129
- }
130
-
131
- def compare_to_sector(sector, ratios):
132
- averages = sector_averages.get(sector, None)
133
- if not averages:
134
- return pd.DataFrame({"Metric": ["Sector data not available"], "Value": ["N/A"]})
135
- comparison = {}
136
- for key in averages:
137
- stock_value = ratios.get(key, 0)
138
- sector_value = averages[key]
139
- comparison[key] = f"{stock_value:.2f} vs Sector Avg {sector_value:.2f}"
140
- return pd.DataFrame({"Ratio": list(comparison.keys()), "Comparison": list(comparison.values())})
141
 
142
  def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
143
  if assumed_eps is None:
 
113
  summary = summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
114
  return summary
115
 
116
+ def answer_investing_question(question):
117
+ basic_prompt = f"Explain clearly and simply: {question}"
118
+ response = summarizer(basic_prompt, max_length=150, min_length=50, do_sample=False)[0]['summary_text']
119
+ return response
120
+
121
+ # (Rest of the app continues with stock_research, download_report, and Gradio UI, now including a new Tab for Q&A)
122
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
125
  if assumed_eps is None: