rcwaterman commited on
Commit
79c0f83
1 Parent(s): 4f091f6

Fixing dcf tool

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -85,7 +85,7 @@ def calculate_percent_valuation(intrinsic_value:float, current_stock_price:float
85
  return (intrinsic_value-current_stock_price)/abs(intrinsic_value)
86
 
87
  @tool
88
- def calculate_intrinsic_value(ticker, average_growth_rate):
89
  """This tool is helpful for calculating the intrinsic value of a stock. It takes the stock ticker, the average growth rate based on revenue (retrieved from financial reports or with the polygon API. This should be capped at plus or minus 300% per year.)"""
90
  wacc = calculate_wacc(ticker)
91
 
@@ -123,8 +123,8 @@ def calculate_wacc( #refer to https://www.gurufocus.com/term/wacc/SOFI#:~:text=S
123
  return wacc
124
 
125
  @tool
126
- def get_dcf(ticker):
127
- """This tool takes a stock ticker as an argument and returns the discounted cash flow valuation, in dollars. This tool is helpful when trying to determine the intrinsic value of a company, or if a company is overvalued or undervalued."""
128
  url = f'https://financialmodelingprep.com/api/v3/discounted-cash-flow/{ticker}?apikey={FMP_API_KEY}'
129
 
130
  # Make the request to the API
@@ -135,7 +135,7 @@ def get_dcf(ticker):
135
  # Parse the response JSON
136
  dcf_data = response.json()
137
  # return the DCF data
138
- return dcf_data.get("dcf")
139
  else:
140
  # return the error message
141
  return f"Failed to retrieve data: {response.status_code}"
 
85
  return (intrinsic_value-current_stock_price)/abs(intrinsic_value)
86
 
87
  @tool
88
+ def calculate_intrinsic_value(ticker:str, average_growth_rate):
89
  """This tool is helpful for calculating the intrinsic value of a stock. It takes the stock ticker, the average growth rate based on revenue (retrieved from financial reports or with the polygon API. This should be capped at plus or minus 300% per year.)"""
90
  wacc = calculate_wacc(ticker)
91
 
 
123
  return wacc
124
 
125
  @tool
126
+ def get_dcf(ticker:str):
127
+ """This tool takes a single stock ticker as an argument and returns the discounted cash flow valuation, in dollars. This tool is helpful when trying to determine the intrinsic value of a company, or if a company is overvalued or undervalued."""
128
  url = f'https://financialmodelingprep.com/api/v3/discounted-cash-flow/{ticker}?apikey={FMP_API_KEY}'
129
 
130
  # Make the request to the API
 
135
  # Parse the response JSON
136
  dcf_data = response.json()
137
  # return the DCF data
138
+ return dcf_data[0]["dcf"]
139
  else:
140
  # return the error message
141
  return f"Failed to retrieve data: {response.status_code}"