GROQ-powered portfolio — gain/loss auto-calculated from structured priceHistory.
TOTAL ITEMS
3
TOTAL MARKET VALUE
Rp 3.900.000
+Rp 1.000.000 (34%)
WISHLIST
2
Grail owned: 1
Keychron • used_excellent
Purchase
Rp 2.100.000
Market
Rp 1.800.000
Rp -300.000 (-14%)
Mattel • mint_sealed
Purchase
Rp 150.000
Market
Rp 1.250.000
+Rp 1.100.000 (733%)
Bandai • mint_sealed
Purchase
Rp 650.000
Market
Rp 850.000
+Rp 200.000 (31%)
// Items with calculated gain + 5 last prices
*[_type == "collectibleItem" && status=="owned"] | order(currentValue desc){
_id, title, slug, brand, rarity, condition, purchasePrice, currentValue, quantity,
"category": category->title,
"categoryIcon": category->icon,
"image": images[0],
"gain": currentValue - purchasePrice,
"gainPercent": round(((currentValue - purchasePrice)/purchasePrice)*100),
"priceHistory": *[_type=="priceHistory" && item._ref==^._id && isOutlier != true] | order(recordedAt desc)[0..5]{price, recordedAt, source}
}
// Portfolio stats (needs structured isOutlier filter)
{
"totalItems": count(*[_type=="collectibleItem" && status=="owned"]),
"totalPurchase": math::sum(*[_type=="collectibleItem" && status=="owned"].purchasePrice),
"totalMarket": math::sum(*[_type=="collectibleItem" && status=="owned"].currentValue),
"wishlistCount": count(*[_type=="wishlist"]),
"grails": *[_type=="collectibleItem" && rarity=="grail" && status=="owned"]{title, currentValue}
}