This AI Agent Analyses Any Stock in 60 Seconds (Free Template)

Most professionals spend hours researching a stock before making a decision — digging through price charts, reading news, checking analyst ratings. This AI stock analysis agent built with n8n does all of that in under 60 seconds, and delivers a clean summary straight to you. No coding. No expensive software. Just type a ticker and let it run.


⏱ Time to build

30–45 minutes

💰 Cost

Mostly free + ~$5 OpenAI credit

🛠 Tools

n8n + OpenAI + Twelve Data + NewsAPI


n8n workflow diagram for the AI stock analysis agent showing eight connected nodes across two parallel tracks — price data from Twelve Data and news from NewsAPI — merging into an OpenAI-powered trade recommendation
The complete AI stock analysis agent — price data across four timeframes and live news headlines run in parallel before merging into the final AI-powered trade recommendation.

Why most stock research takes too long

Before deciding whether to buy, hold, or sell a stock, a professional typically needs to check the current price, recent price movement, trading volume, analyst sentiment, and any breaking news. Done manually, that means opening four or five tabs, cross-referencing sources, and forming a view — all before you have even started your actual work.

This AI stock analysis agent collapses that entire process into a single step. Type a company name or ticker symbol — like AAPL, TSLA, or MSFT — and the agent pulls live market data, runs the analysis, and returns a structured report with a plain-English recommendation. It even tells you whether the US market is currently open so you always know whether you are looking at live or closing prices.


What you need before you start

You need four things in place before importing the workflow. Everything is either free or low-cost and takes around 20 minutes to set up. You will be prompted to add each key as you configure the relevant node below.

What you needWhere to get itCost
n8n accountn8n.io — cloud or self-hostedFree trial (cloud) or ~$5/month (self-hosted)
Twelve Data API keytwelvedata.comFree — 800 credits/day
NewsAPI keynewsapi.orgFree — 1,000 requests/day
OpenAI API keyplatform.openai.com~$5 credit covers hundreds of runs

Import the AI stock analysis agent into n8n

The workflow is ready to import — you do not need to build it from scratch. Download the file below and follow these steps. Every node is already configured and labelled. The only things you need to add are your own API keys, which are covered node by node in the next section.

⬇️ Download the free workflow template

Includes the full n8n workflow JSON, pre-configured and ready to import.

1. Open your n8n instance and log in
2. In the left sidebar, click Workflows
3. Click Add Workflow in the top right
4. On the empty canvas, click the three dots menu (⋮) in the top right corner
5. Select Import from file and choose the JSON file you downloaded
6. The workflow appears on your canvas with all nodes already connected and labelled

💡 First time using n8n? After logging in, you land on the Workflows page automatically. The canvas is the blank grid where your nodes live — your visual workspace for building automation flows.


How the AI stock analysis agent works — step by step

Step 0 — Chat Trigger

Here is every node in the workflow, what it does, and how to configure it. Work through these in order — by the end you will have a fully working agent.


This is the entry point. Instead of running on a schedule, this workflow starts the moment you type a message into a chat window. n8n generates a unique URL that works like a personal app — open it in any browser, type a ticker like AAPL or TSLA, and the workflow runs instantly.

ParameterValueWhat it means
ModeHosted Chatn8n hosts the chat interface — no website or front-end required
Make Chat Publicly AvailableOnThe chat URL works without logging into n8n — bookmark it and use it like an app
AuthenticationNoneFine for personal use — add authentication if sharing with a team
Initial MessageCustomisable greetingThe first message the chat displays — edit it to explain what the agent does

💡 Your Chat URL: Once the workflow is active, your unique chat URL appears at the top of this node. Copy it, bookmark it, and that becomes your personal stock analysis interface. Nothing else to configure here.


Step 1 — Validate Ticker

Before any data is fetched, the workflow cleans up whatever you typed and extracts a valid stock ticker. If you type apple stock, it extracts AAPL. It also checks whether the US market is currently open, so you always know whether you are looking at live prices or the last closing price. If no valid ticker is found, the workflow stops immediately with a clear error message.

ParameterValueWhat it means
Node typeCode (JavaScript)Custom logic to clean, extract, and validate the ticker
Outputticker, isMarketOpen, marketStatus, currentETTimeFour pieces of information passed to every subsequent step

Nothing to configure here. This node is fully pre-built in the downloaded workflow.


Step 2A — Fetch Live Price Data (Twelve Data)

