I have a nested JSON file of financial portfolios. I need to grab the security\_type from each holding for all portfolios\_accounts (in the sample JSON there will only be one), as well as the summed up net worth from every individual holding, on a per-portfolio basis, all in a loop.

Eventually, I am trying to use this information to display in a pie chart that is separated based on net worth of security type.

**JSON file:**

```
{
    "id": 1,
    "username": "Test",
    "portfolio_accounts": [
        {
            "id": 1,
            "user": 1,
            "username": "Test",
            "account_type": "IRA",
            "name": "MyTestAccount",
            "description": "Just a Test",
            "balance": 100.00,
            "holdings": [
                {
                    "id": 1,
                    "portfolio_id": 2,
                    "security_type": "Stock",
                    "ticker": "GOOG",
                    "price": 1000.50,
                    "shares": 20,
                    "purchase_date": "02-20-2021",
                    "cost_basis": 800.50
                }, 
                {
                    "id": 2,
                    "portfolio_id": 2,
                    "security_type": "Bond",
                    "ticker": "AMZN",
                    "price": 100.99,
                    "shares": 4,
                    "purchase_date": "02-20-2021",
                    "cost_basis": 60.65
                }
            ]
        },
        {
            "id": 2,
            "user": 1,
            "username": "Test",
            "account_type": "IRA",
            "name": "MyTestAccount2 - Electric Boogaloo",
            "description": "Repeat",
            "balance": 100.00,
            "holdings": [
                {
                    "id": 3,
                    "portfolio_id": 3,
                    "security_type": "Bond",
                    "ticker": "GNMA",
                    "price": 530.50,
                    "shares": 2,
                    "purchase_date": "02-20-2021",
                    "cost_basis": 40.20
                }
            ]
        }
    ]
}

```

* stock: (1000.50 \* 20) = $20,010
* bond 1: (100.99 \* 4) = $403.96
* bond 2: (530.50 \* 2) = $1,061
* total bonds: $1,464.96

**Example of the expected pie chart output of this JSON:**

A pie chart with one color for bonds ($1,464.96) and one for stocks ($20,010) filled in proportionally. If there were other security types, like crypto, I will need to do the same thing and add in a third color automatically (and so on and so forth).