PY 06: Demand over time

Track: Code (Python client + raw REST) Prerequisite: PY_05.

The task

Fetch a brand's sold lots, bucket them by quarter using sale_date, and count lots per quarter to build a simple demand index, understood as a learning exercise rather than a market-appreciation claim.

Starter steps

  1. Fetch sold lots for one designer with their sale dates and prices:
rows = client.query(
    "all_watches_data",
    fields=["sale_date", "usd_price_decimal"],
    filters=[
        {"field": "designer", "op": "eq", "value": "Omega"},
        {"field": "status", "op": "eq", "value": "sold"},
    ],
    limit=1000,
)
  1. Convert each sale_date string to a quarter label and count lots per quarter using plain Python:
from collections import Counter
from datetime import datetime

def quarter_label(date_str):
    d = datetime.fromisoformat(date_str[:10])
    q = (d.month - 1) // 3 + 1
    return f"{d.year}-Q{q}"

quarters = [quarter_label(r["sale_date"]) for r in rows if r.get("sale_date")]
counts_by_quarter = Counter(quarters)
for label in sorted(counts_by_quarter):
    print(label, counts_by_quarter[label])
  1. If you have pandas available, PY_09 shows the same bucketing done with pd.to_datetime(...).dt.to_period("Q"), which is faster to write for larger pulls.

Expected result

A printed series of quarter labels (for example 2023-Q1, 2023-Q2, and so on) each paired with a lot count, running from the earliest sold lots for that designer up to the most recent quarter. This is a learning exercise in time bucketing, not a market-appreciation claim: the most recent one to two quarters typically show fewer lots than the surrounding trend, because new auction results take time to be scraped, classified, and ingested. Treat those trailing points as provisional and exclude them from any conclusion about rising or falling demand.

Stretch challenge

Extend the loop to also compute a median usd_price_decimal per quarter (using statistics.median on the prices in each bucket), and print quarter, lot count, and median price together, again excluding the trailing one to two quarters from interpretation.