> ## 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.

# YFinanceTools

> Comprehensive financial data toolkit using Yahoo Finance API

## Overview

Comprehensive financial data toolkit using Yahoo Finance API.

## Basic Usage

```python theme={null}
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)
```

## Selective Tool Configuration

Enable only specific financial capabilities:

```python theme={null}
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)
```

## Available Tools

When using `_enable_all_tools()`, the following methods are available:

1. **get\_current\_stock\_price(symbol: str)**: Get current stock price
2. **get\_company\_info(symbol: str)**: Get comprehensive company information
3. **get\_analyst\_recommendations(symbol: str)**: Get analyst recommendations
4. **get\_company\_news(symbol: str, num\_stories: int)**: Get recent company news
5. **get\_stock\_fundamentals(symbol: str)**: Get key financial fundamentals
6. **get\_income\_statements(symbol: str)**: Get income statement data
7. **get\_key\_financial\_ratios(symbol: str)**: Get key financial ratios
8. **get\_historical\_stock\_prices(symbol: str, period: str, interval: str)**: Get historical price data
9. **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

```python theme={null}
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

```bash theme={null}
uv pip install yfinance pandas
```
