Documentation Index
Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Comprehensive financial data toolkit using Yahoo Finance API.
Basic Usage
from upsonic import Agent, Task
from upsonic.tools.common_tools.financial_tools import YFinanceTools
# Create finance tools instance
finance_tools = YFinanceTools()
finance_tools._enable_all_tools()
tools = finance_tools.functions()
# Create task
task = Task(
description="Get the current stock price for Apple (AAPL)",
tools=tools
)
# Create agent
agent = Agent(model="anthropic/claude-sonnet-4-5", name="Finance Agent")
# Execute
result = agent.print_do(task)
print("Result:", result)
Enable only specific financial capabilities:
from upsonic.tools.common_tools.financial_tools import YFinanceTools
from upsonic import Agent, Task
# Enable specific tools
finance_tools = YFinanceTools(
stock_price=True,
company_info=True,
analyst_recommendations=False,
company_news=False
)
task = Task(
description="Get stock price and company information for Microsoft (MSFT)",
tools=finance_tools.functions()
)
agent = Agent(model="anthropic/claude-sonnet-4-5", name="Selective Finance Agent")
result = agent.print_do(task)
print("Result:", result)
When using _enable_all_tools(), the following methods are available:
- get_current_stock_price(symbol: str): Get current stock price
- get_company_info(symbol: str): Get comprehensive company information
- get_analyst_recommendations(symbol: str): Get analyst recommendations
- get_company_news(symbol: str, num_stories: int): Get recent company news
- get_stock_fundamentals(symbol: str): Get key financial fundamentals
- get_income_statements(symbol: str): Get income statement data
- get_key_financial_ratios(symbol: str): Get key financial ratios
- get_historical_stock_prices(symbol: str, period: str, interval: str): Get historical price data
- get_technical_indicators(symbol: str, period: str): Get technical indicators
Parameters
Constructor Parameters:
stock_price (bool): Enable stock price retrieval (default: True)
company_info (bool): Enable company information (default: False)
analyst_recommendations (bool): Enable analyst recommendations (default: False)
company_news (bool): Enable company news (default: False)
enable_all (bool): Enable all available tools (default: False)
Historical Data Parameters:
period (str): Time period - ‘1d’, ‘5d’, ‘1mo’, ‘3mo’, ‘6mo’, ‘1y’, ‘2y’, ‘5y’, ‘10y’, ‘ytd’, ‘max’
interval (str): Data interval - ‘1m’, ‘2m’, ‘5m’, ‘15m’, ‘30m’, ‘60m’, ‘90m’, ‘1h’, ‘1d’, ‘5d’, ‘1wk’, ‘1mo’, ‘3mo’
Complete Example
from upsonic import Agent, Task
from upsonic.tools.common_tools.financial_tools import YFinanceTools
# Enable all financial tools
finance_tools = YFinanceTools()
finance_tools._enable_all_tools()
# Comprehensive analysis task
task = Task(
description="""
Perform comprehensive financial analysis of Tesla (TSLA):
1. Get current stock price
2. Get company fundamentals
3. Get recent news
4. Provide investment recommendation
""",
tools=finance_tools.functions()
)
# Create agent
agent = Agent(model="anthropic/claude-sonnet-4-5", name="Financial Analyst")
# Execute
result = agent.print_do(task)
print("Result:", result)
Installation
uv pip install yfinance pandas