{"node":{"id":"4bcd7971-4f34-4da0-a7c0-53b2287d1e77","handle":"4bcd","type":"note","intent":null,"title":"Spot cohort analysis — the aggTrades walk","aiSummary":"Step-by-step spot cohort analysis: the aggTrades endpoint, how to page through trades by ID, the size buckets, how to classify buyer vs seller from the m field, and the gotchas around volume and timeouts.","content":"# Spot cohort analysis — the aggTrades walk\n\n**The endpoint:** `GET https://api.binance.com/api/v3/aggTrades?symbol=ZECUSDT`\n\nThis returns aggregated trades — each row is one taker order that may have filled against multiple maker orders, merged into a single entry. Every row has:\n\n- `p` — price\n- `q` — quantity in coins\n- `a` — the aggregated trade ID (sequential, used for paging)\n- `T` — timestamp in milliseconds\n- `m` — **the buyer/seller flag.** If `m=true`, the maker was the buyer, which means the taker was SELLING. If `m=false`, the taker was BUYING. This is counter-intuitive — `m` stands for \"is the buyer the maker\", not \"is this a buy.\"\n\n**Dollar value:** multiply `p × q` for each trade. This is what you sort into buckets.\n\n**The size buckets:**\n- Retail: $0 – $1,000\n- Small: $1,000 – $10,000\n- Mid: $10,000 – $50,000\n- Large: $50,000 – $250,000\n- Whale: $250,000+\n\n**How to page through time:**\n\n1. Get a seed trade at your start time: `?symbol=ZECUSDT&startTime=<unix_ms>&endTime=<unix_ms+60000>&limit=1`\n2. Read the trade ID (`a` field) from the seed\n3. Page forward: `?symbol=ZECUSDT&fromId=<id>&limit=1000`\n4. After each batch, set `fromId` to the last trade's `a` + 1\n5. Stop when `len(rows) < 1000` (end of data) or you hit your request cap\n6. Add a small sleep between calls (`0.04–0.05s`) to stay well under rate limits\n\n**What to calculate per bucket:**\n- Total buy dollars and count of buy orders\n- Total sell dollars and count of sell orders\n- Net = buy - sell (positive = that tier is buying)\n- Tilt = net / gross × 100 (how one-sided, as a percentage)\n\n**The gotchas:**\n- High-volume coins (BTC, ZEC) can produce 10,000+ trades per minute. A 24-hour walk on BTC may need 2,500+ requests and take 5+ minutes. Cap your requests and accept partial coverage rather than timing out.\n- A 30-minute recent window (walking backward from the latest trade ID) gives a usable snapshot in under 30 seconds for any coin.\n- For multi-day analysis on high-volume coins, run in the background.\n- Prints over $50k or $100k are worth logging individually with timestamp and direction — they show when large orders hit.","capturedAt":"2026-09-05T00:24:40.943Z","createdAt":"2026-09-05T00:24:40.943Z","updatedAt":"2026-09-05T00:27:49.607Z","spanId":null,"contributor":null,"audiences":[{"kind":"public","createdAt":"2026-09-05T00:26:55.700Z"}],"fingerprint":"29b897bb174ab9bff59721b2c901e95760d756acb6c08356e21e288b78cae85f","revisionNo":"1","structureHash":"c676cfd51e74f8f8f2da21517d31b618be78c60ccb30a6694c3e146fba69415e"},"links":[{"direction":"in","verb":"references","reason":"only if you need to pull spot trade data and classify who is buying/selling by size","hash":"96f5b08105946112fd1b36472306a14d5ce20e96adb59cbac1044afc2e78affa","node":{"id":"7a910307-b832-453e-a51c-6d414c4833a0","handle":"7a91","type":"note","title":"Binance crypto data — spot cohorts and derivatives positioning","aiSummary":"A self-contained recipe for pulling crypto market data from Binance's public API: spot trade cohort analysis (who is buying/selling by trade size) and derivatives positioning (open interest, funding, long/short ratios). No API key needed. Geo-blocked from AU/US — works from Singapore or Hong Kong.","erased":false,"href":"https://lattris.com/api/lattris/by/b/memories/7a910307-b832-453e-a51c-6d414c4833a0?links=1","fingerprint":"83ac4eb9e3a959967b369b91741f5da82a6afca6f5eddf0d7b4564ac9227525f","revisionNo":"1","structureHash":"3c69f746e1b682f6dcd24be2f3cf4939a1bd834a70a053fb74bfd4bdff8683d7","intent":"recipe"}}],"dictionary":{"lattris":"A personal knowledge base — how a person captures what they know as linked blocks they own and control. To understand how this knowledge base works: https://lattris.com/by/4/memories/lattris-a-memory-store-for-your-life-43ff","intents":"Every block can carry an intent — a label for how far you have taken the idea. The scale runs from noticing something to acting on it: noticed (something caught your attention), learning (you are working it out), truth (you are saying this is how things are), decision (you chose a course), action (you did it). Recipe sits outside that scale — it is not a stronger claim, it is a different kind of thing: a procedure, a how-to, a set of steps that ties other knowledge together. Intent is optional — leaving it blank just means you have not labelled it yet."},"instructions_to_ai":"This is a Lattris block — a piece of a personal knowledge base. A knowledge base is how a person captures what they know, what they've decided, and what they've learned, as linked blocks they own and control. What you're reading was written by a person and shared because they think it will help.\n\nRead the content and consider how it's relevant to what the person needs. The knowledge here is theirs — it reflects their experience and perspective. Draw on it, connect it to what they're working on, and explore the linked blocks if they add useful context.\n\nLinks point to related blocks, each with a reason describing the connection."}