Automated financial analysis pipeline that pulls real-time market data, computes technical indicators, generates AI-driven sentiment analysis, and delivers formatted HTML reports via email.
This system automates the kind of stock analysis that would take a human analyst 30-60 minutes per ticker — and delivers it as a polished HTML email report. It combines quantitative technical analysis with qualitative news sentiment, then uses GPT-4o to synthesize both into actionable insights.
The pipeline:
- Accepts a stock symbol (via form submission or scheduled trigger)
- Pulls real-time price history, Bollinger Bands, and MACD data in parallel
- Computes support and resistance levels algorithmically
- Downloads and analyzes the stock chart visually using GPT-4o
- Fetches recent news and runs AI sentiment analysis
- Merges technical + sentiment data and generates a comprehensive written analysis
- Converts to styled HTML and delivers via email
graph TB
subgraph "Triggers"
A[Form Submission] --> B[AI Agent]
C[Scheduled Trigger] --> D[Generate API Variables]
end
subgraph "AI Agent Layer"
B --> E[GPT-4o with Tools]
E --> F[Technical Analysis Tool]
E --> G[Trends Analysis Tool]
E --> H[Think Tool]
E --> I[Structured Output Parser]
E --> J[Refine Text]
end
subgraph "Technical Analysis Pipeline"
F --> K[Set Stock Symbol + API Key]
K --> L[Get Price History]
K --> M[Get Bollinger Bands]
K --> N[Get MACD]
K --> O[Get Chart URL → Download Chart]
L --> P[Calculate Support/Resistance]
O --> Q[GPT-4o Visual Chart Analysis]
P --> R[Merge All Indicators]
M --> R
N --> R
R --> S[Organize Data]
end
subgraph "News + Sentiment Pipeline"
D --> T[Fetch News Data]
T --> U[Analyze Sentiment]
end
subgraph "Synthesis + Delivery"
S --> V[Merge Technical + News]
Q --> V
V --> W[Wrap as JSON for GPT-4o]
W --> X[Generate Final Analysis]
J --> Y[Generate HTML Report]
Y --> Z[Adjust Colors/Styling]
Z --> AA[Send Email]
end
| Component | Technology | Purpose |
|---|---|---|
| Conversational Interface | n8n Form Trigger + AI Agent | Natural language stock queries |
| LLM Orchestration | GPT-4o with tool calling | Agent reasoning, chart analysis, report generation |
| Technical Indicators | Financial APIs (parallel requests) | Price history, Bollinger Bands, MACD |
| Support/Resistance | Custom JavaScript | Algorithmic calculation from price data |
| Chart Analysis | GPT-4o vision | Visual interpretation of stock charts |
| News Sentiment | News API + GPT-4o | Fetch and analyze recent news coverage |
| Output Formatting | Structured Output Parser → HTML | Enforced JSON schema → styled email template |
| Delivery | SMTP Email | Formatted HTML report with analysis |
Why parallel data fetching? A single stock analysis requires 4+ API calls (price history, Bollinger, MACD, chart). Running these sequentially adds unnecessary latency. The pipeline fans out immediately after setting the symbol, then merges results once all data is available.
Why two separate GPT-4o analysis passes? The first pass (visual chart analysis) operates on the chart image and technical data independently. The second pass combines everything — technicals, chart interpretation, news sentiment — into the final synthesis. Splitting these prevents context pollution and lets each analysis focus on its domain.
Why structured output parsing? The AI Agent uses a Structured Output Parser to enforce a JSON schema on the analysis results. This guarantees the downstream HTML template always receives the fields it expects (summary, signals, confidence, etc.) — no more broken reports from unexpected LLM output.
Why an AI Agent for the user-facing layer? Instead of a rigid form → pipeline flow, the AI Agent layer lets users ask natural language questions ("How's NVDA looking?" or "Compare AAPL and MSFT") and routes to the appropriate tools. The agent decides which analyses to run based on the query.
- Multi-modal analysis: Combines numerical data (indicators), visual data (chart images), and textual data (news) in a single pipeline
- Tool-calling architecture: AI Agent dynamically invokes Technical Analysis and Trends Analysis as callable tools
- Parallel execution: 4 simultaneous API calls for market data reduce total latency
- Structured outputs: Enforced JSON schema ensures reliable downstream processing
- Styled HTML generation: Reports are rendered with custom color themes for readability
- Hosting: Self-hosted n8n instance on personal infrastructure
- APIs: Financial data APIs, News APIs, OpenAI GPT-4o
- Orchestration: n8n workflow engine (46 nodes, 30 connections)
- Delivery: SMTP email with HTML formatting