股价异常检测及相关新闻自动通知工作流
高级
这是一个Crypto Trading, Multimodal AI领域的自动化工作流,包含 26 个节点。主要使用 If, Set, Code, DeepL, Merge 等节点。 使用Marketstack、HackerNews和DeepL检测股价异常并发送新闻提醒
前置要求
- •Slack Bot Token 或 Webhook URL
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "72lks0Gu4Zqi4t0i",
"meta": {
"instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
"templateCredsSetupCompleted": true
},
"name": "股价异常检测及相关新闻自动通知工作流",
"tags": [],
"nodes": [
{
"id": "a69b05fc-16c6-4f68-bd14-717b647ad900",
"name": "每日检查",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-544,
0
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 9
},
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "7ab68dfb-380e-4880-a948-89ad068e7533",
"name": "获取股票数据",
"type": "n8n-nodes-base.marketstack",
"position": [
-320,
0
],
"parameters": {
"filters": {
"dateTo": "2025-09-30T00:00:00",
"latest": false,
"dateFrom": "2025-09-01T00:00:00"
},
"symbols": "AMZN"
},
"credentials": {
"marketstackApi": {
"id": "fQQ77wILan88cfRN",
"name": "Marketstack account"
}
},
"typeVersion": 1
},
{
"id": "e8b1795e-59dd-4c7a-9db0-78d3e3228b25",
"name": "计算偏差",
"type": "n8n-nodes-base.code",
"position": [
-96,
0
],
"parameters": {
"jsCode": "// === パラメータ設定 ===\nconst N = 20; // 移動平均の期間\nconst k = 2; // σの倍率(±2σ)\n\n// === データ取得 ===\nlet data = [];\n\n// Marketstackの出力構造をチェック\nif (items[0].json.data) {\n // 通常ケース(Marketstackノードからそのまま)\n data = items[0].json.data;\n} else {\n // 予備パターン:items配列にデータが直接並んでいるケース\n data = items.map(item => item.json);\n}\n\n// N件だけ抽出\ndata = data.slice(0, N);\n\n// === 終値のみ抽出 ===\nconst closes = data.map(d => d.close).filter(v => typeof v === 'number');\n\n// データがない場合の対策\nif (closes.length === 0) {\n return [{ json: { error: \"No valid close data found.\" } }];\n}\n\n// === 移動平均と標準偏差を計算 ===\nconst mean = closes.reduce((a, b) => a + b, 0) / closes.length;\nconst variance = closes.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / closes.length;\nconst sigma = Math.sqrt(variance);\n\n// === 最新値(先頭) ===\nconst latestClose = closes[0] + 100;\n\n// === 判定 ===\nlet status = \"normal\";\nif (latestClose > mean + k * sigma) {\n status = \"high (above +2σ)\";\n} else if (latestClose < mean - k * sigma) {\n status = \"low (below -2σ)\";\n}\n\n// === 出力 ===\nreturn [\n {\n json: {\n mean: mean.toFixed(2),\n sigma: sigma.toFixed(2),\n upper: (mean + k * sigma).toFixed(2),\n lower: (mean - k * sigma).toFixed(2),\n latest: latestClose.toFixed(2),\n status,\n count: closes.length\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "5f5c9951-f936-495d-985f-7ae2108d2787",
"name": "是否异常?(状态 != \"正常\")",
"type": "n8n-nodes-base.if",
"position": [
128,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f79f5888-e19f-4273-81b7-5b6f434fea65",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{$json[\"status\"]}}",
"rightValue": "=normal"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "830c1c3b-92d7-42c2-a698-ec213787ace9",
"name": "获取相关新闻",
"type": "n8n-nodes-base.hackerNews",
"position": [
800,
96
],
"parameters": {
"resource": "all",
"additionalFields": {
"keyword": "={{ $json.keyword }}"
}
},
"typeVersion": 1
},
{
"id": "31e2ca1d-9c30-4dbc-9a67-54e12ca974a3",
"name": "翻译新闻",
"type": "n8n-nodes-base.deepL",
"position": [
1248,
32
],
"parameters": {
"text": "={{ $json.message }}",
"translateTo": "JA",
"additionalFields": {}
},
"credentials": {
"deepLApi": {
"id": "S5c8ArKkbeIQQU5Z",
"name": "DeepL account 3"
}
},
"typeVersion": 1
},
{
"id": "478fdb62-dde4-40e3-9e0b-2676330f91c0",
"name": "发送警报到 Slack",
"type": "n8n-nodes-base.slack",
"position": [
1696,
96
],
"webhookId": "e0a002a8-b1df-41ff-a431-459120a37e77",
"parameters": {
"text": "=🌐 *Original (English)* \n{{ $json.message }}\n\n---\n\n🇯🇵 *Translated (Japanese)* \n{{ $json.text }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "CKUCBTG0H",
"cachedResultName": "general"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "2kyw7TSL5VT4S3md",
"name": "Slack account 8"
}
},
"typeVersion": 2.3
},
{
"id": "7ea2b37e-e074-400d-9e3b-28ac0bc9c816",
"name": "发送正常报告到 Slack",
"type": "n8n-nodes-base.slack",
"position": [
352,
-96
],
"webhookId": "b0f44cfc-ae30-4339-9428-c4fb468f900e",
"parameters": {
"text": "=✅ 異常なし この銘柄の終値は安定しています。 現在値:{{ $('Calculate Deviation').item.json.latest }}(平均 {{ $('Calculate Deviation').item.json.mean }} ± {{ $('Calculate Deviation').item.json.sigma }})",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "CKUCBTG0H",
"cachedResultName": "general"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "2kyw7TSL5VT4S3md",
"name": "Slack account 8"
}
},
"typeVersion": 2.3
},
{
"id": "34c1613d-306b-47fa-b982-db156c54e053",
"name": "合并原文+译文",
"type": "n8n-nodes-base.merge",
"position": [
1472,
96
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "be7b89c0-99ac-44cb-aec0-03b844bc50f5",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-640,
-224
],
"parameters": {
"color": 7,
"width": 224,
"height": 192,
"content": "## 每日检查(09:00 JST)"
},
"typeVersion": 1
},
{
"id": "2ea66681-b507-4737-a6f4-0d0c2590646f",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
208
],
"parameters": {
"color": 7,
"height": 192,
"content": "## 获取股票数据(Marketstack)"
},
"typeVersion": 1
},
{
"id": "e85baa53-b0ed-4017-98b0-e7a07a88c7aa",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1472,
304
],
"parameters": {
"color": 7,
"width": 624,
"height": 256,
"content": "## 自定义提示"
},
"typeVersion": 1
},
{
"id": "22cad535-6c1f-44c1-9018-910baa276cba",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
496
],
"parameters": {
"color": 7,
"width": 400,
"height": 384,
"content": "## 节点结构概览"
},
"typeVersion": 1
},
{
"id": "fa231074-0537-4cc6-b33c-e90006605377",
"name": "便签说明4",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
352
],
"parameters": {
"color": 7,
"height": 176,
"content": "## 发送正常报告到 Slack"
},
"typeVersion": 1
},
{
"id": "2c8bbc35-0320-4350-b64f-e58eacd7c974",
"name": "便签说明5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-448
],
"parameters": {
"color": 7,
"width": 304,
"height": 272,
"content": "## 🛠️ 设置说明"
},
"typeVersion": 1
},
{
"id": "7fbb2805-1ffd-4ce6-86a6-04d9ba827191",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1184,
-288
],
"parameters": {
"width": 480,
"height": 816,
"content": "## 价格异常检测和新闻警报(Marketstack + HN + DeepL + Slack)"
},
"typeVersion": 1
},
{
"id": "4a60a88c-3f9d-4919-9f8e-769138eebad2",
"name": "便签 7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-192,
-160
],
"parameters": {
"color": 7,
"width": 256,
"content": "## 计算偏差"
},
"typeVersion": 1
},
{
"id": "d3e597a0-0400-400d-970d-f179bf3c574c",
"name": "## 为什么选择 4o 模型?👆",
"type": "n8n-nodes-base.stickyNote",
"position": [
32,
176
],
"parameters": {
"color": 7,
"width": 256,
"height": 176,
"content": "## 是否异常?(状态 != \"正常\")"
},
"typeVersion": 1
},
{
"id": "cb2c48c9-349d-4c3e-9f17-ed4636ca0b82",
"name": "便签 9",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
288
],
"parameters": {
"color": 7,
"width": 256,
"height": 176,
"content": "## 获取相关新闻(Hacker News)"
},
"typeVersion": 1
},
{
"id": "8a824d8c-3d66-4838-9c5e-a8708afcfa1d",
"name": "便签10",
"type": "n8n-nodes-base.stickyNote",
"position": [
944,
-208
],
"parameters": {
"color": 7,
"width": 256,
"height": 176,
"content": "## 格式化新闻(标题+摘要+URL)"
},
"typeVersion": 1
},
{
"id": "1ef7949a-e396-449a-b21c-4e72e7031c38",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
1232,
-208
],
"parameters": {
"color": 7,
"width": 208,
"height": 176,
"content": "## 翻译新闻(EN → JA)"
},
"typeVersion": 1
},
{
"id": "4a410b17-9763-4723-a5f2-61fb6ab50fd7",
"name": "便签12",
"type": "n8n-nodes-base.stickyNote",
"position": [
1504,
-208
],
"parameters": {
"color": 7,
"width": 208,
"height": 176,
"content": "## 合并原文+译文"
},
"typeVersion": 1
},
{
"id": "0d5d6b48-6983-4136-80e3-0cf9de926972",
"name": "便签13",
"type": "n8n-nodes-base.stickyNote",
"position": [
1744,
-208
],
"parameters": {
"color": 7,
"width": 208,
"height": 176,
"content": "## 发送警报到 Slack(异常)"
},
"typeVersion": 1
},
{
"id": "fe474a5c-9358-4f1b-ad07-b2ae6169c280",
"name": "添加符号字段",
"type": "n8n-nodes-base.set",
"position": [
352,
96
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "a1de4889-f506-46c6-8189-4e173dad6c39",
"name": "symbol",
"type": "string",
"value": "={{$item(0).$node[\"Get Stock Data\"].json[\"symbol\"]}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ad957b08-b108-427e-9843-b48be879cb3b",
"name": "编写 Slack 消息",
"type": "n8n-nodes-base.code",
"position": [
1024,
96
],
"parameters": {
"jsCode": "// === Hacker News 出力からタイトル・本文・URLを整形 ===\nconst results = items.map(item => {\n const highlight = item.json._highlightResult || {};\n\n const title =\n highlight.title?.value ||\n item.json.title ||\n \"No Title\";\n\n const story =\n highlight.story_text?.value ||\n item.json.story_text ||\n \"No summary available.\";\n\n const url =\n item.json.url ||\n highlight.url?.value ||\n \"No URL\";\n\n // === HTMLタグ(<em>など)を除去 ===\n const cleanTitle = title.replace(/<[^>]*>/g, \"\");\n const cleanStory = story.replace(/<[^>]*>/g, \"\");\n\n return `📰 ${cleanTitle}\\n${cleanStory}\\n🔗 ${url}`;\n});\n\n// === 出力 ===\nreturn [\n {\n json: {\n message: results.slice(0, 3).join(\"\\n\\n---\\n\\n\"), // 上位3件を区切って結合\n },\n },\n];\n"
},
"typeVersion": 2
},
{
"id": "a5ecf56c-8e7d-42da-9335-a2b1a08b71a1",
"name": "构建新闻关键词",
"type": "n8n-nodes-base.code",
"position": [
576,
96
],
"parameters": {
"jsCode": "const map = {\n AMZN: 'Amazon',\n AAPL: 'Apple',\n GOOG: 'Google',\n MSFT: 'Microsoft',\n TSLA: 'Tesla',\n};\n\n// 入力の中身を確認\nconsole.log('INPUT items:', items);\n\nconst first = (items && items[0] && items[0].json) ? items[0].json : {};\nconst symbol = String(first.symbol || first.ticker || '').toUpperCase();\n\nif (!symbol) {\n // symbolが無い時は理由と入力を返して可視化\n return [\n {\n json: {\n error: 'symbol is missing',\n debugInput: first,\n },\n },\n ];\n}\n\nconst keyword = map[symbol] || symbol;\n\nreturn [\n {\n json: { keyword, symbol },\n },\n];\n"
},
"typeVersion": 2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "e90eb5a4-58e8-4a2d-82c3-30862bc8832f",
"connections": {
"Daily Check": {
"main": [
[
{
"node": "Get Stock Data",
"type": "main",
"index": 0
}
]
]
},
"Get Stock Data": {
"main": [
[
{
"node": "Calculate Deviation",
"type": "main",
"index": 0
}
]
]
},
"Translate News": {
"main": [
[
{
"node": "Merge Original + Translated",
"type": "main",
"index": 0
}
]
]
},
"Add Symbol Field": {
"main": [
[
{
"node": "Build News Keyword",
"type": "main",
"index": 0
}
]
]
},
"Get Related News": {
"main": [
[
{
"node": "Compose Slack Message",
"type": "main",
"index": 0
}
]
]
},
"Build News Keyword": {
"main": [
[
{
"node": "Get Related News",
"type": "main",
"index": 0
}
]
]
},
"Calculate Deviation": {
"main": [
[
{
"node": "Is Anomaly? (status != \"normal\")",
"type": "main",
"index": 0
}
]
]
},
"Send Alert to Slack": {
"main": [
[]
]
},
"Compose Slack Message": {
"main": [
[
{
"node": "Translate News",
"type": "main",
"index": 0
},
{
"node": "Merge Original + Translated",
"type": "main",
"index": 1
}
]
]
},
"Merge Original + Translated": {
"main": [
[
{
"node": "Send Alert to Slack",
"type": "main",
"index": 0
}
]
]
},
"Is Anomaly? (status != \"normal\")": {
"main": [
[
{
"node": "Add Symbol Field",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Normal Report to Slack",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 加密货币交易, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用DeepL自动翻译YouTube视频为日语并发布到Slack
使用DeepL自动翻译YouTube视频为日语并发布到Slack
If
Code
Deep L
+5
20 节点noda
社交媒体
基于AI的会议研究与每日议程(Google日历、Attio CRM和Slack)
基于AI的会议研究与每日议程:使用Google日历、Attio CRM和Slack
If
Set
Code
+15
30 节点Harry Siggins
AI 摘要总结
使用Groq、Gemini和Slack审批系统自动化RSS到Medium发布
通过Groq、Gemini和Slack审批系统实现RSS到Medium发布的自动化流程
If
Set
Code
+16
41 节点ObisDev
内容创作
使用OpenAI、Ahrefs和多平台集成的自动化内容营销智能
使用OpenAI、Ahrefs和多平台集成的自动化内容营销智能
If
Set
Code
+8
21 节点Nikan Noorafkan
市场调研
自动化会议准备
使用 GPT-5 和 Gemini 研究从日历到 Slack 通过 Attio CRM 自动准备会议
If
Set
Code
+16
39 节点Harry Siggins
AI 摘要总结
防欺诈潜在客户捕获与培育系统
通过AI评分、表格跟踪和多渠道提醒捕获和培育防欺诈潜在客户
If
Set
Code
+11
28 节点Jitesh Dugar
内容创作