Once the ticker is validated, the workflow calls Twelve Data four times simultaneously, one call per timeframe. Each call fetches the last 100 price candles at that interval, giving the AI a layered picture of price behaviour rather than a single snapshot.

NodeIntervalWhat it shows
1 min Stock Price1minVery short-term momentum — what the stock is doing right now
5 min Stock Price5minShort-term trend — movement over the last hour or so
15 min Stock Price15minIntraday trend — the shape of today’s trading session
1hr Stock Price1hrMulti-day trend — puts today in context of recent days

Each node is configured identically except for the interval value:

ParameterValueWhat it means
MethodGETFetching data, not sending it
URLhttps://api.twelvedata.com/time_seriesTwelve Data’s historical price endpoint
symbol{{ $json.ticker }}Passes the ticker from Step 1 automatically
interval1min / 5min / 15min / 1hThe timeframe — changes per node
outputsize100Returns the last 100 data points per timeframe
apikeyYOUR_TWELVE_DATA_API_KEY_HEREReplace with your Twelve Data API key

✅ Configure this node — add your Twelve Data API key

  • Sign up free at twelvedata.com (800 credits/day, no credit card required)
  • Go to your dashboard → API Keys → Reveal → copy your key
  • In n8n, click the 1 min Stock Price node → scroll to Query Parameters → find apikey → replace YOUR_TWELVE_DATA_API_KEY_HERE with your key
  • Repeat for the 5 min, 15 min, and 1hr Stock Price nodes

Step 2B — Merge Stock Prices

The four price feeds arrive as four separate streams. This node waits for all four and stacks them into one combined list so the next step can process them together.

ParameterValueWhat it means
Node typeMergeCombines multiple data streams into one
ModeAppendStack all four inputs one after another
Number of Inputs4Wait for all four price feeds before continuing

Nothing to configure here. Pre-built in the downloaded workflow.


Step 2C — Aggregate Stock Data

After merging, the data is still a long list of individual price records. This node bundles everything into a single neat package — all four timeframe reports in one folder before passing to the next step.

ParameterValueWhat it means
Node typeAggregateBundles many records into a single item
AggregateAll Item Data (Into a Single List)Combine every record into one list
Put Output in FielddataNames the output — the next node references it as “data”
IncludeAll FieldsKeep every piece of information — nothing gets dropped

Nothing to configure here. Pre-built in the downloaded workflow.


Step 2D — Structure Stock Data

A code node that tidies the raw price data before it reaches the AI. It unpacks the bundle, cleans and formats the numbers, trims each timeframe to the 30 most recent candles to keep cost low, and calculates a simple price-change indicator per timeframe.

ParameterValueWhat it means
Node typeCode (JavaScript)Custom logic to clean and restructure the data
ModeRun Once for All ItemsProcess the entire dataset in one go, not record by record

💡 What is a candle? Each candle represents one time period: the price at the start (open), the price at the end (close), the highest price reached (high), the lowest (low), and shares traded (volume). Trimming to 30 candles per timeframe gives the AI everything it needs without inflating cost.

Nothing to configure here. Pre-built in the downloaded workflow.


Step 3 — Fetch Recent News (NewsAPI)

Running in parallel with the price data steps, this node searches for news articles mentioning your stock ticker published in the last 3 days, sorted by most recent first. Markets move on news — earnings releases, analyst upgrades, product launches, leadership changes. This gives the AI the context behind the price movement.

ParameterValueWhat it means
MethodGETFetching data from NewsAPI
URLhttps://newsapi.org/v2/everythingNewsAPI’s endpoint for searching all news sources
q{{ $(‘Validate Ticker’).item.json.ticker }}Uses the ticker from Step 1 as the search term automatically
from3 days ago (auto-calculated)Only fetches articles from the last 3 days
apiKeyYOUR_NEWSAPI_KEY_HEREReplace with your NewsAPI key
languageenEnglish articles only
sortBypublishedAtMost recent articles appear first

✅ Configure this node — add your NewsAPI key

  • Sign up free at newsapi.org (1,000 requests/day, no credit card required)
  • Click Get API Key → register with your email → key appears immediately on your dashboard
  • In n8n, click the News Articles node → scroll to Query Parameters → find apiKey → replace YOUR_NEWSAPI_KEY_HERE with your key

Step 4 — Analyse News Sentiment

