Agentic-AI-CHAT / my_functions.py
ginipick's picture
Update my_functions.py
acfe410 verified
raw
history blame
563 Bytes
import yfinance as yf
product_catalog = {
"807ZPKBL9V": "SuperWidget",
"1234567890": "MegaGadget"
}
def get_product_name_by_PID(PID: str) -> str:
"""
Finds the name of a product by its Product ID
"""
return product_catalog.get(PID, "Unknown product")
def get_stock_price(ticker: str) -> float:
"""
Retrieves the latest stock price for a given ticker using yfinance.
"""
stock = yf.Ticker(ticker)
data = stock.history(period="1d")
if not data.empty:
return data['Close'].iloc[-1]
return float('nan')