# Gold & Precious Metals Research

Workflow for valuing gold coins, bars, and silver — combining live spot prices with dealer-specific Ankauf (buy-back) rates.

## Two-Layer Approach

### Layer 1: Live Spot Prices (API)

**Gold spot (USD/oz):**
```bash
curl -sL "https://api.gold-api.com/price/XAU" | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'Gold: \${d[\"price\"]}/oz')"
```

**Silver spot (USD/oz):**
```bash
curl -sL "https://api.gold-api.com/price/XAG" | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'Silver: \${d[\"price\"]}/oz')"
```

**FX rates (for EUR/TRY conversion):**
```bash
curl -sL "https://api.exchangerate-api.com/v4/latest/USD" | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'USD/EUR: {d[\"rates\"][\"EUR\"]}, USD/TRY: {d[\"rates\"][\"TRY\"]}')"
```

### Layer 2: Dealer Ankauf Prices (Camofox)

Dealer websites (Haytan, philoro) are JS-rendered SPAs — `curl` gets empty shells. Use Camofox screenshots + vision_analyze.

**Haytan workflow:**
1. Open `https://www.haytan.at/` in Camofox — main page shows Turkish gold coin prices (Tam, Yarım, Çeyrek, Reşat, Gremse) in a live table
2. Screenshot + vision_analyze to extract the "GOLDANKAUF UND GOLDVERKAUF" table
3. Navigate to `/goldbarren/` and `/goldmuenzen/` for bullion prices (Philharmoniker, Commerzbank, etc.)
4. Note: Haytan's bullion pages often show the same Turkish coin table, not bullion-specific prices — the site may not publicly list them

**philoro workflow (for bullion + silver):**
1. Open product page directly, e.g. `https://philoro.at/produkt/silber-philharmoniker-1-oz` or `https://philoro.at/shop/goldbarren`
2. **Cookie banner blocks prices.** Click "Alle akzeptieren" via `/click` with selector `"button:has-text('Alle akzeptieren')"`, wait 2-3s, re-screenshot
3. Product detail pages show both **Verkauf** (sell price, large) and **Ankauf** (buy-back, smaller button below): e.g. Silber Philharmoniker 1oz: Verkauf €80.89, Ankauf €59.09
4. **Goldbarren category page** (`/shop/goldbarren`) shows a grid of products with Kaufen/Verkaufen prices per card — scroll down for smaller bars
5. **Dynamic loading issue:** Some product pages (1g, 10g direct URLs) load prices via JS and may render blank in Camofox screenshots. Fall back to the category grid page or calculate from the 1oz reference price
6. **philoro 1oz gold bar reference price** (16.06.2026): Ankauf €3,628.84 → €116.67/g. Use this to estimate other bar sizes

**Dealer comparison (16.06.2026):**

| Item | Haytan Ankauf | philoro Ankauf |
|------|--------------|----------------|
| Tam Lira (7g 22K) | €779 | — |
| Yarım Lira (3.5g 22K) | €390 | — |
| Çeyrek Lira (1.75g 22K) | €195 | — |
| Reşat (7.2g 22K) | €777 | — |
| 1oz Goldbarren (24K) | — | €3,628.84 |
| Silber Philharmoniker 1oz | — | €59.09 |

**Fallback for bullion:** If dealer pages don't show bullion prices, calculate from spot:
- **Ankauf rate:** ~97.5% of spot for 1oz+ bars/coins, ~95% for 1g bars
- **Silver Ankauf:** ~90% of spot (higher spread due to VAT on purchase)
- **22K gold:** 91.6% of 24K spot price

## Turkish Gold Coins Reference

| Coin | Weight | Purity | Notes |
|------|--------|--------|-------|
| Çeyrek Lira | 1.75g | 22K (91.6%) | Quarter Lira |
| Yarım Lira | 3.5g | 22K | Half Lira |
| Tam Lira | 7g | 22K | Full Lira |
| Reşat | 7.2g | 22K | Ottoman design, slightly heavier |
| Gremse | 17.5g | 22K | 2.5× Tam |

## Conversion Formulas

```
EUR/gram (24K) = (spot_USD_per_oz × USD_to_EUR) / 31.1035
EUR/gram (22K) = EUR/gram (24K) × 0.916
Ankauf = spot_value × dealer_rate
```

## Pitfalls

- **Haytan is JS-rendered:** `curl` returns empty shell. Must use Camofox screenshot + vision.
- **Bullion pages may not show bullion:** Haytan's `/goldbarren/` and `/goldmuenzen/` pages often display the same Turkish coin table. For exact bullion Ankauf rates, call the dealer or try proaurum.at / philoro.at.
- **1g bars have worse rates:** Small bars (1g) get ~95% of spot vs ~97.5% for 1oz+. Factor this into estimates.
- **Silver spread is wider:** Dealers buy silver at ~85-90% of spot due to VAT on original purchase.
- **Spot APIs can fail:** gold-api.com is reliable; metals.live and goldapi.io often require keys or fail. Have fallbacks ready.