The raw news articles are sent to GPT-4.1-mini with a specific role: act as a US equities financial analyst focused on market-moving news. The model reads every article and returns a structured sentiment verdict — positive, negative, or neutral — with the reasoning behind it. This becomes one of two inputs to the final AI agent.

ParameterValueWhat it means
Node typeOpenAI — Message a ModelA single prompt in, a single structured response out
ModelGPT-4.1-miniFast and cost-effective — ideal for focused sentiment tasks
RoleSystemSets the AI’s persona before it reads the articles
Output FormatJSON ObjectReturns structured data the next node can read cleanly
Simplify OutputOnStrips technical metadata — returns just the analysis text

✅ Configure this node — connect your OpenAI credential

  • Go to platform.openai.com → create an account → load at least $5 in credit
  • Go to API Keys → Create new secret key → copy your key
  • In n8n, go to Credentials → Add Credential → OpenAI → paste your key → give it a name → click Save
  • Click the Analyse News Sentiment node → select your credential from the Credential to connect with dropdown

Step 5 — Combine Price and Sentiment

At this point the workflow has two separate results — structured price data from Step 2D and sentiment analysis from Step 4. This node waits for both and stacks them into one combined dataset, ready to hand to the final AI agent.

ParameterValueWhat it means
Node typeMergeCombines two data streams into one
ModeAppendStack both inputs one after the other
Number of Inputs2Wait for both price data and sentiment before continuing

Nothing to configure here. Pre-built in the downloaded workflow.


Step 6 — Prepare for AI Agent

A final housekeeping step that bundles the combined dataset into one clean package before handing it to the AI agent — all your research in a single folder before walking into a meeting.

ParameterValueWhat it means
Node typeAggregateBundles everything into one item
AggregateAll Item Data (Into a Single List)Combine everything into one list
Put Output in FielddataNames the output — Step 7 references it as “data”
IncludeAll FieldsKeep everything — nothing gets dropped

Nothing to configure here. Pre-built in the downloaded workflow.


Step 7 — Generate Trade Recommendation

This is the final and most powerful step. Everything the workflow has collected — price data across four timeframes and news sentiment — gets handed to an AI Agent, which produces a clear, decisive trade recommendation in plain English.

💡 Agent node vs standard model call: Step 4 sends one prompt and gets one reply. Step 7 uses an AI Agent node — it can reason across multiple steps, use tools mid-analysis, and maintain memory. The Memory and Tool slots are available but not yet connected, making them easy to add as you extend the agent later.

Sub-nodeStatusWhat it does
Chat ModelConnected — requiredThe AI model the agent uses. Set to GPT-4.1-mini via the OpenAI Chat Model sub-node
MemoryNot connected — optionalWould allow the agent to remember previous analyses across sessions
ToolNot connected — optionalWould allow the agent to run a live web search mid-analysis
OpenAI Chat Model parameterValueWhat it means
Modelgpt-4.1-miniFast and cost-effective for the final reasoning step
Use Responses APIOnUses OpenAI’s newer API — more reliable output from agent nodes

✅ Configure this node — connect your OpenAI credential

  • On the canvas, click the OpenAI Chat Model sub-node directly beneath the Generate Trade Recommendation node
  • In the Credential to connect with dropdown, select the same OpenAI credential you connected in Step 4
  • Confirm the model is set to gpt-4.1-mini and Use Responses API is toggled on

Activate and run your first test

All nodes are now configured. One final step before testing.

1. Click the Inactive / Active toggle in the top right corner of the canvas — switch it to Active
2. Click on the Chat Trigger node and then click Test chat
3. Type a ticker — for example AAPL — and hit send
4. Wait a few seconds. The full analysis will appear in the chat window

⚠️ Common mistake: Do not use the main Execute Workflow button — the workflow will stall at Step 0 because there is no chat message to process. Always use Test chat inside the Chat Trigger node, or activate the workflow and open your live Chat URL.

✅ If it works, you will see:

  • Market status (open or closed) at the top
  • A clear TRADE RECOMMENDATION: BUY / HOLD / SELL
  • Price analysis across all four timeframes
  • News sentiment summary
  • Key risks and a confidence level

What the AI stock analysis agent actually produces

Here is what the agent returns when you type a stock ticker. The full analysis — price movement across four timeframes, news sentiment, key risks, and a final recommendation — is delivered in seconds, directly in the chat window.

How to use it

Open your Chat URL and type either the ticker symbol or the company name — the agent understands both. Then hit send. That is all you need to do.

