File size: 614 Bytes
77ce8b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from smolagents import Tool
from typing import Any, Optional

class SimpleTool(Tool):
    name = "get_stock_data"
    description = "Gets the latest adjusted closing price for a given stock symbol."
    inputs = {'symbol': {'type': 'string', 'description': 'The stock symbol to look up.'}}
    output_type = "string"

    def forward(self, symbol: str) -> str:
        """
        Gets the latest adjusted closing price for a given stock symbol.
        Args:
          symbol: The stock symbol to look up.
        """
        import yfinance as yf
        return yf.download(symbol, period="1mo")["Adj Close"][-1]