Gold Investment Tracker

Gold Investment Tracker

Add / Edit Gold Holding

Current Gold Holdings

DescriptionPurchase DateQtyUnit Price/UnitCost Basis Current ValueValuation Date Gain/Loss ($)Gain/Loss (%) Holding PeriodActions

Update Current Market Gold Prices

Enter the current spot prices for gold. Clicking "Apply Market Prices" will recalculate the value of your holdings listed in Ounces or Grams. Items listed as 'Units/Pieces' must be valued individually by editing them.

Portfolio Summary

Total Holdings

0

Total Cost Basis

$0.00

Total Current Value

$0.00

Total Unrealized Gain/Loss

$0.00

Total Items: ${summaryTotalItems.textContent}

Total Cost Basis: ${summaryTotalCostBasis.textContent}

Total Current Value: ${summaryTotalCurrentValue.textContent}

Total Unrealized Gain/Loss: ${summaryTotalGainLoss.textContent}

`; let marketPricesHtml = `

Current Market Prices Used for Ounces/Grams (if applicable)

Price per Ounce: ${currentGoldPrices.pricePerOunce ? formatCurrency(currentGoldPrices.pricePerOunce) : 'N/A'}

Price per Gram: ${currentGoldPrices.pricePerGram ? formatCurrency(currentGoldPrices.pricePerGram) : 'N/A'}

Market Valuation Date: ${currentGoldPrices.valuationDate ? formatDateForDisplay(currentGoldPrices.valuationDate) : 'N/A'}

`; let itemsHtml = `

Gold Holdings

`; goldHoldings.forEach(h => { const costBasis = h.quantity * h.purchasePricePerUnit; let currentVal = h.itemCurrentValue; let valDateForDisplay = h.itemValuationDate; if((h.unit === 'ounces' || h.unit === 'grams')) { // Use global if more relevant let useGlobalPdf = false; if(currentGoldPrices.valuationDate) { if(!h.itemValuationDate || new Date(currentGoldPrices.valuationDate) > new Date(h.itemValuationDate)) { useGlobalPdf = true; } } if(useGlobalPdf) { if (h.unit === 'ounces' && currentGoldPrices.pricePerOunce !== null) { currentVal = h.quantity * currentGoldPrices.pricePerOunce; valDateForDisplay = currentGoldPrices.valuationDate; } else if (h.unit === 'grams' && currentGoldPrices.pricePerGram !== null) { currentVal = h.quantity * currentGoldPrices.pricePerGram; valDateForDisplay = currentGoldPrices.valuationDate; } } } const gainLossAmount = (currentVal !== null && !isNaN(currentVal)) ? currentVal - costBasis : null; const gainLossPercent = (gainLossAmount !== null && costBasis !== 0) ? (gainLossAmount / costBasis) * 100 : null; itemsHtml += ``; }); itemsHtml += `
DescriptionPurchase DateQtyUnit Price/UnitCost BasisCurrent ValueVal. Date Gain/Loss ($)Gain/Loss (%)Holding Period
${h.description}${formatDateForDisplay(h.purchaseDate)}${h.quantity} ${h.unit.charAt(0).toUpperCase() + h.unit.slice(1)} ${formatCurrency(h.purchasePricePerUnit)}${formatCurrency(costBasis)} ${formatCurrency(currentVal)}${formatDateForDisplay(valDateForDisplay)} ${formatCurrency(gainLossAmount)} ${formatPercentage(gainLossPercent)} ${calculateHoldingPeriod(h.purchaseDate, valDateForDisplay)}
`; const pdfContent = `

Gold Investment Portfolio Report

${summaryHtml} ${(currentGoldPrices.pricePerOunce || currentGoldPrices.pricePerGram) ? marketPricesHtml : ''} ${itemsHtml}

Generated: ${new Date().toLocaleString()}

`; const printWindow = window.open('', '_blank'); if(printWindow) { printWindow.document.write(pdfContent); printWindow.document.close(); printWindow.focus(); setTimeout(() => printWindow.print(), 250); } else { alert('Could not open print window. Check pop-up settings.'); } }); // Initial Load loadData(); // This will also call renderHoldings -> renderSummary and toggleItemSpecificValueFields switchTab('gitManageHoldingsTab'); // Ensure first tab is active });
Scroll to Top