You can typeOr type
AAPLApple
TSLATesla
MSFTMicrosoft
GOOGLGoogle

Example output — AAPL analysis

Here is a real output from the agent. The user typed AAPL and received this full analysis in under 60 seconds:

Market is CLOSED. Recommendation based on last available prices as of 15:59 ET on May 29, 2026.

TRADE RECOMMENDATION: HOLD

What the price is doing:
  • 1min timeframe: Slightly rising, with price edging up from ~311.87 to 312.07 in the last 10 minutes, though with choppy micro-movements
  • 5min timeframe: Falling in the last candle (15:55 close of 312.07 vs 15:50 close of 312.79), indicating short-term weakness
  • 15min and 1hr views: Both show a gradual rise — 15min candle up 0.33 (0.11%) and 1hr candle up 0.625 (0.2%) to 312.07, confirming a modest upward trend despite the recent 5min decline
  • Volume: Strong through 15min and 1hr candles (4.3M and 5.3M+ shares) — but volume in the last 5min candle (1.98M) is not enough to reverse the short-term decline
What the news says:
  • No news sentiment score or headlines provided — no visible bias to confirm or contradict price. No headline risk detected.
Key risks:
  • Short-term 5min decline could extend, undermining the recent minor gains
  • Lack of bullish volume confirmation in the latest 5min down candle may point to choppiness ahead
  • Absence of news catalysts means the price could be vulnerable to overnight events or market-wide shifts

Confidence: Medium
Mixed signals with modest upward momentum confirmed on broader timeframes but short-term 5min showing weakness and no news support — caution warranted until clearer direction emerges.


Breaking down the output

SectionWhat it tells you
Market statusWhether you are seeing live prices or the last closing price
Trade RecommendationThe agent’s verdict: BUY, HOLD, or SELL
What the price is doingTimeframe-by-timeframe breakdown of price movement and volume
What the news saysWhether recent headlines support, contradict, or are neutral on the price action
Key risksThe specific factors that could invalidate the recommendation
Confidence levelHow much the signals agree — Medium means mixed, High means strong consensus

⚠️ Important disclaimer: This agent is a research and learning tool — not financial advice. Trade recommendations are generated by an AI model based on recent price data and news. Always do your own research and consult a qualified financial adviser before making investment decisions.

Common errors and how to fix them

Most issues with this workflow come down to one of three things: a missing API key, a node that was not activated, or an input the agent did not expect. Here are the errors you are most likely to encounter and exactly how to fix them.


❌ The workflow stalls and nothing happens after I type a ticker

Most likely cause: You clicked the main Execute Workflow button instead of using Test chat, or the workflow is not active.

Fix: Click on the Chat Trigger node (Step 0) and use the Test chat button in the top right of the node panel. Alternatively, make sure the workflow is set to Active using the toggle in the top right of the canvas, then open your Chat URL directly in a browser tab.


❌ “Please type a valid stock ticker symbol”

Most likely cause: The Validate Ticker node could not extract a recognised ticker from what you typed. This happens with very generic phrases, non-US stocks, or unusual formatting.

Fix: Use a standard US ticker symbol or a clear company name. These formats all work reliably:

WorksMay not work
AAPL, TSLA, MSFT, GOOGLApple Inc., Tesla Motors, “the EV company”
Apple, Tesla, MicrosoftNon-US tickers (e.g. HSBA.L, BMW.DE)
AAPL stock, buy TeslaVague terms like “tech stock” or “that EV one”

💡 This workflow is configured for US-listed stocks on NYSE and NASDAQ. International exchanges are not supported in this version.


❌ Red error on one of the Twelve Data nodes

Most likely cause: The API key is missing, incorrect, or the free plan rate limit has been hit.

Fix: Click on the node showing the error and check the following:

1. Open the node and scroll to Query Parameters — confirm the apikey field contains your actual key and not the placeholder text
2. Log into twelvedata.com and check your dashboard — if you have used all 800 daily credits, wait until the next day or upgrade your plan
3. Make sure you have added the key to all four Twelve Data nodes, not just one


❌ Red error on the News Articles node

Most likely cause: The NewsAPI key is missing or incorrect, or you are trying to use the development plan in a production environment.

Fix: Click the News Articles node and check the apiKey parameter. Make sure it contains your actual NewsAPI key with no extra spaces. If the key is correct, log into newsapi.org and check your usage dashboard — the free plan allows 1,000 requests per day.


