ktluege commited on
Commit
dec47fe
·
verified ·
1 Parent(s): f089e11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -37,15 +37,26 @@ def get_current_time_in_timezone(timezone: str) -> str:
37
  return f"The current local time in {timezone} is: {local_time}"
38
  except Exception as e:
39
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
 
40
  @tool
41
- def get_stock_price(stock_info: str) -> str:
42
- """A tool that fetches the current stock prices.
 
43
  Args:
44
- stock_info: include changes, current price and etc).
 
 
 
45
  """
46
- finnhub_client = finnhub.Client(api_key=apikey)
 
 
 
 
 
 
 
47
 
48
- return finnhub_client.quote(stock_info)
49
 
50
 
51
 
 
37
  return f"The current local time in {timezone} is: {local_time}"
38
  except Exception as e:
39
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
40
+
41
  @tool
42
+ def get_stock_price(stock_symbol: str) -> str:
43
+ """Get the latest stock price for a given stock symbol.
44
+
45
  Args:
46
+ stock_symbol: Stock ticker symbol (e.g., 'AAPL' for Apple, 'GOOGL' for Google).
47
+
48
+ Returns:
49
+ A string containing the latest stock price and changes.
50
  """
51
+ try:
52
+ finnhub_client = finnhub.Client(api_key="cus67l1r01qt2ncila50cus67l1r01qt2ncila5g")
53
+ stock_data = finnhub_client.quote(stock_symbol)
54
+
55
+ return f"Stock: {stock_symbol}\nCurrent Price: {stock_data['c']}\nChange: {stock_data['d']}\nPercentage Change: {stock_data['dp']}%"
56
+
57
+ except Exception as e:
58
+ return f"Error fetching stock data for '{stock_symbol}': {str(e)}"
59
 
 
60
 
61
 
62