N
n8n Store
Workflow Market
Track Multi-Broker Investment Portfolio with Google Sheets and Telegram Alerts

Track Multi-Broker Investment Portfolio with Google Sheets and Telegram Alerts

by akash250 views

Description

Categories

⚙️ Automation

Nodes Used

n8n-nodes-base.ifn8n-nodes-base.setn8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.switchn8n-nodes-base.telegramn8n-nodes-base.telegramn8n-nodes-base.aggregaten8n-nodes-base.stickyNoten8n-nodes-base.stickyNote
PriceGratis
Views0
Last Updated11/28/2025
workflow.json
{
  "meta": {
    "instanceId": "40e2ddc17723de14c7d0537f9006dd246a3f4df33df6ca7f746ccb612d5f27b9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "6cc81650-0473-4b2a-bd23-abae6e3c81a7",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -840,
        60
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "376b39de-acc5-49d3-b618-4419a2aa8a25",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.body.message.chat.id }}",
              "rightValue": "={{ $json.myId }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "a038f750-3464-4143-b8a7-e4d244c556c5",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -260,
        260
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 580349873,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI/edit#gid=580349873",
          "cachedResultName": "Dashboard"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI/edit?usp=drivesdk",
          "cachedResultName": "Track Finances"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9NL9w5d9bKz7xt16",
          "name": "Akash Google Sheet Account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7f066010-4fd1-4ccf-a407-05694051e4f7",
      "name": "Get row(s) in sheet2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -260,
        -40
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $('Telegram Trigger').item.json.body.message.text.replaceAll(\"/\", \"\") }}",
              "lookupColumn": "Platform"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 580349873,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI/edit#gid=580349873",
          "cachedResultName": "Dashboard"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI/edit?usp=drivesdk",
          "cachedResultName": "Track Finances"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9NL9w5d9bKz7xt16",
          "name": "Akash Google Sheet Account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "1874c3d2-02e7-4faf-b592-af7c1b392d78",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -580,
        40
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Specific Platform",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6447e8ed-a64e-4d77-8b81-9716d971439d",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.body.message.text }}",
                    "rightValue": "/total"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Total",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3aef81cf-04a3-4eb3-9c12-accc41dd19f3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.body.message.text }}",
                    "rightValue": "/total"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "e019c20d-4f7f-447a-9b24-0b3c7d1840d5",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -40,
        260
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "f8e95cdd-7020-4d9e-970f-ec9013be3268",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        220,
        260
      ],
      "parameters": {
        "jsCode": "const data = items[0].json.data;\n\nlet message = '📊 *Daily P&L Report*\\n\\n';\n\nconst formatCurrency = (value) =>\n  `₹${value.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`;\n\nconst formatPercent = (value) => `${(value * 100).toFixed(2)}%`;\n\nfor (const row of data) {\n  if (row.Platform === 'Total') continue; // Skip Total for now\n\n  message += `*🔹 ${row.Platform}*\\n`;\n  message += `- Invested: ${formatCurrency(row[\"Invested Amount\"])}\\n`;\n  message += `- P&L: ${formatCurrency(row[\"PNL\"])} (${formatPercent(row[\"PNL %\"])})\\n`;\n  message += `- Change: ${formatCurrency(row[\"PNL Change\"])} (*${formatPercent(row[\"PNL Change %\"]) }*)\\n`;\n  message += `- Current Value: ${formatCurrency(row[\"Invested Amount\"] + row[\"PNL\"])}\\n\\n`;\n}\n\n// Add Total Portfolio section\nconst total = data.find((d) => d.Platform === 'Total');\nif (total) {\n  message += `*📈 Total Portfolio*\\n`;\n  message += `- Total Invested: ${formatCurrency(total[\"Invested Amount\"])}\\n`;\n  message += `- Total P&L: ${formatCurrency(total[\"PNL\"])} (${formatPercent(total[\"PNL %\"])})\\n`;\n  message += `- Today's Change: ${formatCurrency(total[\"PNL Change\"])} (*${formatPercent(total[\"PNL Change %\"]) }*)\\n\\n`;\n  message += `💰 *Overall Value*: ${formatCurrency(total[\"Invested Amount\"] + total[\"PNL\"])}\\n`;\n  message += `📈 *Overall Return*: *${formatPercent(total[\"PNL %\"])}*\\n`;\n  message += `💸 *Overall P&L*: ${formatCurrency(total[\"PNL\"])}\\n`;\n}\n\nreturn [{\n  json: {\n    chat_id:$('Edit Fields').first().json.myId ,\n    text: message,\n    parse_mode: \"Markdown\"\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "c37ddc50-eec3-4a8e-a0b1-b5216f0dfe99",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        -40,
        -40
      ],
      "parameters": {
        "jsCode": "const row = items[0].json;\n\nconst formatCurrency = (value) =>\n  `₹${value.toLocaleString('en-IN', { minimumFractionDigits: 2 }) }`;\n\nconst formatPercent = (value) =>\n  `${(value * 100).toFixed(2)}%`;\n\nconst invested = row[\"Invested Amount\"];\nconst pnl = row[\"PNL\"];\nconst change = row[\"PNL Change\"];\nconst pnlPercent = row[\"PNL %\"];\nconst changePercent = row[\"PNL Change %\"];\nconst currentValue = invested + pnl;\nconst platform = row[\"Platform\"].charAt(0).toUpperCase() + row[\"Platform\"].slice(1).toLowerCase();\n\nconst message = \n`📊 *Daily P&L Report*\\n\\n` +\n`*🔹 ${platform}*\\n` +\n`- Invested: ${formatCurrency(invested)}\\n` +\n`- P&L: ${formatCurrency(pnl)} (${formatPercent(pnlPercent)})\\n` +\n`- Change: ${formatCurrency(change)} (*${formatPercent(changePercent)}*)\\n` +\n`- Current Value: ${formatCurrency(currentValue)}`;\n\nreturn [{\n  json: {\n    chat_id: $('Edit Fields').first().json.myId,\n    text: message,\n    parse_mode: \"Markdown\"\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "61c27425-c7f1-44e2-b36a-386076e9abfd",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1300,
        60
      ],
      "webhookId": "8fe1d478-06d9-4fd2-9e7f-b66d7fe13b38",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "chatIds": "[telegram-id]"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "GoSthSk9tEcGAZrk",
          "name": "Telegram account 3"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bc3603aa-cb9d-49f3-a9cb-83dd90b4d0b5",
      "name": "Broker PNL Update",
      "type": "n8n-nodes-base.telegram",
      "position": [
        180,
        -40
      ],
      "webhookId": "5933d82d-50b2-4a7d-ad0b-15b9d5a70b34",
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "={{ $json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "GoSthSk9tEcGAZrk",
          "name": "Telegram account 3"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "61c9441a-f243-49ab-824f-2148d3d9c48f",
      "name": "Auto Update at 10AM and 4PM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -560,
        260
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 16
            },
            {
              "triggerAtHour": 10
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9d2f23f4-5371-45fb-8a03-f7d261f2a0dd",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -1060,
        60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "619c3c76-c797-454c-8995-3cb0c39b20d7",
              "name": "myId",
              "type": "string",
              "value": "=[telegram-id]"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "32f61af1-faea-4148-adb9-fd00ec437810",
      "name": "Total PNL Update",
      "type": "n8n-nodes-base.telegram",
      "position": [
        440,
        260
      ],
      "webhookId": "5933d82d-50b2-4a7d-ad0b-15b9d5a70b34",
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "={{ $json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "GoSthSk9tEcGAZrk",
          "name": "Telegram account 3"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "948fc47b-8d28-4358-9c69-bda130e026af",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2180,
        -340
      ],
      "parameters": {
        "color": 4,
        "width": 840,
        "height": 1520,
        "content": "## **All-in-One Portfolio Tracker & Telegram Finance Updates Workflow for n8n: Multi-Broker, Real-Time, Global 🚀**\n\n### Overview\n\nTake control of all your investments—across multiple brokers and platforms—in one place, with live updates sent directly to your Telegram! 🌍💸 This n8n template brings together Google Sheets and Telegram so you can track your complete finance portfolio with ease, whether you’re in the US market, India, or anywhere in the world.\n\n### How This Workflow Works\n\n- **Tracks your investments** across multiple brokers, platforms, or asset types.\n- **Automatically sends updates to your Telegram account**—see daily Profit & Loss (P&L), changes, and total returns in a rich, emoji-filled report.\n- **Works globally**, with a sample provided for the US market, but can be configured for any country and broker.\n- **Schedule automated updates** (e.g., market close/open) or get real-time insights on demand with Telegram commands.\n\n### Highlights & Features\n\n- 📊 **Unified Dashboard**: Integrate all your broker data in one Google Sheet for effortless monitoring (Google Sheet Link - https://docs.google.com/spreadsheets/d/1dakq9EhU8GrDgBsk82KvAen0N1P3FySAwNHFtG2lsLI/edit?usp=sharing)\n- 🤖 **Interactive Telegram Bot**: Send `/total` or a specific broker’s name in the Telegram chat to get instant, formatted portfolio summaries.\n- ⏰ **Automatic Notifications**: Receive scheduled P&L summaries at market open and close.\n- 🗂️ **Customizable for Any Region or Broker**: Just update your Google Sheet with the platforms or brokers you use—including those in the US, Europe, Asia, etc.\n- 🔐 **Secure and Private**: Only your pre-set Telegram user or chat receives the sensitive financial update.\n\n### Example (For US Market)\n\nLet’s imagine you have portfolios with **Robinhood**, **E*TRADE**, and **Charles Schwab**. Every day at 10AM and 4PM Eastern Time, or whenever you send the `/total` command, you get this on Telegram:\n\n```\n📊 Daily P&L Report\n\n🔹 Robinhood\n- Invested: $5,000.00\n- P&L: $250.00 (5.00%)\n- Change: $30.00 (0.60%)\n- Current Value: $5,250.00\n\n🔹 E*TRADE\n- Invested: $8,000.00\n- P&L: $400.00 (5.00%)\n- Change: $45.00 (0.56%)\n- Current Value: $8,400.00\n\n📈 Total Portfolio\n- Total Invested: $13,000.00\n- Total P&L: $650.00 (5.00%)\n- Today's Change: $75.00 (0.58%)\n\n💰 Overall Value: $13,650.00\n📈 Overall Return: 5.00%\n💸 Overall P&L: $650.00\n```\n\n### Who Is This For?\n\n- Investors managing accounts across several brokers.\n- Traders seeking real-time daily summaries.\n- Portfolio managers wanting one consolidated, secure view.\n- Users in any country, for any major market.\n\n\n### Make It Yours! 🌏\n\nCustomize the sheet and workflow for your unique blend of accounts, currencies, and platforms—track mutual funds, stocks, ETFs, cryptos, or more. Get peace of mind with every notification, organized and delivered just for you!\n\n**Start tracking smarter, not harder. Transform your finance workflow with n8n + Telegram today! 🚀**"
      },
      "typeVersion": 1
    },
    {
      "id": "90280429-7ef1-4fa2-b7dc-5a777faa0b91",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -340
      ],
      "parameters": {
        "color": 3,
        "width": 780,
        "height": 300,
        "content": "\n### Easy Setup Steps\n\n1. **Copy the Template to Your n8n Instance**: Just import the provided workflow JSON.\n2. **Configure Your Google Sheet**:  \n   - List all your brokers/platforms as rows (US, EU, or any other market).\n   - Update your credentials in n8n for Google Sheets and Telegram.\n3. **Set Your Telegram Chat ID**: Secure, so only you or your group receive updates.\n4. **Customize Schedules**: Change times for your local market hours or as you prefer.\n5. **Send Commands in Telegram**:  \n   - `/total` for overall summary\n   - `/Robinhood`, `/ETRADE`, etc., for individual broker updates"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Telegram Trigger": [
      {
        "body": {
          "message": {
            "chat": {
              "id": 864930702,
              "type": "private",
              "username": "Akashkankariya25",
              "last_name": "Kankariya",
              "first_name": "Akash"
            },
            "date": 1752144799,
            "from": {
              "id": 864930702,
              "is_bot": false,
              "username": "Akashkankariya25",
              "last_name": "Kankariya",
              "first_name": "Akash",
              "language_code": "en"
            },
            "text": "/total",
            "entities": [
              {
                "type": "bot_command",
                "length": 9,
                "offset": 0
              }
            ],
            "message_id": 144
          },
          "update_id": 692524987
        },
        "query": {},
        "params": {},
        "headers": {
          "host": "127.0.0.1:8443",
          "connection": "upgrade",
          "content-type": "application/json",
          "content-length": "399",
          "accept-encoding": "gzip, deflate"
        },
        "webhookUrl": "https://n8n.algowiz.in:8443/webhook/7cfe9667-1d95-4bce-9977-1959d8765037",
        "executionMode": "production"
      }
    ]
  },
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Total PNL Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Broker PNL Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Broker PNL Update": {
      "main": [
        []
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet2": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto Update at 10AM and 4PM": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流