day9_加密货币更新获取
高级
这是一个Finance领域的自动化工作流,包含 26 个节点。主要使用 If、Set、Switch、Webhook、Function 等节点。 使用CoinGecko分析加密货币市场:波动性指标与投资信号
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
使用的节点 (26 个)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Uw1r9yGqgPRykfUs",
"meta": {
"instanceId": "3fed23de697c60307f3b4f5caeafbeffabaf7bbd62c1b20ae70d5faf5a9806b4"
},
"name": "day9_加密货币更新获取",
"tags": [
{
"id": "4zX1mtizlZxTekJP",
"name": "training-tasks-n8n",
"createdAt": "2025-04-29T10:41:14.716Z",
"updatedAt": "2025-04-29T10:41:14.716Z"
},
{
"id": "F1KjxL3SjfvVqZqo",
"name": "training-n8n",
"createdAt": "2025-04-29T10:40:13.332Z",
"updatedAt": "2025-04-29T10:40:13.332Z"
}
],
"nodes": [
{
"id": "745e4849-8c61-4b29-9980-24de93821adb",
"name": "获取加密货币数据",
"type": "n8n-nodes-base.httpRequest",
"position": [
220,
385
],
"parameters": {
"url": "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=10&page=1&sparkline=false&price_change_percentage=24h,7d,30d",
"options": {}
},
"typeVersion": 3
},
{
"id": "f4e6c40d-ab60-473b-9961-961eb1fa3505",
"name": "计算市场指标",
"type": "n8n-nodes-base.function",
"position": [
660,
385
],
"parameters": {
"functionCode": "// Calculate a volatility score based on price changes\nconst item = $input.item.json;\n\n// Extract price change percentages\nconst priceChange24h = item.price_change_percentage_24h || 0;\nconst priceChange7d = item.price_change_percentage_7d_in_currency || 0;\nconst priceChange30d = item.price_change_percentage_30d_in_currency || 0;\n\n// Calculate absolute values to measure volatility regardless of direction\nconst absChange24h = Math.abs(priceChange24h);\nconst absChange7d = Math.abs(priceChange7d);\nconst absChange30d = Math.abs(priceChange30d);\n\n// Calculate a weighted volatility score (more weight to recent changes)\nconst volatilityScore = (absChange24h * 0.5) + (absChange7d * 0.3) + (absChange30d * 0.2);\n\n// Calculate market cap to volume ratio (higher means less liquid/more volatile)\nconst marketCapToVolumeRatio = item.market_cap / (item.total_volume || 1);\n\n// Calculate price to ATH ratio (close to 1 means near all-time high)\nconst priceToAthRatio = item.current_price / (item.ath || item.current_price);\n\n// Calculate a composite market score\nconst marketScore = (\n (volatilityScore * 0.4) + \n (Math.min(marketCapToVolumeRatio, 10) * 0.3) + \n ((1 - priceToAthRatio) * 30) // Invert so coins further from ATH get higher scores\n);\n\n// Add calculated metrics to the item\nitem.volatilityScore = parseFloat(volatilityScore.toFixed(2));\nitem.marketCapToVolumeRatio = parseFloat(marketCapToVolumeRatio.toFixed(2));\nitem.priceToAthRatio = parseFloat(priceToAthRatio.toFixed(4));\nitem.marketScore = parseFloat(marketScore.toFixed(2));\n\n// Add a timestamp for the analysis\nitem.analyzedAt = new Date().toISOString();\n\nreturn {json: item};"
},
"typeVersion": 1
},
{
"id": "5d760f94-ca2f-44cc-aef0-83eb2cf438ee",
"name": "如果 24 小时价格上涨 >5%",
"type": "n8n-nodes-base.if",
"position": [
880,
60
],
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.price_change_percentage_24h }}",
"value2": 5,
"operation": "larger"
}
]
}
},
"typeVersion": 1
},
{
"id": "19ca8650-b642-4910-ac7c-50b1ceb41ffc",
"name": "如果 24 小时价格下跌 >5%",
"type": "n8n-nodes-base.if",
"position": [
1100,
260
],
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.price_change_percentage_24h }}",
"value2": -5
}
]
}
},
"typeVersion": 1
},
{
"id": "c5d69bbb-df7e-4089-b0c8-50653cd936f0",
"name": "如果高波动性",
"type": "n8n-nodes-base.if",
"position": [
1320,
560
],
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.volatilityScore }}",
"value2": 10,
"operation": "larger"
}
]
}
},
"typeVersion": 1
},
{
"id": "77902b9a-2cf8-4b6f-95e9-590b51278c59",
"name": "设置上涨趋势数据",
"type": "n8n-nodes-base.set",
"position": [
1540,
60
],
"parameters": {
"values": {
"string": [
{
"name": "priceAction",
"value": "Strong upward momentum in the past 24 hours"
},
{
"name": "signal",
"value": "BUY"
},
{
"name": "recommendation",
"value": "Consider buying on continued strength above resistance levels. Set stop loss at recent support."
},
{
"name": "investmentStrategy",
"value": "Momentum strategy with trailing stop loss. Consider dollar-cost averaging to manage volatility risk."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "4706270b-3bdc-4806-a302-830a88c9a982",
"name": "设置下跌趋势数据",
"type": "n8n-nodes-base.set",
"position": [
1540,
260
],
"parameters": {
"values": {
"string": [
{
"name": "priceAction",
"value": "Rapid price decline in the past 24 hours"
},
{
"name": "signal",
"value": "SELL"
},
{
"name": "recommendation",
"value": "Consider reducing exposure or implementing hedging strategies. Watch for oversold conditions."
},
{
"name": "investmentStrategy",
"value": "Capital preservation is priority. Consider re-evaluation after price stabilization."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "608729c4-23a5-4c5b-b9a0-d77f12166aa3",
"name": "设置波动性数据",
"type": "n8n-nodes-base.set",
"position": [
1540,
460
],
"parameters": {
"values": {
"string": [
{
"name": "priceAction",
"value": "High volatility with significant price swings"
},
{
"name": "signal",
"value": "HOLD"
},
{
"name": "recommendation",
"value": "High volatility indicates market uncertainty. Consider waiting for clearer signals before making major positions."
},
{
"name": "investmentStrategy",
"value": "Range-trading strategy may be effective. Set both upper and lower limit orders."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "f8134b51-4b41-4684-97a9-008e5f0260df",
"name": "设置稳定数据",
"type": "n8n-nodes-base.set",
"position": [
1540,
660
],
"parameters": {
"values": {
"string": [
{
"name": "priceAction",
"value": "Relatively stable price action with minimal volatility"
},
{
"name": "signal",
"value": "NEUTRAL"
},
{
"name": "recommendation",
"value": "Market is consolidating. Watch for breakout signals in either direction."
},
{
"name": "investmentStrategy",
"value": "Consider accumulating small positions or implementing a neutral options strategy."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "5f43178c-7bb5-405d-a988-b3b0ae0a0405",
"name": "合并结果",
"type": "n8n-nodes-base.noOp",
"position": [
1760,
360
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e422a9e1-9016-4db9-912b-58be44604eb2",
"name": "设置高风险评级",
"type": "n8n-nodes-base.set",
"position": [
2200,
-40
],
"parameters": {
"values": {
"string": [
{
"name": "riskRating",
"value": "High Risk"
},
{
"name": "investmentStrategy",
"value": "={{ $json.investmentStrategy }} Due to high risk profile, use strict position sizing (max 2-5% of portfolio)."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "383a55c7-f42f-4a32-b6ba-742049406f67",
"name": "设置中等风险评级",
"type": "n8n-nodes-base.set",
"position": [
2200,
160
],
"parameters": {
"values": {
"string": [
{
"name": "riskRating",
"value": "Medium Risk"
},
{
"name": "investmentStrategy",
"value": "={{ $json.investmentStrategy }} Moderate risk profile suggests balanced position sizing (5-10% of portfolio)."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "2f50e6cd-dd62-4fb2-8ee2-28096c758e23",
"name": "设置低风险评级",
"type": "n8n-nodes-base.set",
"position": [
2200,
460
],
"parameters": {
"values": {
"string": [
{
"name": "riskRating",
"value": "Low Risk"
},
{
"name": "investmentStrategy",
"value": "={{ $json.investmentStrategy }} Lower risk profile allows for larger position sizing (10-15% of portfolio)."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "5a820de9-11f8-4aa7-8811-afb6153a7b54",
"name": "设置默认风险评级",
"type": "n8n-nodes-base.set",
"position": [
2200,
660
],
"parameters": {
"values": {
"string": [
{
"name": "riskRating",
"value": "Unknown Risk"
},
{
"name": "investmentStrategy",
"value": "={{ $json.investmentStrategy }} Risk profile is unclear - use conservative position sizing until more data is available."
}
]
},
"options": {
"dotNotation": true
}
},
"typeVersion": 2
},
{
"id": "9b39eb90-f0c8-44df-9721-ef1d60a8a0fc",
"name": "最终合并",
"type": "n8n-nodes-base.noOp",
"position": [
2420,
360
],
"parameters": {},
"typeVersion": 1
},
{
"id": "f84bd02a-92d1-49c7-9ba3-36e860a31636",
"name": "格式化最终分析",
"type": "n8n-nodes-base.function",
"position": [
2640,
635
],
"parameters": {
"functionCode": "// Create a formatted summary for each coin\nconst item = $input.item.json;\n\n// Format dollar amounts nicely\nconst formatCurrency = (value) => {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2\n }).format(value);\n};\n\n// Format percentages nicely\nconst formatPercent = (value) => {\n return `${value > 0 ? '+' : ''}${value.toFixed(2)}%`;\n};\n\n// Create a detailed analysis report\nconst analysisReport = {\n coin: item.name,\n symbol: item.symbol.toUpperCase(),\n currentPrice: formatCurrency(item.current_price),\n marketCap: formatCurrency(item.market_cap),\n volume24h: formatCurrency(item.total_volume),\n priceChanges: {\n \"24h\": formatPercent(item.price_change_percentage_24h),\n \"7d\": formatPercent(item.price_change_percentage_7d_in_currency),\n \"30d\": formatPercent(item.price_change_percentage_30d_in_currency)\n },\n marketMetrics: {\n volatilityScore: item.volatilityScore,\n marketCapToVolumeRatio: item.marketCapToVolumeRatio,\n priceToAthRatio: item.priceToAthRatio,\n marketScore: item.marketScore\n },\n analysis: {\n priceAction: item.priceAction,\n signal: item.signal,\n riskRating: item.riskRating,\n recommendation: item.recommendation,\n investmentStrategy: item.investmentStrategy\n },\n timestamp: item.analyzedAt\n};\n\n// Generate a natural language summary\nconst summary = `\n## ${item.name} (${item.symbol.toUpperCase()}) Analysis\n\nCurrent Price: ${formatCurrency(item.current_price)} (${formatPercent(item.price_change_percentage_24h)} 24h)\\n\\n\n\nMarket Signal: **${item.signal}** - *${item.priceAction}*\nRisk Rating: **${item.riskRating}**\\n\\n\n\n**Recommendation:**\n${item.recommendation}\n\n**Investment Strategy:**\n${item.investmentStrategy}\n\n---\n*Analysis based on volatility score of ${item.volatilityScore} and market score of ${item.marketScore}*\n`;\n\n// Return both structured data and a human-readable summary\nreturn {\n json: {\n ...item,\n analysisReport,\n summary\n }\n};"
},
"typeVersion": 1
},
{
"id": "911280f8-82cb-42ee-bd8a-6de15c58f188",
"name": "收集所有分析",
"type": "n8n-nodes-base.noOp",
"position": [
660,
-140
],
"parameters": {},
"typeVersion": 1
},
{
"id": "a4de8078-7f49-4b22-a11a-a2efabfa16b1",
"name": "生成投资组合摘要",
"type": "n8n-nodes-base.function",
"position": [
880,
-140
],
"parameters": {
"functionCode": "// Create a portfolio summary based on all coin analyses\nconst allCoins = $input.all();\n\n// Extract all analyzed coins\nconst analyzedCoins = allCoins.map(coin => coin.json);\n\n// Count signals by type\nconst signalCounts = {\n BUY: 0,\n SELL: 0,\n HOLD: 0,\n NEUTRAL: 0\n};\n\n// Count risk ratings\nconst riskCounts = {\n \"High Risk\": 0,\n \"Medium Risk\": 0,\n \"Low Risk\": 0,\n \"Unknown Risk\": 0\n};\n\n// Calculate portfolio metrics\nanalyzedCoins.forEach(coin => {\n // Count signals\n if (coin.signal) {\n signalCounts[coin.signal] = (signalCounts[coin.signal] || 0) + 1;\n }\n\n // Count risk ratings\n if (coin.riskRating) {\n riskCounts[coin.riskRating] = (riskCounts[coin.riskRating] || 0) + 1;\n }\n});\n\n// Sort coins by market score (highest first)\nconst sortedCoins = [...analyzedCoins].sort((a, b) => b.marketScore - a.marketScore);\n\n// Get top recommendation\nconst topOpportunity = sortedCoins[0];\n\n// Generate portfolio summary markdown\nconst portfolioSummary = `# Cryptocurrency Market Analysis\n\n## Market Overview\n**Analyzed Coins:** ${analyzedCoins.length} \n**Buy Signals:** ${signalCounts.BUY} \n**Sell Signals:** ${signalCounts.SELL} \n**Hold Signals:** ${signalCounts.HOLD} \n**Neutral Signals:** ${signalCounts.NEUTRAL} \n\n## Risk Distribution\n**High Risk Assets:** ${riskCounts[\"High Risk\"]} \n**Medium Risk Assets:** ${riskCounts[\"Medium Risk\"]} \n**Low Risk Assets:** ${riskCounts[\"Low Risk\"]} \n\n## Top Opportunity \n${topOpportunity ? `**${topOpportunity.name} (${topOpportunity.symbol.toUpperCase()})** \n${topOpportunity.summary}` : \"No opportunities found\"}\n\n## Detailed Coin Analyses \n${sortedCoins.map(coin => `**${coin.name} (${coin.symbol})** \n${coin.summary}`).join('\\n\\n')}\n\n*Analysis generated on ${new Date().toLocaleString()}*`;\n\nreturn [\n {\n json: {\n portfolioSummary,\n individualAnalyses: analyzedCoins.map(coin => coin.analysisReport),\n marketSignals: signalCounts,\n riskDistribution: riskCounts,\n timestamp: new Date().toISOString()\n }\n }\n];\n"
},
"typeVersion": 1
},
{
"id": "3277b96e-ab2c-4561-a29c-958998f45686",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
440,
385
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "8256a60a-ddb8-4d72-b443-8fba819815bb",
"name": "按市场评分切换",
"type": "n8n-nodes-base.switch",
"position": [
1980,
339
],
"parameters": {
"rules": {
"rules": [
{
"value2": 20,
"operation": "larger"
},
{
"value2": 10,
"operation": "larger"
},
{
"operation": "larger"
}
]
},
"value1": "={{ $json.marketScore }}",
"fallbackOutput": 3
},
"typeVersion": 1
},
{
"id": "b8cb4f7d-3818-48df-89ea-9db22797375a",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
1100,
-140
],
"parameters": {
"options": {},
"fieldToSplitOut": "individualAnalyses"
},
"typeVersion": 1
},
{
"id": "936e9ada-4b6b-4cab-90e1-0bea30eaaa0c",
"name": "响应 Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
1320,
-140
],
"parameters": {
"options": {},
"respondWith": "allIncomingItems"
},
"typeVersion": 1.1
},
{
"id": "7791cebf-4733-4cf6-8341-96771733b507",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
0,
380
],
"webhookId": "31941fd9-9fd5-4fab-a1b9-9c347e26f5c9",
"parameters": {
"path": "31941fd9-9fd5-4fab-a1b9-9c347e26f5c9",
"options": {},
"responseMode": "responseNode"
},
"typeVersion": 2
},
{
"id": "d25b2427-9fc7-4042-92f2-673de5019206",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
2120,
-140
],
"parameters": {
"width": 260,
"height": 960,
"content": "## 分类并设置币种评级"
},
"typeVersion": 1
},
{
"id": "ac3a6503-5ce7-406d-9efb-122928239337",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
40
],
"parameters": {},
"typeVersion": 1
},
{
"id": "c4e4e17d-bf13-44a2-9a9e-1d22104f1062",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
-20
],
"parameters": {
"content": "## 此工作流旨在"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "be12f8a1-3c44-4a1c-8f74-d1df269de92c",
"connections": {
"Webhook": {
"main": [
[
{
"node": "Fetch Crypto Data",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Final Merge": {
"main": [
[
{
"node": "Format Final Analysis",
"type": "main",
"index": 0
}
]
]
},
"Merge Results": {
"main": [
[
{
"node": "Switch by Market Score",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Collect All Analyses",
"type": "main",
"index": 0
}
],
[
{
"node": "Calculate Market Metrics",
"type": "main",
"index": 0
}
]
]
},
"Set Stable Data": {
"main": [
[
{
"node": "Merge Results",
"type": "main",
"index": 0
}
]
]
},
"Set Uptrend Data": {
"main": [
[
{
"node": "Merge Results",
"type": "main",
"index": 0
}
]
]
},
"Fetch Crypto Data": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"IF High Volatility": {
"main": [
[
{
"node": "Set Volatility Data",
"type": "main",
"index": 0
}
],
[
{
"node": "Set Stable Data",
"type": "main",
"index": 0
}
]
]
},
"Set Downtrend Data": {
"main": [
[
{
"node": "Merge Results",
"type": "main",
"index": 0
}
]
]
},
"IF 24h Price Up >5%": {
"main": [
[
{
"node": "Set Uptrend Data",
"type": "main",
"index": 0
}
],
[
{
"node": "IF 24h Price Down >5%",
"type": "main",
"index": 0
}
]
]
},
"Set Low Risk Rating": {
"main": [
[
{
"node": "Final Merge",
"type": "main",
"index": 0
}
]
]
},
"Set Volatility Data": {
"main": [
[
{
"node": "Merge Results",
"type": "main",
"index": 0
}
]
]
},
"Collect All Analyses": {
"main": [
[
{
"node": "Generate Portfolio Summary",
"type": "main",
"index": 0
}
]
]
},
"Set High Risk Rating": {
"main": [
[
{
"node": "Final Merge",
"type": "main",
"index": 0
}
]
]
},
"Format Final Analysis": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"IF 24h Price Down >5%": {
"main": [
[
{
"node": "Set Downtrend Data",
"type": "main",
"index": 0
}
],
[
{
"node": "IF High Volatility",
"type": "main",
"index": 0
}
]
]
},
"Set Medium Risk Rating": {
"main": [
[
{
"node": "Final Merge",
"type": "main",
"index": 0
}
]
]
},
"Switch by Market Score": {
"main": [
[
{
"node": "Set High Risk Rating",
"type": "main",
"index": 0
}
],
[
{
"node": "Set Medium Risk Rating",
"type": "main",
"index": 0
}
],
[
{
"node": "Set Low Risk Rating",
"type": "main",
"index": 0
}
],
[
{
"node": "Set Default Risk Rating",
"type": "main",
"index": 0
}
]
]
},
"Set Default Risk Rating": {
"main": [
[
{
"node": "Final Merge",
"type": "main",
"index": 0
}
]
]
},
"Calculate Market Metrics": {
"main": [
[
{
"node": "IF 24h Price Up >5%",
"type": "main",
"index": 0
},
{
"node": "IF 24h Price Down >5%",
"type": "main",
"index": 0
},
{
"node": "IF High Volatility",
"type": "main",
"index": 0
}
]
]
},
"Generate Portfolio Summary": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Finance等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
灵活新闻聚合器 - 多源集成、AI分析和可设置频道
多源新闻策展系统,集成Mistral AI分析、摘要和自定义频道
If
Set
Xml
+32
120 节点Hybroht
Content Creation
[模板] AI宠物店 v8
🐶 AI宠物店助手 - 集成GPT-4o、Google日历和WhatsApp/Instagram/Facebook
If
N8n
Set
+38
244 节点Amanda Benks
Sales
AI 代理餐厅 [模板]
🤖 WhatsApp、Instagram 和 Messenger 的 AI 餐厅助手
If
N8n
Set
+37
239 节点Amanda Benks
Other
GitHub 同步仪表板 - V2
具有提交历史和回滚功能的 GitHub 工作流版本控制仪表板
If
N8n
Set
+20
94 节点Eduard
DevOps
Bitrix24开放频道RAG聊天机器人应用工作流示例
Bitrix24 AI驱动的开放频道RAG聊天机器人
If
Set
Merge
+18
34 节点Ferenc Erb
Other
实时Notion Todoist双向同步模板
使用Redis的Notion Todoist实时双向同步
If
Set
Code
+26
246 节点Mario
Sales
工作流信息
难度等级
高级
节点数量26
分类1
节点类型11
作者
ist00dent
@ist00dentI’m a dedicated automation engineer passionate about no-code and low-code solutions. I design and implement robust n8n workflows—integrating APIs, databases, and messaging—to eliminate manual tasks and accelerate delivery. Leveraging Python and C#, I build scalable, adaptable automations that empower teams to focus on high-value work.
外部链接
在 n8n.io 上查看 →
分享此工作流