AgentFin / tools /get_stock_data.py
Unosoftware's picture
Upload agent
77ce8b2 verified
raw
history blame contribute delete
614 Bytes
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]