❌ Red error on the Analyse News Sentiment or Generate Trade Recommendation node

Most likely cause: The OpenAI credential is not connected, the API key is wrong, or your OpenAI account has run out of credit.

Fix: Check the following in order:

1. Click the node showing the error and check the Credential to connect with dropdown — it should show your saved OpenAI credential, not be empty
2. Go to platform.openai.com → Billing and confirm you have a positive credit balance
3. Go to platform.openai.com → API Keys and confirm the key has not been deleted or revoked — if it has, create a new one and update your n8n credential


⚠️ The output says “No news sentiment provided”

This is not an error — it means NewsAPI found no articles about that ticker in the last 3 days. This happens with smaller or less-covered stocks, or when there genuinely has been no recent news.

What to do: The agent will still produce a price-based analysis and recommendation — it will simply note that no news context was available. If you want broader news coverage, you can extend the from parameter in the News Articles node from 3 days to 7 days.


⚠️ The output says “Market is CLOSED”

This is not an error — it means you ran the agent outside NYSE and NASDAQ trading hours (Monday to Friday, 9:30am to 4:00pm Eastern Time). The price data is based on the last available closing prices rather than live quotes.

The analysis is still valid — the agent simply tells you the data context upfront so you are never looking at stale prices without knowing it.


Still stuck? How to read the error in n8n

If you see a red dot on any node, click on it to open the node panel, then click the Output tab on the right side. The error message there will tell you exactly what went wrong. The most common messages and what they mean:

Error messageWhat it meansFix
401 UnauthorizedAPI key is wrong or missingCheck the key in the node’s Query Parameters
429 Too Many RequestsYou have hit the rate limit for that APIWait a few minutes or check your daily usage
Insufficient creditsYour OpenAI account is out of creditAdd credit at platform.openai.com → Billing
Could not find a tickerThe Validate Ticker node could not parse your inputUse a standard ticker symbol like AAPL or TSLA
No input dataA previous node did not pass any data forwardCheck the node before it for a red error dot

Ways to extend this agent

The version you just built is deliberately simple — one ticker, one analysis, one response. But the architecture is designed to grow. Here are the most useful extensions, from quick wins to more advanced builds.


Schedule it to run every morning

Instead of typing a ticker manually each time, add a Schedule Trigger node that runs the agent automatically before the market opens — say 9:00am ET every weekday. Swap the Chat Trigger for a Schedule Trigger, hardcode your most-watched tickers, and wake up to a fresh analysis waiting for you every morning.


Email the report to yourself

Add a Gmail or Outlook node at the end of the workflow to send the trade recommendation directly to your inbox. Combine this with the scheduler above and you have a fully automated daily briefing — zero manual input required.


Save every analysis to Google Sheets

Add a Google Sheets node at the end to log each analysis — ticker, date, recommendation, confidence level, and key risks — into a spreadsheet. Over time this builds a personal track record you can review to see how the agent’s recommendations have held up.


Connect the Memory node

The Generate Trade Recommendation node already has a Memory slot ready to connect. Add a memory module and the agent will remember previous analyses for the same stock across sessions — allowing it to say things like “last time you asked about AAPL it was a HOLD, today it is a BUY, here is what changed.”


Add a live web search tool

Connect a web search tool to the Tool slot on the Generate Trade Recommendation node. This allows the agent to search for live information mid-analysis rather than relying solely on what NewsAPI returned — useful for fast-moving situations where news breaks between API calls.


Analyse multiple tickers at once

Add a Code node that accepts a comma-separated list of tickers and loops through each one. The workflow runs the full analysis for every ticker and returns a ranked summary — ideal for screening a watchlist quickly rather than running the agent one stock at a time.


More AI agents for business professionals

This is one of a growing library of AI agent tutorials built specifically for business professionals — no coding required, no developer background assumed. Each post follows the same format: a real business problem, a working n8n workflow, and a free template you can download and run today.

👉 Browse all posts at mymbaproject.com and find the agent that solves your next biggest time drain.

📺 New agents every week on YouTube

Each tutorial will soon be available as a full video walkthrough — watch the build live, follow along at your own pace, and get the free template in the description.


Discover more from My MBA Project

Subscribe to get the latest posts to your email.


Leave a Reply

You may also be interested in

Discover more from My MBA Project

Subscribe now to keep reading and get access to the full archive.

Continue reading