策略源码
{"type":"n8n","content":"{\"workflowData\":{\"nodes\":[{\"parameters\":{\"notice\":\"\",\"rule\":{\"interval\":[{\"field\":\"hours\",\"hoursInterval\":1,\"triggerAtMinute\":0}]}},\"type\":\"n8n-nodes-base.scheduleTrigger\",\"typeVersion\":1.2,\"position\":[-288,160],\"id\":\"31647664-111d-4edc-88bc-2730d95b6396\",\"name\":\"定时触发器\"},{\"parameters\":{\"operation\":\"getRecords\",\"exchange\":0,\"symbol\":{\"__rl\":true,\"value\":\"={{ $vars.contract}}\",\"mode\":\"id\"},\"period\":900,\"limit\":200},\"type\":\"n8n-nodes-base.marketInfo\",\"typeVersion\":1,\"position\":[96,-112],\"id\":\"b45f3470-85e3-4b2a-912d-1644288abb14\",\"name\":\"15m\"},{\"parameters\":{\"operation\":\"getRecords\",\"exchange\":0,\"symbol\":{\"__rl\":true,\"value\":\"={{ $vars.contract}}\",\"mode\":\"id\"},\"period\":3600,\"limit\":200},\"type\":\"n8n-nodes-base.marketInfo\",\"typeVersion\":1,\"position\":[96,32],\"id\":\"033ff445-0ec6-4c7a-8bbc-9feb955c2bcd\",\"name\":\"1h\"},{\"parameters\":{\"operation\":\"getRecords\",\"exchange\":0,\"symbol\":{\"__rl\":true,\"value\":\"={{ $vars.contract}}\",\"mode\":\"id\"},\"period\":86400,\"limit\":200},\"type\":\"n8n-nodes-base.marketInfo\",\"typeVersion\":1,\"position\":[112,160],\"id\":\"f7fcabaf-b68a-4fd7-91ed-e25009fd2c74\",\"name\":\"1d\"},{\"parameters\":{\"mode\":\"append\",\"numberInputs\":3},\"type\":\"n8n-nodes-base.merge\",\"typeVersion\":3.2,\"position\":[560,16],\"id\":\"13fb30c8-d02a-4748-a0fb-d170517769bb\",\"name\":\"合并\"},{\"parameters\":{\"mode\":\"runOnceForAllItems\",\"language\":\"javaScript\",\"jsCode\":\"const result = [];\\nconst data = $input.first().json.result || [];\\n\\ndata.forEach(item => {\\n result.push({\\n timeframe: \\\"15m\\\",\\n candles: item\\n });\\n});\\n\\nreturn result;\",\"notice\":\"\"},\"type\":\"n8n-nodes-base.code\",\"typeVersion\":2,\"position\":[304,-112],\"id\":\"397583de-2700-4288-8325-810e492c6e92\",\"name\":\"代码1\"},{\"parameters\":{\"mode\":\"runOnceForAllItems\",\"language\":\"javaScript\",\"jsCode\":\"const result = [];\\nconst data = $input.first().json.result || [];\\n\\ndata.forEach(item => {\\n result.push({\\n timeframe: \\\"1h\\\",\\n candles: item\\n });\\n});\\n\\nreturn result;\",\"notice\":\"\"},\"type\":\"n8n-nodes-base.code\",\"typeVersion\":2,\"position\":[304,32],\"id\":\"f92c1d5c-d1f9-4bed-8962-1564d510b3a0\",\"name\":\"代码2\"},{\"parameters\":{\"mode\":\"runOnceForAllItems\",\"language\":\"javaScript\",\"jsCode\":\"const result = [];\\nconst data = $input.first().json.result || [];\\n\\ndata.forEach(item => {\\n result.push({\\n timeframe: \\\"1d\\\",\\n candles: item\\n });\\n});\\n\\nreturn result;\",\"notice\":\"\"},\"type\":\"n8n-nodes-base.code\",\"typeVersion\":2,\"position\":[304,160],\"id\":\"2d1542f7-beed-41cb-9a49-167eb764968f\",\"name\":\"代码3\"},{\"parameters\":{\"mode\":\"runOnceForAllItems\",\"language\":\"javaScript\",\"jsCode\":\"const allCandles = [];\\n\\nfor (const item of items){\\n allCandles.push(item.json)\\n}\\n\\nreturn [{\\n json:{\\n allCandles\\n }\\n}];\",\"notice\":\"\"},\"type\":\"n8n-nodes-base.code\",\"typeVersion\":2,\"position\":[720,32],\"id\":\"34620e34-6a0f-4686-8db7-e3f3afd0bd57\",\"name\":\"代码4\"},{\"parameters\":{\"text\":\"=你是一个专门分析黄金市场的高智能精准情感分析器。你将使用两部分方法分析提供文本的情感:\\n\\n短期情感:\\n\\n评估即时市场反应、近期新闻影响和技术波动性\\n确定情感类别:\\\"积极\\\"、\\\"中性\\\"或\\\"消极\\\"\\n计算-1(极度消极)到1(极度积极)之间的数值分数\\n提供简洁的理由说明短期情感(针对重大事件和宏观环境给出详细回应和适当标题)\\n\\n\\n长期情感:\\n\\n评估整体市场前景、基本面以及监管或宏观经济因素\\n确定情感类别:\\\"积极\\\"、\\\"中性\\\"或\\\"消极\\\"\\n计算-1(极度消极)到1(极度积极)之间的数值分数\\n提供详细的理由说明长期情感(针对重大事件和加密货币给出详细回应和适当标题)\\n\\n\\n\\n您的输出必须恰好是一个包含两个键的JSON对象:\\\"shortTermSentiment\\\"和\\\"longTermSentiment\\\"。每个键的值必须是包含三个键的对象:\\\"category\\\"、\\\"score\\\"和\\\"rationale\\\"。不要输出任何额外文本。\\n例如,您的输出应该如下所示:\\n{\\n\\\"shortTermSentiment\\\": {\\n\\\"category\\\": \\\"积极\\\",\\n\\\"score\\\": 0.7,\\n\\\"rationale\\\": \\\"....\\\"\\n},\\n\\\"longTermSentiment\\\": {\\n\\\"category\\\": \\\"中性\\\",\\n\\\"score\\\": 0.0,\\n\\\"rationale\\\": \\\"...\\\"\\n}\\n}\\n现在,分析以下文本并生成您的JSON输出:\\n{{ JSON.stringify($json.text) }}\",\"options\":{}},\"type\":\"@n8n/n8n-nodes-langchain.agent\",\"typeVersion\":1,\"position\":[496,320],\"id\":\"a842958d-205c-4eeb-b053-b789757a2d86\",\"name\":\"AI 智能体\"},{\"parameters\":{\"model\":{\"__rl\":true,\"value\":\"qwen3-max-preview\",\"mode\":\"list\",\"cachedResultName\":\"qwen3-max-preview\"}},\"type\":\"n8n-nodes-base.lmOpenAi\",\"typeVersion\":1,\"position\":[496,496],\"id\":\"b71df42d-e472-4dec-8650-41752e991bfc\",\"name\":\"OpenAI 模型\",\"credentials\":{\"openAiApi\":{\"id\":\"f3da26db-84a0-4a0b-8e63-6bcc89a187e7\",\"name\":\"ali\"}}},{\"parameters\":{\"mode\":\"append\",\"numberInputs\":2},\"type\":\"n8n-nodes-base.merge\",\"typeVersion\":3.2,\"position\":[976,176],\"id\":\"8289a02e-d353-4a98-b6cb-0dda08a63d97\",\"name\":\"合并1\"},{\"parameters\":{\"mode\":\"runOnceForAllItems\",\"language\":\"javaScript\",\"jsCode\":\"// Initialize containers for each set of data.\\nconst allCandles = [];\\nlet contentData = null;\\n// Loop over each item from the merge node.\\nfor (const item of items) {\\n // If the item has candlestick data, add it to the array.\\n if (item.json.allCandles !== undefined) {\\n // Assuming item.json.allCandles is an array.\\n allCandles.push(...item.json.allCandles);\\n }\\n // If the item has embedded content (in message.content), store it.\\n if (item.json.output !== undefined) {\\n contentData = item.json.output;\\n }\\n}\\n// Return a single item with both candlestick data and content.\\nreturn [{\\n json: {\\n allCandles,\\n content: contentData\\n }\\n}];\",\"notice\":\"\"},\"type\":\"n8n-nodes-base.code\",\"typeVersion\":2,\"position\":[1152,176],\"id\":\"47d171f1-e587-4164-afef-ce9a51b642c9\",\"name\":\"代码5\"},{\"parameters\":{\"model\":{\"__rl\":true,\"value\":\"qwen3-max-preview\",\"mode\":\"list\",\"cachedResultName\":\"qwen3-max-preview\"}},\"type\":\"n8n-nodes-base.lmOpenAi\",\"typeVersion\":1,\"position\":[1360,352],\"id\":\"bce990b6-4785-4eeb-ab17-85ee09c0b4a6\",\"name\":\"OpenAI 模型1\",\"credentials\":{\"openAiApi\":{\"id\":\"f3da26db-84a0-4a0b-8e63-6bcc89a187e7\",\"name\":\"ali\"}}},{\"parameters\":{\"text\":\"=## 交易分析指令\\n**数据结构:**\\n{{ $vars.contract}}的综合市场数据:\\n- 技术数据: {{ JSON.stringify($json[\\\"allCandles\\\"]) }}\\n- 情感分析: {{ JSON.stringify($json[\\\"content\\\"]) }}\\nK线格式: 时间框架 (\\\"15m\\\", \\\"1h\\\", \\\"1d\\\") + K线数组\\n情感: 黄金品种新闻的短期/长期分析\\n\\n**分析框架:**\\n**短期 (15m + 1h 数据):**\\n- 识别即时支撑/阻力位\\n- 价格行动信号 + 滞后指标\\n- 专注入场/出场时机\\n\\n**长期 (1d + 1h 数据):**\\n- 主要趋势方向\\n- 结构性价位\\n- 更广泛的市场背景\\n\\n**输出要求:**\\n**格式:** 纯文本\\n**日期:** {{$vars.contract}}品种分析 {{ $now }} (格式: mm/dd/yyyy at xx:xxpm)\\n\\n\\n**参考建议:**\\n**短期:**\\n- 仓位: [做多/做空]\\n- 入场: $X\\n- 止损: $X\\n- 目标: $X\\n- 理由: [2-3句简洁句子涵盖价格行动、确认、情感]\\n\\n**长期:**\\n- 仓位: [做多/做空]\\n- 入场: $X\\n- 止损: $X\\n- 目标: $X\\n- 理由: [2-3句简洁句子涵盖价格行动、确认、情感]\\n\\n\\n**提醒:**\\n- 本建议仅作学习使用,不构成任何投资建议!\\n\\n**关键指导原则:**\\n- 每个理由保持在50字以内\\n- 专注于可操作的洞察\\n- 消除冗余解释\\n- 优先考虑高信度信号\\n- 使用直接、简洁的语言\",\"options\":{}},\"type\":\"@n8n/n8n-nodes-langchain.agent\",\"typeVersion\":1,\"position\":[1360,176],\"id\":\"d363b829-437e-441a-9387-4db984632427\",\"name\":\"AI 智能体2\"},{\"parameters\":{\"endpointUrl\":\"https://mcp.alphavantage.co/mcp?apikey='PL7O6NWMVMLEQD0Y'\",\"authentication\":\"none\",\"tool\":\"NEWS_SENTIMENT\",\"tickers\":\"\",\"topics\":\"GOLD\"},\"type\":\"@n8n/n8n-nodes-langchain.mcpClient\",\"typeVersion\":1.1,\"position\":[128,336],\"id\":\"4457de3c-8133-4b07-a783-2c18f745358d\",\"name\":\"MCP 客户端\"},{\"parameters\":{\"operation\":\"markdown\",\"isAtAll\":true,\"title\":\"投资建议:\",\"markdownText\":\"={{ $json.output }}\"},\"type\":\"n8n-nodes-base.dingTalkRobot\",\"typeVersion\":1,\"position\":[1776,176],\"id\":\"d375efd1-af05-4db2-be6a-a0fad50db834\",\"name\":\"钉钉机器人\",\"credentials\":{\"dingTalkCustomRobotApi\":{\"id\":\"97ceefee-6d07-41e2-8804-d27f9984e48f\",\"name\":\"钉钉自定义机器人 account\"}}}],\"pinData\":{},\"connections\":{\"定时触发器\":{\"main\":[[{\"node\":\"15m\",\"type\":\"main\",\"index\":0},{\"node\":\"1h\",\"type\":\"main\",\"index\":0},{\"node\":\"1d\",\"type\":\"main\",\"index\":0},{\"node\":\"MCP 客户端\",\"type\":\"main\",\"index\":0}]]},\"15m\":{\"main\":[[{\"node\":\"代码1\",\"type\":\"main\",\"index\":0}]]},\"1h\":{\"main\":[[{\"node\":\"代码2\",\"type\":\"main\",\"index\":0}]]},\"1d\":{\"main\":[[{\"node\":\"代码3\",\"type\":\"main\",\"index\":0}]]},\"合并\":{\"main\":[[{\"node\":\"代码4\",\"type\":\"main\",\"index\":0}]]},\"代码1\":{\"main\":[[{\"node\":\"合并\",\"type\":\"main\",\"index\":0}]]},\"代码2\":{\"main\":[[{\"node\":\"合并\",\"type\":\"main\",\"index\":1}]]},\"代码3\":{\"main\":[[{\"node\":\"合并\",\"type\":\"main\",\"index\":2}]]},\"代码4\":{\"main\":[[{\"node\":\"合并1\",\"type\":\"main\",\"index\":0}]]},\"AI 智能体\":{\"main\":[[{\"node\":\"合并1\",\"type\":\"main\",\"index\":1}]]},\"OpenAI 模型\":{\"ai_languageModel\":[[{\"node\":\"AI 智能体\",\"type\":\"ai_languageModel\",\"index\":0}]]},\"合并1\":{\"main\":[[{\"node\":\"代码5\",\"type\":\"main\",\"index\":0}]]},\"代码5\":{\"main\":[[{\"node\":\"AI 智能体2\",\"type\":\"main\",\"index\":0}]]},\"OpenAI 模型1\":{\"ai_languageModel\":[[{\"node\":\"AI 智能体2\",\"type\":\"ai_languageModel\",\"index\":0}]]},\"AI 智能体2\":{\"main\":[[{\"node\":\"钉钉机器人\",\"type\":\"main\",\"index\":0}]]},\"MCP 客户端\":{\"main\":[[{\"node\":\"AI 智能体\",\"type\":\"main\",\"index\":0}]]}},\"active\":false,\"settings\":{\"timezone\":\"Asia/Shanghai\",\"executionOrder\":\"v1\"},\"tags\":[],\"meta\":{\"templateCredsSetupCompleted\":true},\"credentials\":{},\"id\":\"2a4e716f-934c-4e03-ae68-70c42976bdcd\",\"plugins\":{},\"mcpClients\":{\"NEWS_SENTIMENT\":{\"name\":\"NEWS_SENTIMENT\",\"description\":\"Returns live and historical market news & sentiment data from premier news outlets worldwide.\",\"properties\":[{\"displayName\":\"tickers\",\"name\":\"tickers\",\"type\":\"string\",\"description\":\"Stock/crypto/forex symbols to filter articles. Example: \\\"IBM\\\" or \\\"COIN,CRYPTO:BTC,FOREX:USD\\\".\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}},\"placeholder\":\"Enter tickers\"},{\"displayName\":\"topics\",\"name\":\"topics\",\"type\":\"string\",\"description\":\"News topics to filter by. Example: \\\"technology\\\" or \\\"technology,ipo\\\".\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}},\"placeholder\":\"Enter topics\"},{\"displayName\":\"time_from\",\"name\":\"time_from\",\"type\":\"string\",\"description\":\"Start time range in YYYYMMDDTHHMM format. Example: \\\"20220410T0130\\\".\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}},\"placeholder\":\"Enter time_from\"},{\"displayName\":\"time_to\",\"name\":\"time_to\",\"type\":\"string\",\"description\":\"End time range in YYYYMMDDTHHMM format. Defaults to current time if time_from specified.\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}},\"placeholder\":\"Enter time_to\"},{\"displayName\":\"sort\",\"name\":\"sort\",\"type\":\"string\",\"description\":\"Sort order - \\\"LATEST\\\" (default), \\\"EARLIEST\\\", or \\\"RELEVANCE\\\".\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}},\"placeholder\":\"Enter sort\"},{\"displayName\":\"limit\",\"name\":\"limit\",\"type\":\"number\",\"description\":\"Number of results to return. Default 50, max 1000.\",\"displayOptions\":{\"show\":{\"tool\":[\"NEWS_SENTIMENT\"]}}}]}}},\"startNodes\":[],\"triggerToStartFrom\":{\"name\":\"定时触发器\"}}"}