Skip to main content

Stock Analysis & AI Prediction Workflow

This advanced workflow demonstrates a complete AI-powered stock trading analysis system that combines technical analysis, real-time news sentiment, and machine learning to generate BUY/SELL/HOLD predictions with confidence scores.

Key Features:

  • Technical Analysis: Computes moving averages, volatility, trend classification, and volume analysis
  • News Integration: Fetches real-time market news using Brave Search
  • AI Decision Making: Uses AI to combine technical indicators with news sentiment
  • Parallel Processing: Leverages Async Data Aggregator for efficient multi-source data handling
  • Dual Output: Displays both AI predictions and interactive price charts

Stock Analysis AI Prediction Workflow


Steps

  1. Trigger Workflow The Timer node initiates the workflow, triggering both the Data Source (stock name context) and GET Data (API fetch) nodes in parallel.

  2. Fetch Stock Data The GET Data node calls the Alpha Vantage API to retrieve daily historical OHLCV data for the specified stock symbol (e.g., TSLA).

  3. Parallel Data Transformation The API response is processed through two parallel paths:

    • Path A (Chart): JSON Reformatter extracts and formats Open/High/Low/Close data for visualization
    • Path B (Analysis): JSON Reformatter converts data to OHLCV format with proper types
  4. Compute Technical Indicators The Stock Analysis node receives the OHLCV data and computes:

    • Simple Moving Averages (SMA5, SMA10)
    • Price volatility (standard deviation)
    • Trend classification (up/down/sideways)
    • Volume ratio (current vs. average)
    • Price slope (momentum indicator)
    • Percentage change
  5. Aggregate Multi-Source Data The Async Data Aggregator waits for both inputs:

    • Technical analysis results (from Stock Analysis node)
    • Stock name context (from Data Source node)

    Once both arrive, it combines them into an array and passes to the AI processing node.

  6. AI-Powered Decision Making The AI Data Processing node:

    1. Analyzes Technical Indicators: Evaluates trend, slope, volume ratio, volatility
    2. Searches for News: Calls the Brave Search tool with query "<symbol> stock news"
    3. Synthesizes Information: Combines technical signals with news sentiment
    4. Generates Prediction: Outputs BUY/SELL/HOLD with confidence score
    5. Provides Reasoning: Explains the decision based on indicators and news
  7. Display Results Two parallel outputs show the complete picture:

    • Data Flow Spy: Displays AI prediction with symbol, recommendation, confidence, and reasoning
    • Display Chart: Shows interactive OHLC chart for visual analysis

Customization Options

  1. Change Stock Symbol Modify the GET Data node URL to analyze different stocks:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&outputsize=compact&apikey=YOUR_KEY
  1. Fine-tune AI Prompt Customize the AI Data Processing prompt to:
  • Add more sophisticated decision rules
  • Include risk management considerations
  • Adjust confidence scoring methodology
  • Add additional data sources
  1. Add More Context Include additional data sources in the Async Data Aggregator:
  • Fundamental data (P/E ratio, earnings)
  • Sector performance
  • Market indices correlation
  • Social media sentiment

Requirements

API Keys

  1. Alpha Vantage API Key: Get free key at alphavantage.co
    • Free tier: 25 requests/day
    • ⚠️ Replace the demo API key in the GET Data node with your actual key
  2. Brave Search API Key: Get key at brave.com/search/api
    • Required for news search functionality

LLM Model

  • Recommended: Models with 8B+ parameters for reliable tool calling
  • Examples: granite4:latest, llama3.1:8b, qwen2.5:14b
  • Smaller models may struggle with sequential tool calls