Changeset 9e6d8a2 for docs/P6-AdvancedReports/AdvancedReports.md
- Timestamp:
- 09/17/26 00:36:39 (13 days ago)
- Branches:
- main
- Children:
- 4438e45
- Parents:
- 35bcb41
- File:
-
- 1 edited
-
docs/P6-AdvancedReports/AdvancedReports.md (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/P6-AdvancedReports/AdvancedReports.md
r35bcb41 r9e6d8a2 175 175 physical products: a market with heavy volume but a dead price, or a big price swing nobody 176 176 actually traded, are both misleading on their own; this report puts volume, trade count, 177 price return , volatilityand user participation side by side so a market's performance over a177 price return and user participation side by side so a market's performance over a 178 178 quarter/year/multi-year window can be judged as a whole, not from one number in isolation. 179 179 Everything needed already exists: `market_trades` is the single source of truth for price and … … 192 192 - **Market return %** = `(last trade price − first trade price) ÷ first trade price × 100`, 193 193 ordering trades by `executed_at` inside the period. 194 - **Price volatility** = the (sample) standard deviation of trade prices in the period.195 194 - **Participating users** = `COUNT(DISTINCT user_id)` from that market's **executed orders** 196 195 in the period — the only correct source, since `market_trades` cannot answer this question … … 211 210 avg_price numeric, 212 211 market_return_pct numeric, 213 price_volatility numeric,214 212 participating_users bigint 215 213 ) … … 231 229 COUNT(*) AS trade_count, 232 230 AVG(price) AS avg_price, 233 STDDEV(price) AS price_volatility,234 231 MAX(first_price) AS first_price, 235 232 MAX(last_price) AS last_price … … 250 247 ROUND(ms.avg_price, 6) AS avg_price, 251 248 ROUND((ms.last_price - ms.first_price) / NULLIF(ms.first_price, 0) * 100, 2) AS market_return_pct, 252 ROUND(COALESCE(ms.price_volatility, 0), 6) AS price_volatility,253 249 COALESCE(p.participating_users, 0) AS participating_users 254 250 FROM market_stats ms … … 270 266 271 267 ``` 272 Symbol Quote Volume Trades Avg Price Return % VolatilityUsers273 ----------------------------------------------------------------------------- ----------------274 DOGE USD 29500.0000 3 0.120583 +2.95 0.0018430275 ADA USD 2500.0000 3 0.450750 +1.62 0.0037830276 SOL USD 23.5000 3 165.283333 +1.13 0.9438400277 ETH USD 14.3500 8 3622.312500 -12.00 182.6579922278 BTC USD 3.9750 9 59447.400000 +67.85 10563.4133392268 Symbol Quote Volume Trades Avg Price Return % Users 269 ----------------------------------------------------------------------------- 270 DOGE USD 29500.0000 3 0.120583 +2.95 0 271 ADA USD 2500.0000 3 0.450750 +1.62 0 272 SOL USD 23.5000 3 165.283333 +1.13 0 273 ETH USD 14.3500 8 3622.312500 -12.00 2 274 BTC USD 3.9750 9 59447.400000 +67.85 2 279 275 ``` 280 276 281 277 BTC/USD and ETH/USD are the only two markets with historical (multi-quarter) data seeded, and 282 they show it: BTC's price nearly tripled over the period (`+67.85%`) with by far the highest 283 volatility, while ETH quietly lost `12%`. ADA/SOL/DOGE only have the few minutes of 284 `data_load.sql`'s own recent seed trades, so their return/volatility numbers reflect that 285 narrow window, and their `0` participating users is correct — `data_load.sql` seeds trade 286 history for every market but only ever places an *order* on ETH. 278 they show it: BTC's price nearly tripled over the period (`+67.85%`), while ETH quietly lost 279 `12%`. ADA/SOL/DOGE only have the few minutes of `data_load.sql`'s own recent seed trades, so 280 their return numbers reflect that narrow window, and their `0` participating users is correct 281 — `data_load.sql` seeds trade history for every market but only ever places an *order* on ETH. 282 283 A price-volatility column (standard deviation of trade price) was dropped from this report 284 after review — with only a handful of trades per market in most periods it read as noise 285 rather than signal, and total volume plus return already carry the useful information. 287 286 288 287 ### Solution Relational Algebra … … 301 300 302 301 Stats = γ_{market_id ; SUM(quantity) → total_volume, COUNT(*) → trade_count, 303 AVG(price) → avg_price , STDDEV(price) → price_volatility} (MT_period)302 AVG(price) → avg_price} (MT_period) 304 303 305 304 MarketStats = (Stats ⋈_{market_id} FirstPx) ⋈_{market_id} LastPx … … 314 313 π_{symbol, quote_currency, total_volume, trade_count, avg_price, 315 314 (last_price − first_price) / first_price × 100 → market_return_pct, 316 COALESCE(price_volatility, 0) → price_volatility,317 315 COALESCE(participating_users, 0) → participating_users} 318 316 (Joined) ) … … 338 336 turn them into working SQL, wire them into the prototype as real reports, build the 339 337 relational-algebra equivalents, and produce demonstration data rich enough to show the 340 reports doing something non-trivial. 338 reports doing something non-trivial. In a follow-up, I asked for the price-volatility column 339 to be dropped from the market performance report — see 340 [AdvancedReportsAIUsage](AdvancedReportsAIUsage.md#follow-up--2026-09-17) for that change.
Note:
See TracChangeset
for help on using the changeset viewer.
