n8n AI-Powered Stock Market Summary Bot: Hourly RSI & MACD Alerts to Slack
Input: stock ticker list; Process: scheduled trigger → Alpaca data fetch → Python technical indicator calculation → OpenAI summary generation; Output: categorized Buy/Hold/Sell Slack message
- Who
- n8n users who want automated US stock monitoring with Slack alerts
- You get
- Hourly automated data fetch, RSI/MACD calculation, signal generation, and Slack delivery during US market hours
Constraints
Prerequisites: accessible n8n instance; Alpaca API credentials (httpCustomAuth, paper-api endpoint); OpenAI API credentials (pre-configured Assistant required); Slack API credentials (target user or channel needed). Workflow timezone set to America/Los_Angeles. Known limitations: OpenAI Assistant ID and Slack user ID are redacted in template; RSI thresholds 30/70 and MACD parameters 12/26/9 are hardcoded; iex feed used to avoid SIP permission errors. Not tested.
What they did
Author kenandrewmiranda published this workflow template on n8n.io. It uses a Schedule Trigger during US market hours, fetches stock data via the Alpaca API, calculates RSI and MACD indicators in Python, calls an OpenAI Assistant to generate plain-English categorized summaries, and pushes results to Slack.
How it went
The template has 35,948 views on n8n.io (author-reported). The author describes expected behavior: hourly Slack messages with 🟢/⚪/🔴 categorized stock analysis summaries.
Worth knowing
The template uses the Alpaca paper API endpoint (not live trading). The OpenAI Assistant ID and Slack user ID are redacted in the public template; users must configure their own. RSI buy threshold 30 and sell threshold 70 are hardcoded in Python. feed=iex avoids SIP data permission errors. Timezone is fixed to America/Los_Angeles. Not tested; verify API credential validity and OpenAI Assistant output format during setup.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- Fetch Stock Data node: connect httpCustomAuth credentials.
- Stock Analysis Assistant node: connect OpenAI API credentials.
- Send Summary to User(s) node: connect Slack API credentials.
- Check Market Status node: connect httpCustomAuth credentials.
Configuration to replace
- Source template is n8n public workflow #4867 (~21 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Configure Schedule Trigger and Market Status Check
Add a Schedule Trigger node with Cron expression `0 30 6-14 * * 1-5` (hourly Mon–Fri 6:30 AM–2:30 PM PT). Then add an HTTP Request node calling `https://paper-api.alpaca.markets/v2/clock` to check if the market is open, followed by an If node evaluating `{{ $json.is_open }}`: if true continue, if false exit gracefully via a NoOp node.
Set Up Ticker List
Add an Edit Fields (Set) node and define the stock symbols to monitor in the JSON output. Default list: AAPL, MSFT, NVDA, TSLA, AMZN, GOOGL, META, JPM, XOM, UNH, GME. Modify as needed.
Configure Alpaca Stock Data Fetch
Add an HTTP Request node with URL `=https://data.alpaca.markets/v2/stocks/bars`, authentication set to httpCustomAuth. Query parameters: symbols from `{{ $json.symbols }}`, timeframe=`1Day`, limit=`1000`, feed=`iex` (avoids SIP permission error), start=100 days ago, end=today.
Add Python Technical Indicator Calculation Node
Add a Code node with language set to Python. This node receives Alpaca bars data, calculates RSI(14) and MACD(12,26,9), and generates Buy/Hold/Sell signals based on thresholds. Outputs include a stocks list and a summary JSON string for GPT.
Execution prompt · Source text。Interpret Data node (n8n-nodes-base.code), language: python
import pandas as pd import numpy as np import json bars_by_symbol = items[0]['json']['bars'] stocks = [] for symbol, bars in bars_by_symbol.items(): closes = [bar['c'] for bar in bars if 'c' in bar] if len(closes) < 30: continue df = pd.DataFrame({'close': closes}) # RSI(14) delta = df['close'].diff() gain = delta.clip(lower=0) loss = -delta.clip(upper=0) avg_gain = gain.rolling(14).mean() avg_loss = loss.rolling(14).mean() rs = avg_gain / avg_loss df['rsi'] = 100 - (100 / (1 + rs)) # MACD (12,26,9) ema12 = df['close'].ewm(span=12, adjust=False).mean() ema26 = df['close'].ewm(span=26, adjust=False).mean() df['macd'] = ema12 - ema26 df['signal'] = df['macd'].ewm(span=9, adjust=False).mean() latest = df.iloc[-1] rsi = latest['rsi'] macd = latest['macd'] signal = latest['signal'] status = "Hold" if rsi < 30 and macd > signal: status = "Buy" elif rsi > 70 and macd < signal: status = "Sell" stocks.append({ "ticker": symbol, "rsi": round(float(rsi), 2), "macd": round(float(macd), 2), "signal": round(float(signal), 2), "status": status }) return [{ "json": { "summary": json.dumps({ "stocks": stocks }, separators=(',', ':')), "stocks": stocks } }]Configure OpenAI Stock Analysis Assistant
Add an OpenAI node with resource set to assistant. Enter dynamic content in the text field referencing technical indicator data and timestamp. You must pre-create an Assistant in the OpenAI platform and configure the system prompt to generate Slack-friendly Markdown with stocks grouped into Buy Watchlist / Neutral Hold / Caution Sell categories.
Execution prompt · Source text。Stock Analysis Assistant node text field (OpenAI Assistant message input)
=Here is the technical indicator data as JSON: {{ $json.summary }} Pulled as of {{ $now }}Execution prompt · Source text。OpenAI Assistant system/instruction prompt (configure in OpenAI platform when setting up the Assistant; Sticky Note10 documents intended behavior)
You are a financial assistant writing a quick, readable market update for a general audience. Your job is to help people understand how well-known stocks are behaving — even if they aren’t professional traders. You’ll be given: A list of stocks with technical indicators (e.g., momentum data) A timestamp (in RFC 3339 or ISO format) for when the data was pulled. 📌 Your task: Group the stocks into three categories: 🟢 Buy Watchlist – Stocks showing signs of recovery or upward momentum ⚪ Neutral Hold – Stocks with steady or unclear direction 🔴 Caution / Sell – Stocks that appear overbought or may pull back For each stock: Write a short, plain-language insight about what’s happening Use familiar terms like “gaining steam,” “cooling off,” or “showing hesitation” Avoid technical jargon like RSI or MACD unless context makes it helpful Add a helpful tip or comment for each stock (e.g., “This pattern often signals hesitation” or “This dip might attract bargain hunters”) Finish with a summary line using the timestamp like this: Summary as of October 2, 2025 – Most stocks were stable with one or two worth watching. 📦 Respond in Slack Markdown Only: Example Format: *📊 Market Summary (as of October 2, 2025)* 🟢 *Buy Watchlist* • TSLA – Recovering after a dip; gaining steam. This type of rebound often attracts early buyers. ⚪ *Neutral Hold* • AAPL – Holding steady. This often means the market is waiting on new developments. • GOOGL – Moving sideways. A sign of consolidation before potential breakout. • MSFT – Little movement. Could be digesting prior gains. • NVDA – Slight back-and-forth. May indicate indecision in the market. 🔴 *Caution / Sell* • None at this time. _Summary as of October 2, 2025: Most stocks appear steady. TSLA could be one to watch if momentum holds._ 🚫 Do NOT: Return raw JSON Use code blocks unless formatting Slack markdown (no YAML or tags) Use technical finance language unless simplified
Configure Slack Message Delivery
Add a Slack node, select user or channel for the select parameter, and set the text field to `{{ $json.output }}` to send the OpenAI-generated summary. Configure Slack API credentials in advance and ensure the bot has permission to post to the target channel or user.
Save and Activate Workflow
Confirm the workflow timezone is set to America/Los_Angeles, verify all credentials are properly configured, then save and activate the workflow. Run a manual test first to validate Alpaca data retrieval and OpenAI output formatting.
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first
This block is the prompt. Ads are never placed here.
You are a stock analysis workflow setup assistant. The user will provide access to an n8n instance, Alpaca API key, OpenAI API key, and Slack bot token. Help them complete the setup in this order: 1) Configure schedule trigger and market status check; 2) Set up ticker list; 3) Configure Alpaca data fetch node; 4) Add Python technical indicator calculation; 5) Configure OpenAI Assistant node (pre-create Assistant in OpenAI platform and paste system prompt); 6) Configure Slack send node; 7) Test and activate. Note: OpenAI Assistant ID and Slack user/channel ID must be provided by the user.
Requires: n8n instance, Alpaca API key, OpenAI API key (with pre-configured Assistant), Slack bot token, target Slack user/channel ID
Source
AI-powered stock market summary bot · kenandrewmiranda · n8n.io · 2025-06-11
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.