Help me create valid script to pivot table of my stocks

What I’m trying to do

I want to create note, which will show me pivot table of all my investments, group it by type of invesments (like stoks, banks deposit, bonds and so on), sort it and calculate the “weight” of each type of investments to total amount of my portfolio.

Things I have tried

I created folder “Investment”, subfolder “Stocks” and note “Stocks” in this with a yaml-format text, like:

---
Date: 2024-11-27
Type: Stock
Name: something
Quantity: 10
PurchasePrice: 1144
CurrentPrice: 1242
---

Than I asked ChatGPT to create dataview script, which will execute all I want.
It offered me this script:

// Function to calculate total amount of assets
const totalValue = dv.pages('"Investment"')
 .where(p => p.Type)
 .sum(p => p.Quantity * p.CurrentPrice);

// Get all assets
const positions = dv.pages('"Investment"').where(p => p.Type).sort(p => p.Date);

// Create final table
dv.table(
 ["Type", "Name", "Quantity", "PurchasePrice", "CurrentPrice", "Total Amount"],
 positions.map(p => [
  p.Type,
  p.Name,
  p.Quantity,
  p.PurchasePrice,
  p.CurrentPrice,
  p.Quantity * p.CurrentPrice
 ])
);

// Add string with total amount
dv.paragraph(`Total amount assets: ${totalValue}`);

But, the problem is - non of my notes do not visible for this script and table is empty.

And I’ve tried to just list this pages - didn’t work.
(Something like

LIST
FROM "Investment"
where type
```)

Where could be a problem? I've checked naming of attributes several times and so on, but I do not understand why it is not working, while it is sound like logical script. 

Thank you very much in advance)