Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,12 +23,8 @@ def get_dcf_of_company(symbol: str) -> str:
|
|
| 23 |
e.g. AAPL for apple, IBM for IBM
|
| 24 |
"""
|
| 25 |
try:
|
| 26 |
-
# Step 1: Retrieve the stock ticker symbol
|
| 27 |
-
search_url = f'https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords={symbol}&apikey=NR9AFISYRYH2B5U3'
|
| 28 |
-
response = requests.get(search_url)
|
| 29 |
-
data = response.json()
|
| 30 |
|
| 31 |
-
#
|
| 32 |
financials = {}
|
| 33 |
for statement in ['INCOME_STATEMENT', 'BALANCE_SHEET', 'CASH_FLOW']:
|
| 34 |
url = f'https://www.alphavantage.co/query?function={statement}&symbol={symbol}&apikey=NR9AFISYRYH2B5U3'
|
|
@@ -71,10 +67,10 @@ def get_dcf_of_company(symbol: str) -> str:
|
|
| 71 |
# Total DCF value
|
| 72 |
total_value = dcf_value + discounted_terminal_value
|
| 73 |
|
| 74 |
-
return f"The Discounted Cash Flow (DCF) for company '{
|
| 75 |
|
| 76 |
except Exception as e:
|
| 77 |
-
return f"Error calculating DCF for company '{
|
| 78 |
|
| 79 |
|
| 80 |
|
|
|
|
| 23 |
e.g. AAPL for apple, IBM for IBM
|
| 24 |
"""
|
| 25 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
# Retrieve the company's financial statements
|
| 28 |
financials = {}
|
| 29 |
for statement in ['INCOME_STATEMENT', 'BALANCE_SHEET', 'CASH_FLOW']:
|
| 30 |
url = f'https://www.alphavantage.co/query?function={statement}&symbol={symbol}&apikey=NR9AFISYRYH2B5U3'
|
|
|
|
| 67 |
# Total DCF value
|
| 68 |
total_value = dcf_value + discounted_terminal_value
|
| 69 |
|
| 70 |
+
return f"The Discounted Cash Flow (DCF) for company '{symbol}' is: ${total_value:,.2f}"
|
| 71 |
|
| 72 |
except Exception as e:
|
| 73 |
+
return f"Error calculating DCF for company '{symbol}': {str(e)}"
|
| 74 |
|
| 75 |
|
| 76 |
|