8
n8n 中文网amn8n.com

AI Sonar-Pro黄金市场追踪器:基于新闻经济数据预测价格

高级

这是一个Crypto Trading, AI Summarization领域的自动化工作流,包含 22 个节点。主要使用 Set, Merge, Slack, EmailSend, Wordpress 等节点。 使用Perplexity Sonar-Pro、FRED数据和WordPress报告的黄金市场预测系统

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "nTt3ryZ7mIeGMnVv",
  "meta": {
    "instanceId": "b91e510ebae4127f953fd2f5f8d40d58ca1e71c746d4500c12ae86aad04c1502"
  },
  "name": "AI Sonar-Pro 黄金市场追踪器:根据新闻和经济数据预测价格",
  "tags": [],
  "nodes": [
    {
      "id": "b83c3eaf-eb99-4de6-bfb4-f572559f9960",
      "name": "每 6 小时",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        512,
        256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c799a1dc-f452-4deb-b771-727c45e41a9e",
      "name": "获取当前黄金价格",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        -128
      ],
      "parameters": {
        "url": "https://api.metalpriceapi.com/v1/latest",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "queryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key",
              "value": "={{ $credentials.apiKey }}"
            },
            {
              "name": "base",
              "value": "USD"
            },
            {
              "name": "currencies",
              "value": "XAU"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "722ee37a-298c-4c93-b5ed-55fe71bce92c",
      "name": "获取财经新闻",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        64
      ],
      "parameters": {
        "url": "https://newsapi.org/v2/everything",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "queryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "apiKey",
              "value": "={{ $credentials.apiKey }}"
            },
            {
              "name": "q",
              "value": "gold market OR precious metals OR inflation OR federal reserve"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "sortBy",
              "value": "publishedAt"
            },
            {
              "name": "pageSize",
              "value": "20"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "32d7a705-f003-4b3a-8487-88091161305e",
      "name": "获取通胀数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        256
      ],
      "parameters": {
        "url": "https://api.stlouisfed.org/fred/series/observations",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "series_id",
              "value": "CPIAUCSL"
            },
            {
              "name": "api_key",
              "value": "={{ $credentials.apiKey }}"
            },
            {
              "name": "file_type",
              "value": "json"
            },
            {
              "name": "limit",
              "value": "12"
            },
            {
              "name": "sort_order",
              "value": "desc"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9bc19922-62ed-43c9-8a2e-260ad222e0a4",
      "name": "获取利率数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        448
      ],
      "parameters": {
        "url": "https://api.stlouisfed.org/fred/series/observations",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "series_id",
              "value": "FEDFUNDS"
            },
            {
              "name": "api_key",
              "value": "={{ $credentials.apiKey }}"
            },
            {
              "name": "file_type",
              "value": "json"
            },
            {
              "name": "limit",
              "value": "12"
            },
            {
              "name": "sort_order",
              "value": "desc"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "24c0614a-458f-4c97-a699-658129e12af4",
      "name": "获取就业数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        640
      ],
      "parameters": {
        "url": "https://api.stlouisfed.org/fred/series/observations",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "series_id",
              "value": "UNRATE"
            },
            {
              "name": "api_key",
              "value": "={{ $credentials.apiKey }}"
            },
            {
              "name": "file_type",
              "value": "json"
            },
            {
              "name": "limit",
              "value": "12"
            },
            {
              "name": "sort_order",
              "value": "desc"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8f69c836-908d-474c-b1af-e4a40dfb6133",
      "name": "格式化黄金价格",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        -128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "gold_price",
              "name": "gold_price_usd",
              "type": "number",
              "value": "={{ $json.rates.XAU }}"
            },
            {
              "id": "timestamp",
              "name": "price_timestamp",
              "type": "string",
              "value": "={{ $json.timestamp }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e66ccf59-958b-48b2-8b9b-c810c43ac8bc",
      "name": "格式化新闻数据",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "news_articles",
              "name": "news_summary",
              "type": "array",
              "value": "={{ $json.articles.map(a => ({ title: a.title, source: a.source.name, publishedAt: a.publishedAt, description: a.description, url: a.url })).slice(0, 10) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "698df7ed-3e8b-4fd0-b7c6-ca117c1e6fb7",
      "name": "格式化通胀",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "inflation_data",
              "name": "inflation_trend",
              "type": "array",
              "value": "={{ $json.observations.slice(0, 6).map(o => ({ date: o.date, value: parseFloat(o.value) })) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b2946653-aef5-4178-bada-1a45af0a4d51",
      "name": "格式化利率",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "interest_rate",
              "name": "fed_funds_rate",
              "type": "array",
              "value": "={{ $json.observations.slice(0, 6).map(o => ({ date: o.date, value: parseFloat(o.value) })) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "54665285-1ff7-47c8-9804-241ae5a7cc81",
      "name": "格式化就业",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        640
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "unemployment",
              "name": "unemployment_rate",
              "type": "array",
              "value": "={{ $json.observations.slice(0, 6).map(o => ({ date: o.date, value: parseFloat(o.value) })) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e9acb270-2801-4b29-a837-4f0d20daf3a5",
      "name": "合并所有数据",
      "type": "n8n-nodes-base.merge",
      "position": [
        1184,
        -32
      ],
      "parameters": {
        "mode": "combine",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "94f957c5-f758-430f-b126-64c2df6eab9c",
      "name": "准备 AI 输入",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "combined_data",
              "name": "analysis_input",
              "type": "string",
              "value": "=Gold Price Data:\nCurrent Price (USD per oz): {{ $('Format Gold Price').item.json.gold_price_usd }}\nTimestamp: {{ $('Format Gold Price').item.json.price_timestamp }}\n\nRecent Financial News (Top 10):\n{{ $('Format News Data').item.json.news_summary.map((n, i) => `${i+1}. ${n.title} (${n.source}) - ${n.publishedAt}\\n   ${n.description}`).join('\\n\\n') }}\n\nMacroeconomic Indicators:\n\nInflation (CPI - Last 6 months):\n{{ $('Format Inflation').item.json.inflation_trend.map(d => `${d.date}: ${d.value}`).join('\\n') }}\n\nFederal Funds Rate (Last 6 months):\n{{ $('Format Interest Rates').item.json.fed_funds_rate.map(d => `${d.date}: ${d.value}%`).join('\\n') }}\n\nUnemployment Rate (Last 6 months):\n{{ $('Format Employment').item.json.unemployment_rate.map(d => `${d.date}: ${d.value}%`).join('\\n') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "65481686-817a-4113-8f5c-907eafa330ee",
      "name": "AI 代理 - 黄金市场分析",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1504,
        -32
      ],
      "parameters": {
        "text": "=You are an expert financial analyst specializing in precious metals markets and macroeconomic trends. Analyze the provided data comprehensively.\n\n{{ $json.analysis_input }}\n\nBased on this data, provide a detailed gold market analysis with the following structure:\n\n**EXECUTIVE SUMMARY** (2-3 sentences)\nProvide a concise overview of the current gold market state and outlook.\n\n**KEY DRIVERS** (List 5-7 main factors)\nIdentify and explain the primary factors currently influencing gold prices:\n- Factor name: Brief explanation of its impact (bullish/bearish/neutral)\n\n**SHORT-TERM PREDICTION (1-7 days)**\n- Price Direction: [Up/Down/Sideways]\n- Expected Range: $X,XXX - $X,XXX per oz\n- Confidence Score: X/10\n- Reasoning: 2-3 sentence justification\n\n**MEDIUM-TERM PREDICTION (2-4 weeks)**\n- Price Direction: [Up/Down/Sideways]\n- Expected Range: $X,XXX - $X,XXX per oz\n- Confidence Score: X/10\n- Reasoning: 2-3 sentence justification\n\n**WATCHLIST** (Upcoming Events)\nList 5-8 specific upcoming events or data releases that could significantly impact gold prices:\n- Event name (approximate date): Potential impact explanation\n\nBe specific, data-driven, and consider correlations between indicators. Use current date context for timing predictions.",
        "options": {
          "systemMessage": "You are a senior financial analyst with 15+ years of experience in commodity markets, specializing in gold and precious metals. You provide clear, actionable insights based on technical analysis, fundamental data, and macroeconomic indicators."
        }
      },
      "typeVersion": 1.7
    },
    {
      "id": "03892373-2f22-4e07-ae13-c0e46a50355e",
      "name": "格式化最终报告",
      "type": "n8n-nodes-base.set",
      "position": [
        1808,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "analysis_report",
              "name": "final_report",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "generated_at",
              "name": "report_timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "gold_price",
              "name": "current_gold_price",
              "type": "number",
              "value": "={{ $('Format Gold Price').item.json.gold_price_usd }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "04ff9645-e526-46be-a245-f4a43726bac3",
      "name": "发布到 WordPress",
      "type": "n8n-nodes-base.wordpress",
      "position": [
        1984,
        -32
      ],
      "parameters": {
        "title": "=Gold Market Analysis - {{ $now.format('MMM dd, yyyy HH:mm') }}",
        "additionalFields": {
          "status": "publish",
          "authorId": 1
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8d5b7ebd-f6d4-4026-b6e9-20b5ebf91e29",
      "name": "发送 Slack 摘要",
      "type": "n8n-nodes-base.slack",
      "position": [
        2208,
        -128
      ],
      "webhookId": "907cc27a-30aa-433f-81aa-b7e77f1f339f",
      "parameters": {
        "text": "=:bar_chart: *Gold Market Analysis Report Published*\n\n*Current Price:* ${{ $('Format Final Report').item.json.current_gold_price.toFixed(2) }} per oz\n*Generated:* {{ $now.format('MMM dd, yyyy HH:mm') }}\n\n{{ $('AI Agent - Gold Market Analysis').item.json.output.split('**EXECUTIVE SUMMARY**')[1].split('**KEY DRIVERS**')[0].trim() }}\n\n:link: Read full analysis: {{ $('Publish to WordPress').item.json.link }}",
        "otherOptions": {}
      },
      "typeVersion": 2.2
    },
    {
      "id": "e0243aba-6269-4ecb-b95b-fe27426a860c",
      "name": "发送邮件摘要",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2208,
        64
      ],
      "webhookId": "d50551b7-50a2-4a79-9e20-8492bf029bd0",
      "parameters": {
        "options": {},
        "subject": "=Gold Market Forecast - {{ $now.format('MMM dd, yyyy') }}",
        "toEmail": "team@yourcompany.com",
        "fromEmail": "alerts@yourcompany.com"
      },
      "typeVersion": 2.1
    },
    {
      "id": "986680b8-bdfc-4c03-af8f-24fb2c27a5a6",
      "name": "OpenRouter 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1504,
        128
      ],
      "parameters": {
        "model": "perplexity/sonar-pro",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "fKnn6LL7cRFqNHDX",
          "name": "OpenRouter account2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "49db7300-6578-4548-b743-53634988975f",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        256
      ],
      "parameters": {
        "width": 912,
        "height": 208,
        "content": "## **简介**"
      },
      "typeVersion": 1
    },
    {
      "id": "9b10ec61-d430-4cf9-adf3-470b232f7bd7",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2096,
        256
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 464,
        "content": "## 先决条件"
      },
      "typeVersion": 1
    },
    {
      "id": "066a76a3-86b6-4a9d-8f2d-b448296e3883",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        480
      ],
      "parameters": {
        "color": 3,
        "width": 912,
        "height": 416,
        "content": "## **工作流模板**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "258c779e-78ef-493a-87ad-17e2938c37b8",
  "connections": {
    "Every 6 Hours": {
      "main": [
        [
          {
            "node": "Get Current Gold Price",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Financial News",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Inflation Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Interest Rate Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Employment Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Data": {
      "main": [
        [
          {
            "node": "Prepare AI Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format News Data": {
      "main": [
        [
          {
            "node": "Merge All Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Prepare AI Input": {
      "main": [
        [
          {
            "node": "AI Agent - Gold Market Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Gold Price": {
      "main": [
        [
          {
            "node": "Merge All Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Inflation Data": {
      "main": [
        [
          {
            "node": "Format Inflation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Final Report": {
      "main": [
        [
          {
            "node": "Publish to WordPress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Employment Data": {
      "main": [
        [
          {
            "node": "Format Employment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Financial News": {
      "main": [
        [
          {
            "node": "Format News Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish to WordPress": {
      "main": [
        [
          {
            "node": "Send Slack Summary",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Gold Market Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Current Gold Price": {
      "main": [
        [
          {
            "node": "Format Gold Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Interest Rate Data": {
      "main": [
        [
          {
            "node": "Format Interest Rates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Gold Market Analysis": {
      "main": [
        [
          {
            "node": "Format Final Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 加密货币交易, AI 摘要总结

需要付费吗?

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

工作流信息
难度等级
高级
节点数量22
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Cheng Siong Chin

Cheng Siong Chin

@cschin

Dr. Cheng Siong CHIN serves as a Professor in Intelligent Systems Modelling and Simulation in Newcastle University, Singapore. His academic credentials include an M.Sc. in Advanced Control and Systems Engineering from The University of Manchester and a Ph.D. in Robotics from Nanyang Technological University.

外部链接
在 n8n.io 查看

分享此工作流