global: metrics -> series rename

This commit is contained in:
nym21
2026-03-16 14:31:50 +01:00
parent bc06567bb0
commit ae2dd43073
95 changed files with 8907 additions and 8415 deletions
+155 -155
View File
@@ -23,7 +23,7 @@ import { colors } from "../../utils/colors.js";
/**
* @param {{ sent: Brk.BaseCumulativeInSumPattern, coindaysDestroyed: Brk.BaseCumulativeSumPattern<number> }} activity
* @param {Color} color
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsTree}
*/
function volumeAndCoinsTree(activity, color, title) {
@@ -35,18 +35,18 @@ function volumeAndCoinsTree(activity, color, title) {
name: "Sum",
title: title("Sent Volume"),
bottom: [
line({ metric: activity.sent.base, name: "Sum", color, unit: Unit.sats }),
line({ metric: activity.sent.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ metric: activity.sent.sum._1w, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ metric: activity.sent.sum._1m, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ metric: activity.sent.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
line({ series: activity.sent.base, name: "Sum", color, unit: Unit.sats }),
line({ series: activity.sent.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ series: activity.sent.sum._1w, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ series: activity.sent.sum._1m, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ series: activity.sent.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
],
},
{
name: "Cumulative",
title: title("Sent Volume (Total)"),
bottom: [
line({ metric: activity.sent.cumulative, name: "All-time", color, unit: Unit.sats }),
line({ series: activity.sent.cumulative, name: "All-time", color, unit: Unit.sats }),
],
},
],
@@ -58,18 +58,18 @@ function volumeAndCoinsTree(activity, color, title) {
name: "Base",
title: title("Coindays Destroyed"),
bottom: [
line({ metric: activity.coindaysDestroyed.base, name: "Base", color, unit: Unit.coindays }),
line({ metric: activity.coindaysDestroyed.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.coindays, defaultActive: false }),
line({ metric: activity.coindaysDestroyed.sum._1w, name: "1w", color: colors.time._1w, unit: Unit.coindays, defaultActive: false }),
line({ metric: activity.coindaysDestroyed.sum._1m, name: "1m", color: colors.time._1m, unit: Unit.coindays, defaultActive: false }),
line({ metric: activity.coindaysDestroyed.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.coindays, defaultActive: false }),
line({ series: activity.coindaysDestroyed.base, name: "Base", color, unit: Unit.coindays }),
line({ series: activity.coindaysDestroyed.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.coindays, defaultActive: false }),
line({ series: activity.coindaysDestroyed.sum._1w, name: "1w", color: colors.time._1w, unit: Unit.coindays, defaultActive: false }),
line({ series: activity.coindaysDestroyed.sum._1m, name: "1m", color: colors.time._1m, unit: Unit.coindays, defaultActive: false }),
line({ series: activity.coindaysDestroyed.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.coindays, defaultActive: false }),
],
},
{
name: "Cumulative",
title: title("Cumulative Coindays Destroyed"),
bottom: [
line({ metric: activity.coindaysDestroyed.cumulative, name: "All-time", color, unit: Unit.coindays }),
line({ series: activity.coindaysDestroyed.cumulative, name: "All-time", color, unit: Unit.coindays }),
],
},
],
@@ -80,7 +80,7 @@ function volumeAndCoinsTree(activity, color, title) {
/**
* Sent in profit/loss breakdown tree (shared by full and mid-level activity)
* @param {Brk.BaseCumulativeInSumPattern} sent
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsTree}
*/
function sentProfitLossTree(sent, title) {
@@ -92,39 +92,39 @@ function sentProfitLossTree(sent, title) {
name: "USD",
title: title("Sent Volume In Profit"),
bottom: [
line({ metric: sent.inProfit.base.usd, name: "Base", color: colors.profit, unit: Unit.usd }),
line({ metric: sent.inProfit.sum._24h.usd, name: "24h", color: colors.time._24h, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inProfit.sum._1w.usd, name: "1w", color: colors.time._1w, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inProfit.sum._1m.usd, name: "1m", color: colors.time._1m, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inProfit.sum._1y.usd, name: "1y", color: colors.time._1y, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inProfit.base.usd, name: "Base", color: colors.profit, unit: Unit.usd }),
line({ series: sent.inProfit.sum._24h.usd, name: "24h", color: colors.time._24h, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inProfit.sum._1w.usd, name: "1w", color: colors.time._1w, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inProfit.sum._1m.usd, name: "1m", color: colors.time._1m, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inProfit.sum._1y.usd, name: "1y", color: colors.time._1y, unit: Unit.usd, defaultActive: false }),
],
},
{
name: "BTC",
title: title("Sent Volume In Profit (BTC)"),
bottom: [
line({ metric: sent.inProfit.base.btc, name: "Base", color: colors.profit, unit: Unit.btc }),
line({ metric: sent.inProfit.sum._24h.btc, name: "24h", color: colors.time._24h, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inProfit.sum._1w.btc, name: "1w", color: colors.time._1w, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inProfit.sum._1m.btc, name: "1m", color: colors.time._1m, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inProfit.sum._1y.btc, name: "1y", color: colors.time._1y, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inProfit.base.btc, name: "Base", color: colors.profit, unit: Unit.btc }),
line({ series: sent.inProfit.sum._24h.btc, name: "24h", color: colors.time._24h, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inProfit.sum._1w.btc, name: "1w", color: colors.time._1w, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inProfit.sum._1m.btc, name: "1m", color: colors.time._1m, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inProfit.sum._1y.btc, name: "1y", color: colors.time._1y, unit: Unit.btc, defaultActive: false }),
],
},
{
name: "Sats",
title: title("Sent Volume In Profit (Sats)"),
bottom: [
line({ metric: sent.inProfit.base.sats, name: "Base", color: colors.profit, unit: Unit.sats }),
line({ metric: sent.inProfit.sum._24h.sats, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inProfit.sum._1w.sats, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inProfit.sum._1m.sats, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inProfit.sum._1y.sats, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inProfit.base.sats, name: "Base", color: colors.profit, unit: Unit.sats }),
line({ series: sent.inProfit.sum._24h.sats, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inProfit.sum._1w.sats, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inProfit.sum._1m.sats, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inProfit.sum._1y.sats, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
],
},
{ name: "Cumulative", title: title("Cumulative Sent In Profit"), bottom: [
line({ metric: sent.inProfit.cumulative.usd, name: "USD", color: colors.profit, unit: Unit.usd }),
line({ metric: sent.inProfit.cumulative.btc, name: "BTC", color: colors.profit, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inProfit.cumulative.sats, name: "Sats", color: colors.profit, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inProfit.cumulative.usd, name: "USD", color: colors.profit, unit: Unit.usd }),
line({ series: sent.inProfit.cumulative.btc, name: "BTC", color: colors.profit, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inProfit.cumulative.sats, name: "Sats", color: colors.profit, unit: Unit.sats, defaultActive: false }),
]},
],
},
@@ -135,39 +135,39 @@ function sentProfitLossTree(sent, title) {
name: "USD",
title: title("Sent Volume In Loss"),
bottom: [
line({ metric: sent.inLoss.base.usd, name: "Base", color: colors.loss, unit: Unit.usd }),
line({ metric: sent.inLoss.sum._24h.usd, name: "24h", color: colors.time._24h, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inLoss.sum._1w.usd, name: "1w", color: colors.time._1w, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inLoss.sum._1m.usd, name: "1m", color: colors.time._1m, unit: Unit.usd, defaultActive: false }),
line({ metric: sent.inLoss.sum._1y.usd, name: "1y", color: colors.time._1y, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inLoss.base.usd, name: "Base", color: colors.loss, unit: Unit.usd }),
line({ series: sent.inLoss.sum._24h.usd, name: "24h", color: colors.time._24h, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inLoss.sum._1w.usd, name: "1w", color: colors.time._1w, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inLoss.sum._1m.usd, name: "1m", color: colors.time._1m, unit: Unit.usd, defaultActive: false }),
line({ series: sent.inLoss.sum._1y.usd, name: "1y", color: colors.time._1y, unit: Unit.usd, defaultActive: false }),
],
},
{
name: "BTC",
title: title("Sent Volume In Loss (BTC)"),
bottom: [
line({ metric: sent.inLoss.base.btc, name: "Base", color: colors.loss, unit: Unit.btc }),
line({ metric: sent.inLoss.sum._24h.btc, name: "24h", color: colors.time._24h, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inLoss.sum._1w.btc, name: "1w", color: colors.time._1w, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inLoss.sum._1m.btc, name: "1m", color: colors.time._1m, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inLoss.sum._1y.btc, name: "1y", color: colors.time._1y, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inLoss.base.btc, name: "Base", color: colors.loss, unit: Unit.btc }),
line({ series: sent.inLoss.sum._24h.btc, name: "24h", color: colors.time._24h, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inLoss.sum._1w.btc, name: "1w", color: colors.time._1w, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inLoss.sum._1m.btc, name: "1m", color: colors.time._1m, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inLoss.sum._1y.btc, name: "1y", color: colors.time._1y, unit: Unit.btc, defaultActive: false }),
],
},
{
name: "Sats",
title: title("Sent Volume In Loss (Sats)"),
bottom: [
line({ metric: sent.inLoss.base.sats, name: "Base", color: colors.loss, unit: Unit.sats }),
line({ metric: sent.inLoss.sum._24h.sats, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inLoss.sum._1w.sats, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inLoss.sum._1m.sats, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ metric: sent.inLoss.sum._1y.sats, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inLoss.base.sats, name: "Base", color: colors.loss, unit: Unit.sats }),
line({ series: sent.inLoss.sum._24h.sats, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inLoss.sum._1w.sats, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inLoss.sum._1m.sats, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inLoss.sum._1y.sats, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }),
],
},
{ name: "Cumulative", title: title("Cumulative Sent In Loss"), bottom: [
line({ metric: sent.inLoss.cumulative.usd, name: "USD", color: colors.loss, unit: Unit.usd }),
line({ metric: sent.inLoss.cumulative.btc, name: "BTC", color: colors.loss, unit: Unit.btc, defaultActive: false }),
line({ metric: sent.inLoss.cumulative.sats, name: "Sats", color: colors.loss, unit: Unit.sats, defaultActive: false }),
line({ series: sent.inLoss.cumulative.usd, name: "USD", color: colors.loss, unit: Unit.usd }),
line({ series: sent.inLoss.cumulative.btc, name: "BTC", color: colors.loss, unit: Unit.btc, defaultActive: false }),
line({ series: sent.inLoss.cumulative.sats, name: "Sats", color: colors.loss, unit: Unit.sats, defaultActive: false }),
]},
],
},
@@ -178,7 +178,7 @@ function sentProfitLossTree(sent, title) {
* Volume and coins tree with coinyears, dormancy, and sent in profit/loss (All/STH/LTH)
* @param {Brk.CoindaysCoinyearsDormancySentPattern} activity
* @param {Color} color
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsTree}
*/
function fullVolumeTree(activity, color, title) {
@@ -188,12 +188,12 @@ function fullVolumeTree(activity, color, title) {
{
name: "Coinyears Destroyed",
title: title("Coinyears Destroyed"),
bottom: [line({ metric: activity.coinyearsDestroyed, name: "CYD", color, unit: Unit.years })],
bottom: [line({ series: activity.coinyearsDestroyed, name: "CYD", color, unit: Unit.years })],
},
{
name: "Dormancy",
title: title("Dormancy"),
bottom: [line({ metric: activity.dormancy, name: "Dormancy", color, unit: Unit.days })],
bottom: [line({ series: activity.dormancy, name: "Dormancy", color, unit: Unit.days })],
},
];
}
@@ -204,7 +204,7 @@ function fullVolumeTree(activity, color, title) {
/**
* @param {Brk._1m1w1y24hPattern<number>} ratio
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @param {string} [prefix]
* @returns {PartialOptionsTree}
*/
@@ -214,31 +214,31 @@ function singleRollingSoprTree(ratio, title, prefix = "") {
name: "Compare",
title: title(`Rolling ${prefix}SOPR`),
bottom: [
baseline({ metric: ratio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio, base: 1 }),
baseline({ metric: ratio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio, base: 1 }),
baseline({ metric: ratio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio, base: 1 }),
baseline({ metric: ratio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio, base: 1 }),
baseline({ series: ratio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio, base: 1 }),
baseline({ series: ratio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio, base: 1 }),
baseline({ series: ratio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio, base: 1 }),
baseline({ series: ratio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio, base: 1 }),
],
},
{
name: "24h",
title: title(`${prefix}SOPR (24h)`),
bottom: [dotsBaseline({ metric: ratio._24h, name: "24h", unit: Unit.ratio, base: 1 })],
bottom: [dotsBaseline({ series: ratio._24h, name: "24h", unit: Unit.ratio, base: 1 })],
},
{
name: "7d",
title: title(`${prefix}SOPR (7d)`),
bottom: [baseline({ metric: ratio._1w, name: "SOPR", unit: Unit.ratio, base: 1 })],
bottom: [baseline({ series: ratio._1w, name: "SOPR", unit: Unit.ratio, base: 1 })],
},
{
name: "30d",
title: title(`${prefix}SOPR (30d)`),
bottom: [baseline({ metric: ratio._1m, name: "SOPR", unit: Unit.ratio, base: 1 })],
bottom: [baseline({ series: ratio._1m, name: "SOPR", unit: Unit.ratio, base: 1 })],
},
{
name: "1y",
title: title(`${prefix}SOPR (1y)`),
bottom: [baseline({ metric: ratio._1y, name: "SOPR", unit: Unit.ratio, base: 1 })],
bottom: [baseline({ series: ratio._1y, name: "SOPR", unit: Unit.ratio, base: 1 })],
},
];
}
@@ -249,7 +249,7 @@ function singleRollingSoprTree(ratio, title, prefix = "") {
/**
* @param {Brk._1m1w1y24hPattern6} sellSideRisk
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsTree}
*/
function singleSellSideRiskTree(sellSideRisk, title) {
@@ -294,7 +294,7 @@ function singleSellSideRiskTree(sellSideRisk, title) {
/**
* @param {Brk.BaseCumulativeSumPattern<number>} valueCreated
* @param {Brk.BaseCumulativeSumPattern<number>} valueDestroyed
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @param {string} [prefix]
* @returns {PartialOptionsTree}
*/
@@ -307,20 +307,20 @@ function singleRollingValueTree(valueCreated, valueDestroyed, title, prefix = ""
name: "Created",
title: title(`Rolling ${prefix}Value Created`),
bottom: [
line({ metric: valueCreated.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.usd }),
line({ metric: valueCreated.sum._1w, name: "7d", color: colors.time._1w, unit: Unit.usd }),
line({ metric: valueCreated.sum._1m, name: "30d", color: colors.time._1m, unit: Unit.usd }),
line({ metric: valueCreated.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.usd }),
line({ series: valueCreated.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.usd }),
line({ series: valueCreated.sum._1w, name: "7d", color: colors.time._1w, unit: Unit.usd }),
line({ series: valueCreated.sum._1m, name: "30d", color: colors.time._1m, unit: Unit.usd }),
line({ series: valueCreated.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.usd }),
],
},
{
name: "Destroyed",
title: title(`Rolling ${prefix}Value Destroyed`),
bottom: [
line({ metric: valueDestroyed.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1w, name: "7d", color: colors.time._1w, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1m, name: "30d", color: colors.time._1m, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.usd }),
line({ series: valueDestroyed.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1w, name: "7d", color: colors.time._1w, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1m, name: "30d", color: colors.time._1m, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.usd }),
],
},
],
@@ -329,40 +329,40 @@ function singleRollingValueTree(valueCreated, valueDestroyed, title, prefix = ""
name: "24h",
title: title(`${prefix}Value Created & Destroyed (24h)`),
bottom: [
line({ metric: valueCreated.sum._24h, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._24h, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.sum._24h, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.sum._24h, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "7d",
title: title(`${prefix}Value Created & Destroyed (7d)`),
bottom: [
line({ metric: valueCreated.sum._1w, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1w, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.sum._1w, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1w, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "30d",
title: title(`${prefix}Value Created & Destroyed (30d)`),
bottom: [
line({ metric: valueCreated.sum._1m, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1m, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.sum._1m, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1m, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "1y",
title: title(`${prefix}Value Created & Destroyed (1y)`),
bottom: [
line({ metric: valueCreated.sum._1y, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.sum._1y, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.sum._1y, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.sum._1y, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "Cumulative",
title: title(`${prefix}Value Created & Destroyed (Total)`),
bottom: [
line({ metric: valueCreated.cumulative, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.cumulative, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.cumulative, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.cumulative, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
];
@@ -374,12 +374,12 @@ function singleRollingValueTree(valueCreated, valueDestroyed, title, prefix = ""
* @param {Brk.BaseCapitulationCumulativeNegativeRelSumValuePattern} loss
* @param {Brk.BaseCumulativeSumPattern<number>} valueCreated
* @param {Brk.BaseCumulativeSumPattern<number>} valueDestroyed
* @param {AnyFetchedSeriesBlueprint[]} extraValueMetrics
* @param {AnyFetchedSeriesBlueprint[]} extraValueSeries
* @param {PartialOptionsTree} rollingTree
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
*/
function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValueMetrics, rollingTree, title) {
function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValueSeries, rollingTree, title) {
return {
name: "Value",
tree: [
@@ -387,17 +387,17 @@ function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValue
name: "Flows",
title: title("Profit & Capitulation Flows"),
bottom: [
line({ metric: profit.distributionFlow, name: "Distribution Flow", color: colors.profit, unit: Unit.usd }),
line({ metric: loss.capitulationFlow, name: "Capitulation Flow", color: colors.loss, unit: Unit.usd }),
line({ series: profit.distributionFlow, name: "Distribution Flow", color: colors.profit, unit: Unit.usd }),
line({ series: loss.capitulationFlow, name: "Capitulation Flow", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "Created & Destroyed",
title: title("Value Created & Destroyed"),
bottom: [
line({ metric: valueCreated.base, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
...extraValueMetrics,
line({ series: valueCreated.base, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
...extraValueSeries,
],
},
{
@@ -407,16 +407,16 @@ function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValue
name: "Profit",
title: title("Profit Value Created & Destroyed"),
bottom: [
line({ metric: profit.valueCreated.base, name: "Created", color: colors.profit, unit: Unit.usd }),
line({ metric: profit.valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: profit.valueCreated.base, name: "Created", color: colors.profit, unit: Unit.usd }),
line({ series: profit.valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
name: "Loss",
title: title("Loss Value Created & Destroyed"),
bottom: [
line({ metric: loss.valueCreated.base, name: "Created", color: colors.profit, unit: Unit.usd }),
line({ metric: loss.valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: loss.valueCreated.base, name: "Created", color: colors.profit, unit: Unit.usd }),
line({ series: loss.valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
],
@@ -430,7 +430,7 @@ function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValue
* Simple value section (created & destroyed + rolling)
* @param {Brk.BaseCumulativeSumPattern<number>} valueCreated
* @param {Brk.BaseCumulativeSumPattern<number>} valueDestroyed
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
*/
function simpleValueSection(valueCreated, valueDestroyed, title) {
@@ -441,8 +441,8 @@ function simpleValueSection(valueCreated, valueDestroyed, title) {
name: "Created & Destroyed",
title: title("Value Created & Destroyed"),
bottom: [
line({ metric: valueCreated.base, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ metric: valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
line({ series: valueCreated.base, name: "Created", color: colors.usd, unit: Unit.usd }),
line({ series: valueDestroyed.base, name: "Destroyed", color: colors.loss, unit: Unit.usd }),
],
},
{
@@ -459,7 +459,7 @@ function simpleValueSection(valueCreated, valueDestroyed, title) {
/**
* Full activity with adjusted SOPR (All/STH)
* @param {{ cohort: CohortAll | CohortFull, title: (metric: string) => string }} args
* @param {{ cohort: CohortAll | CohortFull, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createActivitySectionWithAdjusted({ cohort, title }) {
@@ -489,8 +489,8 @@ export function createActivitySectionWithAdjusted({ cohort, title }) {
r.profit, r.loss,
sopr.valueCreated, sopr.valueDestroyed,
[
line({ metric: sopr.adjusted.valueCreated.base, name: "Adjusted Created", color: colors.adjustedCreated, unit: Unit.usd, defaultActive: false }),
line({ metric: sopr.adjusted.valueDestroyed.base, name: "Adjusted Destroyed", color: colors.adjustedDestroyed, unit: Unit.usd, defaultActive: false }),
line({ series: sopr.adjusted.valueCreated.base, name: "Adjusted Created", color: colors.adjustedCreated, unit: Unit.usd, defaultActive: false }),
line({ series: sopr.adjusted.valueDestroyed.base, name: "Adjusted Destroyed", color: colors.adjustedDestroyed, unit: Unit.usd, defaultActive: false }),
],
[
{
@@ -510,7 +510,7 @@ export function createActivitySectionWithAdjusted({ cohort, title }) {
/**
* Activity section for cohorts with rolling SOPR + sell side risk (LTH, also CohortFull | CohortLongTerm)
* @param {{ cohort: CohortFull | CohortLongTerm, title: (metric: string) => string }} args
* @param {{ cohort: CohortFull | CohortLongTerm, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createActivitySection({ cohort, title }) {
@@ -540,7 +540,7 @@ export function createActivitySection({ cohort, title }) {
/**
* Activity section for cohorts with activity but basic realized (AgeRange/MaxAge — 24h SOPR only)
* @param {{ cohort: CohortAgeRange | CohortWithAdjusted, title: (metric: string) => string }} args
* @param {{ cohort: CohortAgeRange | CohortWithAdjusted, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createActivitySectionWithActivity({ cohort, title }) {
@@ -555,7 +555,7 @@ export function createActivitySectionWithActivity({ cohort, title }) {
{
name: "SOPR",
title: title("SOPR (24h)"),
bottom: [dotsBaseline({ metric: sopr.ratio._24h, name: "SOPR", unit: Unit.ratio, base: 1 })],
bottom: [dotsBaseline({ series: sopr.ratio._24h, name: "SOPR", unit: Unit.ratio, base: 1 })],
},
simpleValueSection(sopr.valueCreated, sopr.valueDestroyed, title),
],
@@ -564,7 +564,7 @@ export function createActivitySectionWithActivity({ cohort, title }) {
/**
* Minimal activity section for cohorts without activity field (value only)
* @param {{ cohort: CohortBasicWithMarketCap | CohortBasicWithoutMarketCap | CohortWithoutRelative | CohortAddress | AddressCohortObject, title: (metric: string) => string }} args
* @param {{ cohort: CohortBasicWithMarketCap | CohortBasicWithoutMarketCap | CohortWithoutRelative | CohortAddress | AddressCohortObject, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createActivitySectionMinimal({ cohort, title }) {
@@ -587,10 +587,10 @@ export function createActivitySectionMinimal({ cohort, title }) {
* @template {{ color: Color, name: string }} A
* @param {readonly T[]} list
* @param {A} all
* @param {(item: T | A) => AnyMetricPattern} getRaw
* @param {(item: T | A) => AnyMetricPattern} get7d
* @param {(item: T | A) => AnyMetricPattern} get30d
* @param {(metric: string) => string} title
* @param {(item: T | A) => AnySeriesPattern} getRaw
* @param {(item: T | A) => AnySeriesPattern} get7d
* @param {(item: T | A) => AnySeriesPattern} get30d
* @param {(name: string) => string} title
* @param {string} [prefix]
* @returns {PartialOptionsTree}
*/
@@ -600,21 +600,21 @@ function groupedSoprCharts(list, all, getRaw, get7d, get30d, title, prefix = "")
name: "Raw",
title: title(`${prefix}SOPR`),
bottom: mapCohortsWithAll(list, all, (item) =>
baseline({ metric: getRaw(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
baseline({ series: getRaw(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "7d",
title: title(`${prefix}SOPR (7d)`),
bottom: mapCohortsWithAll(list, all, (item) =>
baseline({ metric: get7d(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get7d(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "30d",
title: title(`${prefix}SOPR (30d)`),
bottom: mapCohortsWithAll(list, all, (item) =>
baseline({ metric: get30d(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get30d(item), name: item.name, color: item.color, unit: Unit.ratio, base: 1 }),
),
},
];
@@ -625,11 +625,11 @@ function groupedSoprCharts(list, all, getRaw, get7d, get30d, title, prefix = "")
* @template {{ color: Color, name: string }} A
* @param {readonly T[]} list
* @param {A} all
* @param {(item: T | A) => AnyMetricPattern} get24h
* @param {(item: T | A) => AnyMetricPattern} get7d
* @param {(item: T | A) => AnyMetricPattern} get30d
* @param {(item: T | A) => AnyMetricPattern} get1y
* @param {(metric: string) => string} title
* @param {(item: T | A) => AnySeriesPattern} get24h
* @param {(item: T | A) => AnySeriesPattern} get7d
* @param {(item: T | A) => AnySeriesPattern} get30d
* @param {(item: T | A) => AnySeriesPattern} get1y
* @param {(name: string) => string} title
* @param {string} [prefix]
* @returns {PartialOptionsTree}
*/
@@ -639,28 +639,28 @@ function groupedRollingSoprCharts(list, all, get24h, get7d, get30d, get1y, title
name: "24h",
title: title(`${prefix}SOPR (24h)`),
bottom: mapCohortsWithAll(list, all, (c) =>
baseline({ metric: get24h(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get24h(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "7d",
title: title(`${prefix}SOPR (7d)`),
bottom: mapCohortsWithAll(list, all, (c) =>
baseline({ metric: get7d(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get7d(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "30d",
title: title(`${prefix}SOPR (30d)`),
bottom: mapCohortsWithAll(list, all, (c) =>
baseline({ metric: get30d(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get30d(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "1y",
title: title(`${prefix}SOPR (1y)`),
bottom: mapCohortsWithAll(list, all, (c) =>
baseline({ metric: get1y(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
baseline({ series: get1y(c), name: c.name, color: c.color, unit: Unit.ratio, base: 1 }),
),
},
];
@@ -675,8 +675,8 @@ function groupedRollingSoprCharts(list, all, get24h, get7d, get30d, get1y, title
* @template {{ color: Color, name: string }} A
* @param {readonly T[]} list
* @param {A} all
* @param {readonly { name: string, getCreated: (item: T | A) => AnyMetricPattern, getDestroyed: (item: T | A) => AnyMetricPattern }[]} windows
* @param {(metric: string) => string} title
* @param {readonly { name: string, getCreated: (item: T | A) => AnySeriesPattern, getDestroyed: (item: T | A) => AnySeriesPattern }[]} windows
* @param {(name: string) => string} title
* @param {string} [prefix]
* @returns {PartialOptionsTree}
*/
@@ -688,7 +688,7 @@ function groupedRollingValueCharts(list, all, windows, title, prefix = "") {
name: w.name,
title: title(`${prefix}Value Created (${w.name})`),
bottom: mapCohortsWithAll(list, all, (item) =>
line({ metric: w.getCreated(item), name: item.name, color: item.color, unit: Unit.usd }),
line({ series: w.getCreated(item), name: item.name, color: item.color, unit: Unit.usd }),
),
})),
},
@@ -698,7 +698,7 @@ function groupedRollingValueCharts(list, all, windows, title, prefix = "") {
name: w.name,
title: title(`${prefix}Value Destroyed (${w.name})`),
bottom: mapCohortsWithAll(list, all, (item) =>
line({ metric: w.getDestroyed(item), name: item.name, color: item.color, unit: Unit.usd }),
line({ series: w.getDestroyed(item), name: item.name, color: item.color, unit: Unit.usd }),
),
})),
},
@@ -723,7 +723,7 @@ function valueWindows(list, all) {
// ============================================================================
/**
* @param {{ list: readonly CohortFull[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly CohortFull[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
@@ -734,7 +734,7 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
name: "Volume",
title: title("Sent Volume"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
]),
},
{
@@ -793,10 +793,10 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
{
name: "Sell Side Risk",
tree: [
{ name: "24h", title: title("Sell Side Risk (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._24h.ratio, name, color, unit: Unit.ratio })) },
{ name: "7d", title: title("Sell Side Risk (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1w.ratio, name, color, unit: Unit.ratio })) },
{ name: "30d", title: title("Sell Side Risk (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1m.ratio, name, color, unit: Unit.ratio })) },
{ name: "1y", title: title("Sell Side Risk (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1y.ratio, name, color, unit: Unit.ratio })) },
{ name: "24h", title: title("Sell Side Risk (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._24h.ratio, name, color, unit: Unit.ratio })) },
{ name: "7d", title: title("Sell Side Risk (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1w.ratio, name, color, unit: Unit.ratio })) },
{ name: "30d", title: title("Sell Side Risk (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1m.ratio, name, color, unit: Unit.ratio })) },
{ name: "1y", title: title("Sell Side Risk (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1y.ratio, name, color, unit: Unit.ratio })) },
],
},
{
@@ -805,12 +805,12 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
{
name: "Flows",
tree: [
{ name: "Distribution", title: title("Distribution Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.profit.distributionFlow, name, color, unit: Unit.usd })) },
{ name: "Capitulation", title: title("Capitulation Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.loss.capitulationFlow, name, color, unit: Unit.usd })) },
{ name: "Distribution", title: title("Distribution Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.profit.distributionFlow, name, color, unit: Unit.usd })) },
{ name: "Capitulation", title: title("Capitulation Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.loss.capitulationFlow, name, color, unit: Unit.usd })) },
],
},
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{
name: "Rolling",
tree: [
@@ -840,7 +840,7 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
name: "Coins Destroyed",
title: title("Coindays Destroyed"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
line({ series: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
]),
},
],
@@ -849,7 +849,7 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) {
/**
* Grouped activity for cohorts with rolling SOPR + sell side risk (LTH-like)
* @param {{ list: readonly (CohortFull | CohortLongTerm)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortFull | CohortLongTerm)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedActivitySection({ list, all, title }) {
@@ -860,7 +860,7 @@ export function createGroupedActivitySection({ list, all, title }) {
name: "Volume",
title: title("Sent Volume"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
]),
},
{
@@ -889,10 +889,10 @@ export function createGroupedActivitySection({ list, all, title }) {
{
name: "Sell Side Risk",
tree: [
{ name: "24h", title: title("Sell Side Risk (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._24h.ratio, name, color, unit: Unit.ratio })) },
{ name: "7d", title: title("Sell Side Risk (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1w.ratio, name, color, unit: Unit.ratio })) },
{ name: "30d", title: title("Sell Side Risk (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1m.ratio, name, color, unit: Unit.ratio })) },
{ name: "1y", title: title("Sell Side Risk (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sellSideRiskRatio._1y.ratio, name, color, unit: Unit.ratio })) },
{ name: "24h", title: title("Sell Side Risk (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._24h.ratio, name, color, unit: Unit.ratio })) },
{ name: "7d", title: title("Sell Side Risk (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1w.ratio, name, color, unit: Unit.ratio })) },
{ name: "30d", title: title("Sell Side Risk (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1m.ratio, name, color, unit: Unit.ratio })) },
{ name: "1y", title: title("Sell Side Risk (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sellSideRiskRatio._1y.ratio, name, color, unit: Unit.ratio })) },
],
},
{
@@ -901,12 +901,12 @@ export function createGroupedActivitySection({ list, all, title }) {
{
name: "Flows",
tree: [
{ name: "Distribution", title: title("Distribution Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.profit.distributionFlow, name, color, unit: Unit.usd })) },
{ name: "Capitulation", title: title("Capitulation Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.loss.capitulationFlow, name, color, unit: Unit.usd })) },
{ name: "Distribution", title: title("Distribution Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.profit.distributionFlow, name, color, unit: Unit.usd })) },
{ name: "Capitulation", title: title("Capitulation Flow"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.loss.capitulationFlow, name, color, unit: Unit.usd })) },
],
},
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{
name: "Rolling",
tree: groupedRollingValueCharts(list, all, valueWindows(list, all), title),
@@ -917,7 +917,7 @@ export function createGroupedActivitySection({ list, all, title }) {
name: "Coins Destroyed",
title: title("Coindays Destroyed"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
line({ series: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
]),
},
],
@@ -926,7 +926,7 @@ export function createGroupedActivitySection({ list, all, title }) {
/**
* Grouped activity for cohorts with activity but basic realized (AgeRange/MaxAge)
* @param {{ list: readonly (CohortAgeRange | CohortWithAdjusted)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortAgeRange | CohortWithAdjusted)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedActivitySectionWithActivity({ list, all, title }) {
@@ -937,28 +937,28 @@ export function createGroupedActivitySectionWithActivity({ list, all, title }) {
name: "Volume",
title: title("Sent Volume"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }),
]),
},
{
name: "SOPR",
title: title("SOPR (24h)"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({ metric: tree.realized.sopr.ratio._24h, name, color, unit: Unit.ratio, base: 1 }),
baseline({ series: tree.realized.sopr.ratio._24h, name, color, unit: Unit.ratio, base: 1 }),
),
},
{
name: "Value",
tree: [
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{ name: "Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
],
},
{
name: "Coins Destroyed",
title: title("Coindays Destroyed"),
bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [
line({ metric: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
line({ series: tree.activity.coindaysDestroyed.sum._24h, name, color, unit: Unit.coindays }),
]),
},
],
@@ -967,15 +967,15 @@ export function createGroupedActivitySectionWithActivity({ list, all, title }) {
/**
* Grouped minimal activity (value only, no activity field)
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative | CohortAddress | AddressCohortObject)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative | CohortAddress | AddressCohortObject)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedActivitySectionMinimal({ list, all, title }) {
return {
name: "Activity",
tree: [
{ name: "Value Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Value Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ metric: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
{ name: "Value Created", title: title("Value Created"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueCreated.base, name, color, unit: Unit.usd })) },
{ name: "Value Destroyed", title: title("Value Destroyed"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ series: tree.realized.sopr.valueDestroyed.base, name, color, unit: Unit.usd })) },
],
};
}
@@ -27,9 +27,9 @@ const ACTIVE_PCTS = new Set(["pct75", "pct50", "pct25"]);
function createCorePercentileSeries(p, n = (x) => x) {
return entries(p)
.reverse()
.map(([key, metric], i, arr) =>
.map(([key, s], i, arr) =>
price({
metric,
series: s,
name: n(key.replace("pct", "p")),
color: colors.at(i, arr.length),
...(ACTIVE_PCTS.has(key) ? {} : { defaultActive: false }),
@@ -45,28 +45,28 @@ function createSingleSummarySeries(cohort) {
const { color, tree } = cohort;
const p = tree.costBasis.percentiles;
return [
price({ metric: tree.realized.price, name: "Average", color }),
price({ series: tree.realized.price, name: "Average", color }),
price({
metric: tree.costBasis.max,
series: tree.costBasis.max,
name: "Max (p100)",
color: colors.stat.max,
defaultActive: false,
}),
price({
metric: p.pct75,
series: p.pct75,
name: "Q3 (p75)",
color: colors.stat.pct75,
defaultActive: false,
}),
price({ metric: p.pct50, name: "Median (p50)", color: colors.stat.median }),
price({ series: p.pct50, name: "Median (p50)", color: colors.stat.median }),
price({
metric: p.pct25,
series: p.pct25,
name: "Q1 (p25)",
color: colors.stat.pct25,
defaultActive: false,
}),
price({
metric: tree.costBasis.min,
series: tree.costBasis.min,
name: "Min (p0)",
color: colors.stat.min,
defaultActive: false,
@@ -81,7 +81,7 @@ function createSingleSummarySeries(cohort) {
*/
function createGroupedSummarySeries(list, all) {
return mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.realized.price, name, color }),
price({ series: tree.realized.price, name, color }),
);
}
@@ -93,16 +93,16 @@ function createSingleByCoinSeries(cohort) {
const { color, tree } = cohort;
const cb = tree.costBasis;
return [
price({ metric: tree.realized.price, name: "Average", color }),
price({ series: tree.realized.price, name: "Average", color }),
price({
metric: cb.max,
series: cb.max,
name: "p100",
color: colors.stat.max,
defaultActive: false,
}),
...createCorePercentileSeries(cb.percentiles),
price({
metric: cb.min,
series: cb.min,
name: "p0",
color: colors.stat.min,
defaultActive: false,
@@ -117,7 +117,7 @@ function createSingleByCoinSeries(cohort) {
function createSingleByCapitalSeries(cohort) {
const { color, tree } = cohort;
return [
price({ metric: tree.realized.investor.price, name: "Average", color }),
price({ series: tree.realized.investor.price, name: "Average", color }),
...createCorePercentileSeries(tree.costBasis.investedCapital),
];
}
@@ -139,7 +139,7 @@ function createSingleSupplyDensitySeries(cohort) {
}
/**
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (metric: string) => string }} args
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createCostBasisSectionWithPercentiles({ cohort, title }) {
@@ -171,7 +171,7 @@ export function createCostBasisSectionWithPercentiles({ cohort, title }) {
}
/**
* @param {{ list: readonly (CohortAll | CohortFull | CohortLongTerm)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortAll | CohortFull | CohortLongTerm)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedCostBasisSectionWithPercentiles({
@@ -194,28 +194,28 @@ export function createGroupedCostBasisSectionWithPercentiles({
name: "Average",
title: title("Realized Price Comparison"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.realized.price, name, color }),
price({ series: tree.realized.price, name, color }),
),
},
{
name: "Median",
title: title("Cost Basis Median (BTC-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.costBasis.percentiles.pct50, name, color }),
price({ series: tree.costBasis.percentiles.pct50, name, color }),
),
},
{
name: "Q3",
title: title("Cost Basis Q3 (BTC-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.costBasis.percentiles.pct75, name, color }),
price({ series: tree.costBasis.percentiles.pct75, name, color }),
),
},
{
name: "Q1",
title: title("Cost Basis Q1 (BTC-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.costBasis.percentiles.pct25, name, color }),
price({ series: tree.costBasis.percentiles.pct25, name, color }),
),
},
],
@@ -227,7 +227,7 @@ export function createGroupedCostBasisSectionWithPercentiles({
name: "Average",
title: title("Investor Price Comparison"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.realized.investor.price, name, color }),
price({ series: tree.realized.investor.price, name, color }),
),
},
{
@@ -235,7 +235,7 @@ export function createGroupedCostBasisSectionWithPercentiles({
title: title("Cost Basis Median (USD-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({
metric: tree.costBasis.investedCapital.pct50,
series: tree.costBasis.investedCapital.pct50,
name,
color,
}),
@@ -246,7 +246,7 @@ export function createGroupedCostBasisSectionWithPercentiles({
title: title("Cost Basis Q3 (USD-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({
metric: tree.costBasis.investedCapital.pct75,
series: tree.costBasis.investedCapital.pct75,
name,
color,
}),
@@ -257,7 +257,7 @@ export function createGroupedCostBasisSectionWithPercentiles({
title: title("Cost Basis Q1 (USD-weighted)"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({
metric: tree.costBasis.investedCapital.pct25,
series: tree.costBasis.investedCapital.pct25,
name,
color,
}),
+3 -3
View File
@@ -19,9 +19,9 @@ const isAddressable = (key) =>
/** @type {readonly string[]} */ (ADDRESSABLE_TYPES).includes(key);
export function buildCohortData() {
const utxoCohorts = brk.metrics.cohorts.utxo;
const addressCohorts = brk.metrics.cohorts.address;
const { addresses } = brk.metrics;
const utxoCohorts = brk.series.cohorts.utxo;
const addressCohorts = brk.series.cohorts.address;
const { addresses } = brk.series;
const {
TERM_NAMES,
EPOCH_NAMES,
@@ -3,7 +3,7 @@
*
* Supply pattern capabilities by cohort type:
* - DeltaHalfInRelTotalPattern2 (STH/LTH): inProfit + inLoss + relToCirculating + relToOwn
* - MetricsTree_Cohorts_Utxo_All_Supply (All): inProfit + inLoss + relToOwn (no relToCirculating)
* - SeriesTree_Cohorts_Utxo_All_Supply (All): inProfit + inLoss + relToOwn (no relToCirculating)
* - DeltaHalfInRelTotalPattern (AgeRange/MaxAge/Epoch): inProfit + inLoss + relToCirculating (no relToOwn)
* - DeltaHalfInTotalPattern2 (Type.*): inProfit + inLoss (no rel)
* - DeltaHalfTotalPattern (Empty/UtxoAmount/AddrAmount): total + half only
@@ -74,40 +74,40 @@ function fullSupplySeries(supply) {
/**
* % of Own Supply series (profit/loss relative to own supply)
* @param {{ inProfit: { relToOwn: { percent: AnyMetricPattern, ratio: AnyMetricPattern } }, inLoss: { relToOwn: { percent: AnyMetricPattern, ratio: AnyMetricPattern } } }} supply
* @param {{ inProfit: { relToOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } }, inLoss: { relToOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } } }} supply
* @returns {AnyFetchedSeriesBlueprint[]}
*/
function ownSupplyPctSeries(supply) {
return [
line({ metric: supply.inProfit.relToOwn.percent, name: "In Profit", color: colors.profit, unit: Unit.pctOwn }),
line({ metric: supply.inLoss.relToOwn.percent, name: "In Loss", color: colors.loss, unit: Unit.pctOwn }),
line({ metric: supply.inProfit.relToOwn.ratio, name: "In Profit", color: colors.profit, unit: Unit.ratio }),
line({ metric: supply.inLoss.relToOwn.ratio, name: "In Loss", color: colors.loss, unit: Unit.ratio }),
line({ series: supply.inProfit.relToOwn.percent, name: "In Profit", color: colors.profit, unit: Unit.pctOwn }),
line({ series: supply.inLoss.relToOwn.percent, name: "In Loss", color: colors.loss, unit: Unit.pctOwn }),
line({ series: supply.inProfit.relToOwn.ratio, name: "In Profit", color: colors.profit, unit: Unit.ratio }),
line({ series: supply.inLoss.relToOwn.ratio, name: "In Loss", color: colors.loss, unit: Unit.ratio }),
...priceLines({ numbers: [100, 50, 0], unit: Unit.pctOwn }),
];
}
/**
* % of Circulating Supply series (total, profit, loss)
* @param {{ relToCirculating: { percent: AnyMetricPattern }, inProfit: { relToCirculating: { percent: AnyMetricPattern } }, inLoss: { relToCirculating: { percent: AnyMetricPattern } } }} supply
* @param {{ relToCirculating: { percent: AnySeriesPattern }, inProfit: { relToCirculating: { percent: AnySeriesPattern } }, inLoss: { relToCirculating: { percent: AnySeriesPattern } } }} supply
* @returns {AnyFetchedSeriesBlueprint[]}
*/
function circulatingSupplyPctSeries(supply) {
return [
line({
metric: supply.relToCirculating.percent,
series: supply.relToCirculating.percent,
name: "Total",
color: colors.default,
unit: Unit.pctSupply,
}),
line({
metric: supply.inProfit.relToCirculating.percent,
series: supply.inProfit.relToCirculating.percent,
name: "In Profit",
color: colors.profit,
unit: Unit.pctSupply,
}),
line({
metric: supply.inLoss.relToCirculating.percent,
series: supply.inLoss.relToCirculating.percent,
name: "In Loss",
color: colors.loss,
unit: Unit.pctSupply,
@@ -117,25 +117,25 @@ function circulatingSupplyPctSeries(supply) {
/**
* Ratio of Circulating Supply series (total, profit, loss)
* @param {{ relToCirculating: { ratio: AnyMetricPattern }, inProfit: { relToCirculating: { ratio: AnyMetricPattern } }, inLoss: { relToCirculating: { ratio: AnyMetricPattern } } }} supply
* @param {{ relToCirculating: { ratio: AnySeriesPattern }, inProfit: { relToCirculating: { ratio: AnySeriesPattern } }, inLoss: { relToCirculating: { ratio: AnySeriesPattern } } }} supply
* @returns {AnyFetchedSeriesBlueprint[]}
*/
function circulatingSupplyRatioSeries(supply) {
return [
line({
metric: supply.relToCirculating.ratio,
series: supply.relToCirculating.ratio,
name: "Total",
color: colors.default,
unit: Unit.ratio,
}),
line({
metric: supply.inProfit.relToCirculating.ratio,
series: supply.inProfit.relToCirculating.ratio,
name: "In Profit",
color: colors.profit,
unit: Unit.ratio,
}),
line({
metric: supply.inLoss.relToCirculating.ratio,
series: supply.inLoss.relToCirculating.ratio,
name: "In Loss",
color: colors.loss,
unit: Unit.ratio,
@@ -146,7 +146,7 @@ function circulatingSupplyRatioSeries(supply) {
/**
* @param {readonly (UtxoCohortObject | CohortWithoutRelative)[]} list
* @param {CohortAll} all
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
*/
function groupedUtxoCountChart(list, all, title) {
return {
@@ -154,7 +154,7 @@ function groupedUtxoCountChart(list, all, title) {
title: title("UTXO Count"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({
metric: tree.outputs.unspentCount.inner,
series: tree.outputs.unspentCount.inner,
name,
color,
unit: Unit.count,
@@ -164,9 +164,9 @@ function groupedUtxoCountChart(list, all, title) {
}
/**
* @param {{ absolute: { _24h: AnyMetricPattern, _1w: AnyMetricPattern, _1m: AnyMetricPattern, _1y: AnyMetricPattern }, rate: { _24h: { percent: AnyMetricPattern, ratio: AnyMetricPattern }, _1w: { percent: AnyMetricPattern, ratio: AnyMetricPattern }, _1m: { percent: AnyMetricPattern, ratio: AnyMetricPattern }, _1y: { percent: AnyMetricPattern, ratio: AnyMetricPattern } } }} delta
* @param {{ absolute: { _24h: AnySeriesPattern, _1w: AnySeriesPattern, _1m: AnySeriesPattern, _1y: AnySeriesPattern }, rate: { _24h: { percent: AnySeriesPattern, ratio: AnySeriesPattern }, _1w: { percent: AnySeriesPattern, ratio: AnySeriesPattern }, _1m: { percent: AnySeriesPattern, ratio: AnySeriesPattern }, _1y: { percent: AnySeriesPattern, ratio: AnySeriesPattern } } }} delta
* @param {Unit} unit
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @param {string} name
* @returns {PartialOptionsGroup}
*/
@@ -187,7 +187,7 @@ function singleDeltaTree(delta, unit, title, name) {
* @param {A} all
* @param {(c: T | A) => DeltaPattern} getDelta
* @param {Unit} unit
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @param {string} name
* @returns {PartialOptionsGroup}
*/
@@ -201,7 +201,7 @@ function groupedDeltaTree(list, all, getDelta, unit, title, name) {
name: w.name,
title: title(`${name} Change (${w.name})`),
bottom: mapCohortsWithAll(list, all, (c) =>
baseline({ metric: getDelta(c).absolute[w.key], name: c.name, color: c.color, unit }),
baseline({ series: getDelta(c).absolute[w.key], name: c.name, color: c.color, unit }),
),
})),
},
@@ -221,7 +221,7 @@ function groupedDeltaTree(list, all, getDelta, unit, title, name) {
/**
* @param {UtxoCohortObject | CohortWithoutRelative} cohort
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialChartOption}
*/
function singleUtxoCountChart(cohort, title) {
@@ -230,7 +230,7 @@ function singleUtxoCountChart(cohort, title) {
title: title("UTXO Count"),
bottom: [
line({
metric: cohort.tree.outputs.unspentCount.inner,
series: cohort.tree.outputs.unspentCount.inner,
name: "UTXO Count",
color: cohort.color,
unit: Unit.count,
@@ -242,7 +242,7 @@ function singleUtxoCountChart(cohort, title) {
/**
* @param {CohortAll | CohortAddress | AddressCohortObject} cohort
* @param {(metric: string) => string} title
* @param {(name: string) => string} title
* @returns {PartialChartOption}
*/
function singleAddressCountChart(cohort, title) {
@@ -251,7 +251,7 @@ function singleAddressCountChart(cohort, title) {
title: title("Address Count"),
bottom: [
line({
metric: cohort.addressCount.inner,
series: cohort.addressCount.inner,
name: "Address Count",
color: cohort.color,
unit: Unit.count,
@@ -268,7 +268,7 @@ function singleAddressCountChart(cohort, title) {
/**
* Basic holdings (total + half only, no supply breakdown)
* For: CohortWithoutRelative, CohortBasicWithMarketCap, CohortBasicWithoutMarketCap
* @param {{ cohort: UtxoCohortObject | CohortWithoutRelative, title: (metric: string) => string }} args
* @param {{ cohort: UtxoCohortObject | CohortWithoutRelative, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSection({ cohort, title }) {
@@ -294,7 +294,7 @@ export function createHoldingsSection({ cohort, title }) {
/**
* Holdings for CohortAll (has inProfit/inLoss with relToOwn but no relToCirculating)
* @param {{ cohort: CohortAll, title: (metric: string) => string }} args
* @param {{ cohort: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionAll({ cohort, title }) {
@@ -325,9 +325,9 @@ export function createHoldingsSectionAll({ cohort, title }) {
}
/**
* Holdings with full relative metrics (relToCirculating + relToOwn)
* Holdings with full relative series (relToCirculating + relToOwn)
* For: CohortFull, CohortLongTerm (have DeltaHalfInRelTotalPattern2)
* @param {{ cohort: CohortFull | CohortLongTerm, title: (metric: string) => string }} args
* @param {{ cohort: CohortFull | CohortLongTerm, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionWithRelative({ cohort, title }) {
@@ -369,7 +369,7 @@ export function createHoldingsSectionWithRelative({ cohort, title }) {
/**
* Holdings with inProfit/inLoss + relToCirculating (no relToOwn)
* For: CohortWithAdjusted, CohortAgeRange (have DeltaHalfInRelTotalPattern)
* @param {{ cohort: CohortWithAdjusted | CohortAgeRange, title: (metric: string) => string }} args
* @param {{ cohort: CohortWithAdjusted | CohortAgeRange, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionWithOwnSupply({ cohort, title }) {
@@ -410,7 +410,7 @@ export function createHoldingsSectionWithOwnSupply({ cohort, title }) {
/**
* Holdings with inProfit/inLoss (no rel, no address count)
* For: CohortWithoutRelative (p2ms, unknown, empty)
* @param {{ cohort: CohortWithoutRelative, title: (metric: string) => string }} args
* @param {{ cohort: CohortWithoutRelative, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionWithProfitLoss({ cohort, title }) {
@@ -436,7 +436,7 @@ export function createHoldingsSectionWithProfitLoss({ cohort, title }) {
/**
* Holdings for CohortAddress (has inProfit/inLoss but no rel, plus address count)
* @param {{ cohort: CohortAddress, title: (metric: string) => string }} args
* @param {{ cohort: CohortAddress, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionAddress({ cohort, title }) {
@@ -464,7 +464,7 @@ export function createHoldingsSectionAddress({ cohort, title }) {
/**
* Holdings for address amount cohorts (no inProfit/inLoss, has address count)
* @param {{ cohort: AddressCohortObject, title: (metric: string) => string }} args
* @param {{ cohort: AddressCohortObject, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createHoldingsSectionAddressAmount({ cohort, title }) {
@@ -495,7 +495,7 @@ export function createHoldingsSectionAddressAmount({ cohort, title }) {
// ============================================================================
/**
* @param {{ list: readonly CohortAddress[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly CohortAddress[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSectionAddress({ list, all, title }) {
@@ -541,7 +541,7 @@ export function createGroupedHoldingsSectionAddress({ list, all, title }) {
name: "Address Count",
title: title("Address Count"),
bottom: mapCohortsWithAll(list, all, ({ name, color, addressCount }) =>
line({ metric: addressCount.inner, name, color, unit: Unit.count }),
line({ series: addressCount.inner, name, color, unit: Unit.count }),
),
},
{
@@ -558,7 +558,7 @@ export function createGroupedHoldingsSectionAddress({ list, all, title }) {
/**
* Grouped holdings for address amount cohorts (no inProfit/inLoss, has address count)
* @param {{ list: readonly AddressCohortObject[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly AddressCohortObject[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSectionAddressAmount({
@@ -586,7 +586,7 @@ export function createGroupedHoldingsSectionAddressAmount({
name: "Address Count",
title: title("Address Count"),
bottom: mapCohortsWithAll(list, all, ({ name, color, addressCount }) =>
line({ metric: addressCount.inner, name, color, unit: Unit.count }),
line({ series: addressCount.inner, name, color, unit: Unit.count }),
),
},
{
@@ -603,7 +603,7 @@ export function createGroupedHoldingsSectionAddressAmount({
/**
* Basic grouped holdings (total + half only)
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSection({ list, all, title }) {
@@ -637,7 +637,7 @@ export function createGroupedHoldingsSection({ list, all, title }) {
/**
* Grouped holdings with inProfit/inLoss (no rel, no address count)
* For: CohortWithoutRelative (p2ms, unknown, empty)
* @param {{ list: readonly CohortWithoutRelative[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly CohortWithoutRelative[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSectionWithProfitLoss({
@@ -697,7 +697,7 @@ export function createGroupedHoldingsSectionWithProfitLoss({
/**
* Grouped holdings with inProfit/inLoss + relToCirculating (no relToOwn)
* For: CohortWithAdjusted, CohortAgeRange
* @param {{ list: readonly (CohortWithAdjusted | CohortAgeRange)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortWithAdjusted | CohortAgeRange)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSectionWithOwnSupply({
@@ -720,7 +720,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.relToCirculating.percent,
series: tree.supply.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -741,7 +741,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.inProfit.relToCirculating.percent,
series: tree.supply.inProfit.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -762,7 +762,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.inLoss.relToCirculating.percent,
series: tree.supply.inLoss.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -785,9 +785,9 @@ export function createGroupedHoldingsSectionWithOwnSupply({
}
/**
* Grouped holdings with full relative metrics (relToCirculating + relToOwn)
* Grouped holdings with full relative series (relToCirculating + relToOwn)
* For: CohortFull, CohortLongTerm
* @param {{ list: readonly (CohortFull | CohortLongTerm)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortFull | CohortLongTerm)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
@@ -806,7 +806,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.relToCirculating.percent,
series: tree.supply.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -827,7 +827,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.inProfit.relToCirculating.percent,
series: tree.supply.inProfit.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -835,7 +835,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
),
...mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({
metric: tree.supply.inProfit.relToOwn.percent,
series: tree.supply.inProfit.relToOwn.percent,
name,
color,
unit: Unit.pctOwn,
@@ -857,7 +857,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
),
...mapCohorts(list, ({ name, color, tree }) =>
line({
metric: tree.supply.inLoss.relToCirculating.percent,
series: tree.supply.inLoss.relToCirculating.percent,
name,
color,
unit: Unit.pctSupply,
@@ -865,7 +865,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) {
),
...mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({
metric: tree.supply.inLoss.relToOwn.percent,
series: tree.supply.inLoss.relToOwn.percent,
name,
color,
unit: Unit.pctOwn,
+16 -24
View File
@@ -13,6 +13,7 @@
import { formatCohortTitle, satsBtcUsd, satsBtcUsdFullTree } from "../shared.js";
import { ROLLING_WINDOWS, line, baseline, percentRatio, rollingWindowsTree, rollingPercentRatioTree } from "../series.js";
import { Unit } from "../../utils/units.js";
import { colors } from "../../utils/colors.js";
// Section builders
import {
@@ -602,14 +603,12 @@ function singleBucketFolder({ name, color, pattern }) {
name: "Supply",
tree: [
{
name: "All",
name: "Value",
title: `${name}: Supply`,
bottom: satsBtcUsd({ pattern: pattern.supply.all, name, color }),
},
{
name: "STH",
title: `${name}: STH Supply`,
bottom: satsBtcUsd({ pattern: pattern.supply.sth, name, color }),
bottom: [
...satsBtcUsd({ pattern: pattern.supply.all, name: "Total" }),
...satsBtcUsd({ pattern: pattern.supply.sth, name: "STH", color: colors.term.short }),
],
},
{
name: "Change",
@@ -622,23 +621,16 @@ function singleBucketFolder({ name, color, pattern }) {
},
{
name: "Realized Cap",
tree: [
{
name: "All",
title: `${name}: Realized Cap`,
bottom: [line({ metric: pattern.realizedCap.all, name, color, unit: Unit.usd })],
},
{
name: "STH",
title: `${name}: STH Realized Cap`,
bottom: [line({ metric: pattern.realizedCap.sth, name, color, unit: Unit.usd })],
},
title: `${name}: Realized Cap`,
bottom: [
line({ series: pattern.realizedCap.all, name: "Total", unit: Unit.usd }),
line({ series: pattern.realizedCap.sth, name: "STH", color: colors.term.short, unit: Unit.usd }),
],
},
{
name: "NUPL",
title: `${name}: NUPL`,
bottom: [line({ metric: pattern.nupl.ratio, name, color, unit: Unit.ratio })],
bottom: [line({ series: pattern.nupl.ratio, name, color, unit: Unit.ratio })],
},
],
};
@@ -679,7 +671,7 @@ function groupedBucketCharts(list, titlePrefix) {
title: `${titlePrefix}: Supply Change`,
bottom: ROLLING_WINDOWS.flatMap((w) =>
list.map(({ name, color, pattern }) =>
baseline({ metric: pattern.supply.all.delta.absolute[w.key], name: `${name} ${w.name}`, color, unit: Unit.sats }),
baseline({ series: pattern.supply.all.delta.absolute[w.key], name: `${name} ${w.name}`, color, unit: Unit.sats }),
),
),
},
@@ -687,7 +679,7 @@ function groupedBucketCharts(list, titlePrefix) {
name: w.name,
title: `${titlePrefix}: Supply Change ${w.name}`,
bottom: list.map(({ name, color, pattern }) =>
baseline({ metric: pattern.supply.all.delta.absolute[w.key], name, color, unit: Unit.sats }),
baseline({ series: pattern.supply.all.delta.absolute[w.key], name, color, unit: Unit.sats }),
),
})),
],
@@ -724,14 +716,14 @@ function groupedBucketCharts(list, titlePrefix) {
name: "All",
title: `${titlePrefix}: Realized Cap`,
bottom: list.map(({ name, color, pattern }) =>
line({ metric: pattern.realizedCap.all, name, color, unit: Unit.usd }),
line({ series: pattern.realizedCap.all, name, color, unit: Unit.usd }),
),
},
{
name: "STH",
title: `${titlePrefix}: STH Realized Cap`,
bottom: list.map(({ name, color, pattern }) =>
line({ metric: pattern.realizedCap.sth, name, color, unit: Unit.usd }),
line({ series: pattern.realizedCap.sth, name, color, unit: Unit.usd }),
),
},
],
@@ -740,7 +732,7 @@ function groupedBucketCharts(list, titlePrefix) {
name: "NUPL",
title: `${titlePrefix}: NUPL`,
bottom: list.map(({ name, color, pattern }) =>
line({ metric: pattern.nupl.ratio, name, color, unit: Unit.ratio }),
line({ series: pattern.nupl.ratio, name, color, unit: Unit.ratio }),
),
},
];
+12 -12
View File
@@ -21,7 +21,7 @@ import { Unit } from "../../utils/units.js";
/**
* Create prices section for cohorts with full ratio patterns
* (CohortAll, CohortFull, CohortLongTerm)
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (metric: string) => string }} args
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createPricesSectionFull({ cohort, title }) {
@@ -33,10 +33,10 @@ export function createPricesSectionFull({ cohort, title }) {
name: "Compare",
title: title("Prices"),
top: [
price({ metric: tree.realized.price, name: "Realized", color: colors.realized }),
price({ metric: tree.realized.investor.price, name: "Investor", color: colors.investor }),
price({ metric: tree.realized.investor.upperPriceBand, name: "I²/R", color: colors.stat.max, style: 2, defaultActive: false }),
price({ metric: tree.realized.investor.lowerPriceBand, name: "R²/I", color: colors.stat.min, style: 2, defaultActive: false }),
price({ series: tree.realized.price, name: "Realized", color: colors.realized }),
price({ series: tree.realized.investor.price, name: "Investor", color: colors.investor }),
price({ series: tree.realized.investor.upperPriceBand, name: "I²/R", color: colors.stat.max, style: 2, defaultActive: false }),
price({ series: tree.realized.investor.lowerPriceBand, name: "R²/I", color: colors.stat.min, style: 2, defaultActive: false }),
],
},
{
@@ -67,7 +67,7 @@ export function createPricesSectionFull({ cohort, title }) {
/**
* Create prices section for cohorts with basic ratio patterns only
* (CohortWithAdjusted, CohortBasic, CohortAddress, CohortWithoutRelative)
* @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative | CohortAgeRange, title: (metric: string) => string }} args
* @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative | CohortAgeRange, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createPricesSectionBasic({ cohort, title }) {
@@ -81,14 +81,14 @@ export function createPricesSectionBasic({ cohort, title }) {
{
name: "Price",
title: title("Realized Price"),
top: [price({ metric: tree.realized.price, name: "Realized", color })],
top: [price({ series: tree.realized.price, name: "Realized", color })],
},
{
name: "MVRV",
title: title("MVRV"),
bottom: [
baseline({
metric: tree.realized.mvrv,
series: tree.realized.mvrv,
name: "MVRV",
unit: Unit.ratio,
base: 1,
@@ -100,7 +100,7 @@ export function createPricesSectionBasic({ cohort, title }) {
title: title("Realized Price Ratio"),
bottom: [
baseline({
metric: tree.realized.price.ratio,
series: tree.realized.price.ratio,
name: "Price Ratio",
unit: Unit.ratio,
base: 1,
@@ -115,7 +115,7 @@ export function createPricesSectionBasic({ cohort, title }) {
/**
* Create prices section for grouped cohorts
* @param {{ list: readonly CohortObject[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly CohortObject[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedPricesSection({ list, all, title }) {
@@ -129,7 +129,7 @@ export function createGroupedPricesSection({ list, all, title }) {
name: "Price",
title: title("Realized Price"),
top: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
price({ metric: tree.realized.price, name, color }),
price({ series: tree.realized.price, name, color }),
),
},
{
@@ -137,7 +137,7 @@ export function createGroupedPricesSection({ list, all, title }) {
title: title("MVRV"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({
metric: tree.realized.mvrv,
series: tree.realized.mvrv,
name,
color,
unit: Unit.ratio,
File diff suppressed because it is too large Load Diff
@@ -22,7 +22,7 @@ function createSingleRealizedCapSeries(cohort) {
const { color, tree } = cohort;
return [
line({
metric: tree.realized.cap.usd,
series: tree.realized.cap.usd,
name: "Realized Cap",
color,
unit: Unit.usd,
@@ -33,7 +33,7 @@ function createSingleRealizedCapSeries(cohort) {
/**
* Create valuation section for cohorts with full ratio patterns
* (CohortAll, CohortFull, CohortWithPercentiles)
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (metric: string) => string }} args
* @param {{ cohort: CohortAll | CohortFull | CohortLongTerm, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createValuationSectionFull({ cohort, title }) {
@@ -77,7 +77,7 @@ export function createValuationSectionFull({ cohort, title }) {
/**
* Create valuation section for cohorts with basic ratio patterns
* (CohortWithAdjusted, CohortBasic, CohortAddress, CohortWithoutRelative)
* @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative, title: (metric: string) => string }} args
* @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createValuationSection({ cohort, title }) {
@@ -102,7 +102,7 @@ export function createValuationSection({ cohort, title }) {
title: title("MVRV"),
bottom: [
baseline({
metric: tree.realized.mvrv,
series: tree.realized.mvrv,
name: "MVRV",
unit: Unit.ratio,
base: 1,
@@ -114,7 +114,7 @@ export function createValuationSection({ cohort, title }) {
}
/**
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedValuationSection({ list, all, title }) {
@@ -126,7 +126,7 @@ export function createGroupedValuationSection({ list, all, title }) {
title: title("Realized Cap"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({
metric: tree.realized.cap.usd,
series: tree.realized.cap.usd,
name,
color,
unit: Unit.usd,
@@ -142,7 +142,7 @@ export function createGroupedValuationSection({ list, all, title }) {
name: w.name,
title: title(`Realized Cap Change (${w.name})`),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({ metric: tree.realized.cap.delta.absolute[w.key].usd, name, color, unit: Unit.usd }),
baseline({ series: tree.realized.cap.delta.absolute[w.key].usd, name, color, unit: Unit.usd }),
),
})),
},
@@ -163,7 +163,7 @@ export function createGroupedValuationSection({ list, all, title }) {
title: title("MVRV"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({
metric: tree.realized.mvrv,
series: tree.realized.mvrv,
name,
color,
unit: Unit.ratio,
@@ -176,7 +176,7 @@ export function createGroupedValuationSection({ list, all, title }) {
}
/**
* @param {{ list: readonly (CohortAll | CohortFull | CohortLongTerm)[], all: CohortAll, title: (metric: string) => string }} args
* @param {{ list: readonly (CohortAll | CohortFull | CohortLongTerm)[], all: CohortAll, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createGroupedValuationSectionWithOwnMarketCap({
@@ -194,7 +194,7 @@ export function createGroupedValuationSectionWithOwnMarketCap({
name: "USD",
title: title("Realized Cap"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({ metric: tree.realized.cap.usd, name, color, unit: Unit.usd }),
line({ series: tree.realized.cap.usd, name, color, unit: Unit.usd }),
),
},
{
@@ -215,7 +215,7 @@ export function createGroupedValuationSectionWithOwnMarketCap({
name: w.name,
title: title(`Realized Cap Change (${w.name})`),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({ metric: tree.realized.cap.delta.absolute[w.key].usd, name, color, unit: Unit.usd }),
baseline({ series: tree.realized.cap.delta.absolute[w.key].usd, name, color, unit: Unit.usd }),
),
})),
},
@@ -236,7 +236,7 @@ export function createGroupedValuationSectionWithOwnMarketCap({
title: title("MVRV"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({
metric: tree.realized.mvrv,
series: tree.realized.mvrv,
name,
color,
unit: Unit.ratio,