8
n8n 中文网amn8n.com

市场观察机器人

中级

这是一个Crypto Trading领域的自动化工作流,包含 14 个节点。主要使用 Code, Wait, Slack, HttpRequest, SplitInBatches 等节点。 FinnHub API和Slack模板

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "VYmYeHeu5eKYVLXA",
  "meta": {
    "instanceId": "3a80618028e8320a9c63d9239bfaf37c2f20bb22591695cb28556731cef25f4d",
    "templateCredsSetupCompleted": true
  },
  "name": "市场观察机器人",
  "tags": [
    {
      "id": "mmCdWnzPkjIpcvuR",
      "name": "Investment",
      "createdAt": "2025-06-15T04:39:59.965Z",
      "updatedAt": "2025-06-15T04:39:59.965Z"
    }
  ],
  "nodes": [
    {
      "id": "a244c890-bc5f-4edd-91f4-37192d7807c2",
      "name": "每日市场新闻触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -3000,
        660
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "15 9 * * 1-5"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1baa58b8-de7e-469c-a1ab-3c020e87714e",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2340,
        660
      ],
      "parameters": {
        "url": "https://finnhub.io/api/v1/company-news",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ $json.ticker }}"
            },
            {
              "name": "from",
              "value": "={{ $now.toLocal().toISO().split('T')[0] }}"
            },
            {
              "name": "to",
              "value": "={{ $now.toLocal().toISO().split('T')[0] }}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "Tj0aIslgiVQgNZb4",
          "name": "Header Auth - Finnhub"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "c36458a6-50c2-4219-b459-6629147c205e",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2560,
        660
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0da44d7e-1300-4d47-80f2-da63e647dfe8",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1260,
        740
      ],
      "webhookId": "6c990829-24a2-4dfd-a689-4bdbd37a8bd3",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "64246872-3c95-429f-93e8-561ad6b6b940",
      "name": "Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        -1740,
        660
      ],
      "webhookId": "4a63a5b5-e257-430e-8956-8cd1a620c4f2",
      "parameters": {
        "text": "={{ $json.output }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#stock-market"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "id": "CBElgW2pS2InXBCW",
          "name": "Slack Market Bot"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "35e91c84-e051-4b71-91ea-2800d5919751",
      "name": "格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        -2120,
        660
      ],
      "parameters": {
        "jsCode": "let msg = '*' + ($input.first().json.related ? $input.first().json.related : $('Loop Over Items').first().json.ticker) + '* - Daily Market News :newspaper: \\n\\n';\n\nlet count = 0;\n\nif ($input.first().json.related) {\n  for (const item of $input.all()) {\n    count++;\n    if (count <= 5) {\n      msg += '- <' + item.json.url + '|' + item.json.headline + '>\\n';\n    } else {\n      break;\n    }\n    \n  }\n} else {\n  msg += 'No news found for this ticker'\n}\n\nreturn {\n  output: msg\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "4ab6c87d-536e-4d40-a6c3-e92ed3f30e13",
      "name": "无操作,不执行任何动作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2360,
        260
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4987c8e4-83da-403c-aca2-f56e77d9f4a9",
      "name": "准备股票代码",
      "type": "n8n-nodes-base.code",
      "position": [
        -2780,
        660
      ],
      "parameters": {
        "jsCode": "const tickers = [\"AAPL\", \"META\", \"NVDA\", \"TSLA\", \"MSFT\", \"AMZN\", \"GOOG\", \"IAU\", \"IBIT\", \"QQQ\", \"SPY\"];\n\nlet output = [];\n\nfor(const item of tickers) {\n  output.push({ticker: item});\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "8914ece4-d42b-4db9-a6dd-ef6310320e53",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3820,
        320
      ],
      "parameters": {
        "width": 460,
        "height": 960,
        "content": "## 每日公司新闻机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "553353ca-c848-4110-91a5-ffdd9edabc28",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2840,
        460
      ],
      "parameters": {
        "content": "## 准备股票代码列表"
      },
      "typeVersion": 1
    },
    {
      "id": "957ee9cc-3f32-4bed-aaf8-6ff3d9e8f1d3",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2380,
        420
      ],
      "parameters": {
        "width": 440,
        "height": 440,
        "content": "## 通过 FinnHub API 获取公司新闻"
      },
      "typeVersion": 1
    },
    {
      "id": "eea4abee-a783-452c-afb1-496e658f2e38",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1900,
        420
      ],
      "parameters": {
        "width": 440,
        "height": 440,
        "content": "## 通过 Webhook 发布到 Slack 频道"
      },
      "typeVersion": 1
    },
    {
      "id": "45362a93-2523-44e4-8e3e-1b642eaa7381",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        420
      ],
      "parameters": {
        "width": 440,
        "height": 440,
        "content": "## 等待5秒"
      },
      "typeVersion": 1
    },
    {
      "id": "51f5c38c-3fd9-4022-9c24-d83b4d98818d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3060,
        860
      ],
      "parameters": {
        "content": "## Cron 计划程序"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1",
    "timeSavedPerExecution": 15
  },
  "versionId": "e2ac836d-ee4b-4f78-b43b-e8054c511bc1",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prep Tickers": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Market News Trigger": {
      "main": [
        [
          {
            "node": "Prep Tickers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 加密货币交易

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量14
分类1
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Fan Luo

Fan Luo

@luofan189

Hi, there, I am Fan Luo, father of two lovely daughters Chloe and Claire. My family and I live in a small beautiful town in Toronto area, Canada. I have extensive experience as a developer, technical leader and AI automation expert and solopreneur. My expertise are web app development, hybrid app development and process automation.

外部链接
在 n8n.io 查看

分享此工作流