Yahoo Finance Stock Analyzer

AI agent that analyzes stock market data using Yahoo Finance tools with database tool resolution

Back
Workflow Information

ID: yahoo_finance_analyzer

Namespace: default

Version: 1.0

Created: 2025-07-01

Updated: 2025-07-01

Tasks: 2

Quick Actions
Manage Secrets
Inputs
Name Type Required Default
stock_symbols string Optional AAPL,GOOGL,MSFT
analysis_type string Optional current_price
Outputs

No outputs defined

Tasks
stock_analyzer
ai_agent

AI agent that analyzes stock prices using Yahoo Finance

format_report
script

Format the AI analysis into a structured report using safe template resolution

Triggers
Manual Trigger: Yahoo Finance Stock Analysis (Final)
YAML Source
id: yahoo_finance_analyzer
name: Yahoo Finance Stock Analyzer
tasks:
- id: stock_analyzer
  name: Stock Market Analyzer
  type: ai_agent
  config:
    tools:
    - current_time
    - get_current_stock_price
    - get_stock_price_date_range
    - get_historical_stock_prices
    streaming: false
    agent_type: financial_analyst
    input_format: text
    output_format: text
    model_client_id: finance_analyst
  description: AI agent that analyzes stock prices using Yahoo Finance
  user_message: "Please perform a stock market analysis for the following symbols:\
    \ ${stock_symbols}\n\nAnalysis requirements:\n1. First, get the current time to\
    \ timestamp this analysis\n2. Fetch current stock prices for each symbol\n3. Get\
    \ historical data for the past week to identify trends\n4. Provide insights on:\n\
    \   - Current valuation vs recent performance\n   - Price movement patterns\n\
    \   - Notable changes or volatility\n\nPresent your findings in a clear, professional\
    \ format.\n"
  system_message: 'You are a professional financial analyst specializing in stock
    market analysis.

    You have access to real-time stock data through Yahoo Finance tools.


    Your responsibilities:

    - Retrieve accurate stock price data

    - Analyze market trends and patterns

    - Provide clear insights about stock performance

    - Include timestamps with all data collection


    Always start by getting the current time to timestamp your analysis.

    '
- id: format_report
  name: Format Analysis Report
  type: script
  script: "import os\nimport json\nfrom datetime import datetime\n\nprint(\"=== YAHOO\
    \ FINANCE STOCK ANALYSIS REPORT ===\")\nprint(f\"Generated: {datetime.now().strftime('%Y-%m-%d\
    \ %H:%M:%S UTC')}\")\nprint(f\"Symbols Analyzed: ${stock_symbols}\")\nprint(\"\
    =\" * 50)\nprint()\n\n# Get AI analysis results using triple quotes for safe multiline\
    \ handling\nai_response = '''${stock_analyzer.ai_response}'''\n\n# Try to extract\
    \ structured data from AI response\ntry:\n    # If AI response is JSON, parse\
    \ it\n    if ai_response.startswith('{'):\n        analysis_data = json.loads(ai_response)\n\
    \        \n        # Print structured analysis\n        if 'stocks' in analysis_data:\n\
    \            for stock in analysis_data['stocks']:\n                print(f\"\U0001F4CA\
    \ {stock.get('symbol', 'N/A')}\")\n                print(f\"   Current Price:\
    \ ${stock.get('price', 'N/A')}\")\n                print(f\"   Change: {stock.get('change',\
    \ 'N/A')}\")\n                print(f\"   Volume: {stock.get('volume', 'N/A')}\"\
    )\n                print()\n        \n        if 'insights' in analysis_data:\n\
    \            print(\"\U0001F4A1 Key Insights:\")\n            print(analysis_data['insights'])\n\
    \    else:\n        # Plain text response - display safely\n        print(\"\U0001F4C8\
    \ Analysis Results:\")\n        print(\"-\" * 50)\n        print(ai_response)\n\
    except Exception as e:\n    # Fallback to plain text display\n    print(\"\U0001F4C8\
    \ Analysis Results:\")\n    print(\"-\" * 50)\n    print(ai_response)\n    print(f\"\
    \\nNote: Display formatting error: {e}\")\n\nprint()\nprint(\"\u2705 ANALYSIS\
    \ COMPLETE\")\nprint(f\"Analyzed {len('${stock_symbols}'.split(','))} stocks\"\
    )\nprint(f\"Using database tool resolution with tenant_id + tool_name queries\"\
    )\n"
  depends_on:
  - stock_analyzer
  description: Format the AI analysis into a structured report using safe template
    resolution
inputs:
- name: stock_symbols
  type: string
  default: AAPL,GOOGL,MSFT
  description: Stock symbols to analyze (comma-separated)
- name: analysis_type
  type: string
  default: current_price
  description: Type of analysis to perform
version: '1.0'
triggers:
- name: Yahoo Finance Stock Analysis (Final)
  type: manual
  description: Execute stock market analysis using Yahoo Finance data with safe template
    resolution
tenant_id: 0572fa8d-d7c3-47db-9219-ef40b80d42b7
description: AI agent that analyzes stock market data using Yahoo Finance tools with
  database tool resolution
model_clients:
- id: finance_analyst
  config:
    model: gpt-4o-mini
    api_key: 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
    max_tokens: 800
    temperature: 0.3
  provider: openai
Execution ID Status Started Duration Actions
ddc86211... COMPLETED 2025-08-13
08:28:08
N/A View
6ce55cef... COMPLETED 2025-07-23
12:30:51
N/A View
ebd4553a... COMPLETED 2025-07-17
05:58:29
N/A View
02e01d73... COMPLETED 2025-07-15
12:17:55
N/A View
f789e70a... COMPLETED 2025-07-03
04:31:56
N/A View