{
  "name": "Track portfolio performance and risk using Google Sheets and Alpha Vantage",
  "nodes": [
    {
      "id": "365a188d-baf8-4a34-a75a-82268fac6bb0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -880
      ],
      "parameters": {
        "width": 544,
        "height": 656,
        "content": "## Track portfolio performance and risk using Google Sheets and Alpha Vantage - Overview\n\nThis workflow automatically tracks stock portfolio performance by reading holdings from Google Sheets, fetchin"
      }
    },
    {
      "id": "529f71be-5a19-4d09-911e-f7dd4c18ad79",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -176
      ],
      "parameters": {
        "width": 576,
        "height": 368,
        "content": "### Portfolio Input and Scheduling\n\nThis workflow runs on a schedule and reads stock holdings such as (symbol, buy price, quantity, buy date) from Google Sheets. Each row represents one portfolio posi"
      }
    },
    {
      "id": "a8b67a41-3ae8-4a29-bbdf-6299e5ac4e1c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -224
      ],
      "parameters": {
        "width": 320,
        "height": 416,
        "content": "### Market data retrieval\n\nFetches daily stock price data from the Alpha Vantage API for each portfolio holding to ensure consistent performance calculations."
      }
    },
    {
      "id": "4a854d01-7cd7-4691-a618-6ea4b5f18345",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -224
      ],
      "parameters": {
        "width": 608,
        "height": 416,
        "content": "### Performance and risk analysis\n\nCalculates invested value, current value, PnL, return %, CAGR, and maximum drawdown. Each stock is classified as Healthy, Watch, or Risk. After calculations, the lat"
      }
    },
    {
      "id": "918eb914-c4f3-4aa1-8f4f-df25ef16a4c2",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        320
      ],
      "parameters": {
        "width": 672,
        "height": 336,
        "content": "## 🚨 Error Handling \n\n \nCatches any workflow failure and posts an alert to Email.  \nIncludes node name, error message, and timestamp for quick debugging.\n"
      }
    },
    {
      "id": "b0920fc8-a89d-4728-bd26-a458496e8531",
      "name": "Run daily portfolio update",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -48,
        16
      ]
    },
    {
      "id": "99515b62-d127-405d-8d43-dc1e71073f70",
      "name": "Read portfolio holdings",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        16
      ]
    },
    {
      "id": "7ffa2d8a-ea7d-4a6d-b7d5-c2cf70017e55",
      "name": "Process each stock",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        352,
        16
      ]
    },
    {
      "id": "8dca0ca9-6d59-46e7-96b6-955a86799e6a",
      "name": "Fetch daily stock prices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        624,
        16
      ]
    },
    {
      "id": "b32f194b-64cb-4892-88bb-d8fbc41f4017",
      "name": "Calculate returns and risk metrics",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        16
      ]
    },
    {
      "id": "28bb1003-a7a0-4d83-a7c1-db8bab41e970",
      "name": "Update portfolio performance",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1248,
        16
      ]
    },
    {
      "id": "8a9f430e-88a1-4b9c-a99a-fceea5e6475b",
      "name": "Workflow error trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        -416,
        480
      ]
    },
    {
      "id": "b516ff82-6e22-453e-a0f5-9e871567ad06",
      "name": "Send error notification email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -96,
        480
      ]
    }
  ],
  "connections": {
    "Process each stock": {
      "main": [
        [],
        [
          {
            "node": "Fetch daily stock prices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow error trigger": {
      "main": [
        [
          {
            "node": "Send error notification email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read portfolio holdings": {
      "main": [
        [
          {
            "node": "Process each stock",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch daily stock prices": {
      "main": [
        [
          {
            "node": "Calculate returns and risk metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run daily portfolio update": {
      "main": [
        [
          {
            "node": "Read portfolio holdings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate returns and risk metrics": {
      "main": [
        [
          {
            "node": "Update portfolio performance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}