mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { colors } from "../utils/colors.js";
|
||||
import { brk } from "../client.js";
|
||||
import { Unit } from "../utils/units.js";
|
||||
import { dots, line, baseline, price, rollingWindowsTree } from "./series.js";
|
||||
import { dots, line, baseline, price, rollingWindowsTree, percentRatioDots } from "./series.js";
|
||||
import { satsBtcUsd } from "./shared.js";
|
||||
|
||||
/**
|
||||
@@ -53,6 +53,26 @@ export function createCointimeSection() {
|
||||
name: "Cointime",
|
||||
color: colors.cointime,
|
||||
},
|
||||
{
|
||||
pattern: cointimePrices.transfer,
|
||||
name: "Transfer",
|
||||
color: colors.transfer,
|
||||
},
|
||||
{
|
||||
pattern: cointimePrices.balanced,
|
||||
name: "Balanced",
|
||||
color: colors.balanced,
|
||||
},
|
||||
{
|
||||
pattern: cointimePrices.terminal,
|
||||
name: "Terminal",
|
||||
color: colors.terminal,
|
||||
},
|
||||
{
|
||||
pattern: cointimePrices.delta,
|
||||
name: "Delta",
|
||||
color: colors.delta,
|
||||
},
|
||||
]);
|
||||
|
||||
const caps = /** @type {const} */ ([
|
||||
@@ -158,12 +178,16 @@ export function createCointimeSection() {
|
||||
const pctUsd = /** @type {const} */ ([
|
||||
{ name: "pct95", prop: p.pct95.price, color: colors.ratioPct._95 },
|
||||
{ name: "pct5", prop: p.pct5.price, color: colors.ratioPct._5 },
|
||||
{ name: "pct98", prop: p.pct98.price, color: colors.ratioPct._98 },
|
||||
{ name: "pct2", prop: p.pct2.price, color: colors.ratioPct._2 },
|
||||
{ name: "pct99", prop: p.pct99.price, color: colors.ratioPct._99 },
|
||||
{ name: "pct1", prop: p.pct1.price, color: colors.ratioPct._1 },
|
||||
]);
|
||||
const pctRatio = /** @type {const} */ ([
|
||||
{ name: "pct95", prop: p.pct95.ratio, color: colors.ratioPct._95 },
|
||||
{ name: "pct5", prop: p.pct5.ratio, color: colors.ratioPct._5 },
|
||||
{ name: "pct98", prop: p.pct98.ratio, color: colors.ratioPct._98 },
|
||||
{ name: "pct2", prop: p.pct2.ratio, color: colors.ratioPct._2 },
|
||||
{ name: "pct99", prop: p.pct99.ratio, color: colors.ratioPct._99 },
|
||||
{ name: "pct1", prop: p.pct1.ratio, color: colors.ratioPct._1 },
|
||||
]);
|
||||
@@ -463,6 +487,19 @@ export function createCointimeSection() {
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AVIV",
|
||||
title: "AVIV Ratio",
|
||||
bottom: [
|
||||
baseline({
|
||||
metric: cap.aviv.ratio,
|
||||
name: "Ratio",
|
||||
color: colors.reserveRisk,
|
||||
unit: Unit.ratio,
|
||||
base: 1,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "HODL Bank",
|
||||
title: "HODL Bank",
|
||||
@@ -492,11 +529,10 @@ export function createCointimeSection() {
|
||||
color: colors.base,
|
||||
unit: Unit.percentage,
|
||||
}),
|
||||
dots({
|
||||
metric: adjusted.inflationRate.percent,
|
||||
...percentRatioDots({
|
||||
pattern: adjusted.inflationRate,
|
||||
name: "Cointime-Adjusted",
|
||||
color: colors.adjusted,
|
||||
unit: Unit.percentage,
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -508,7 +544,7 @@ export function createCointimeSection() {
|
||||
title: "Cointime-Adjusted BTC Velocity",
|
||||
bottom: [
|
||||
line({
|
||||
metric: supply.velocity.btc,
|
||||
metric: supply.velocity.native,
|
||||
name: "Base",
|
||||
color: colors.base,
|
||||
unit: Unit.ratio,
|
||||
@@ -526,7 +562,7 @@ export function createCointimeSection() {
|
||||
title: "Cointime-Adjusted USD Velocity",
|
||||
bottom: [
|
||||
line({
|
||||
metric: supply.velocity.usd,
|
||||
metric: supply.velocity.fiat,
|
||||
name: "Base",
|
||||
color: colors.thermo,
|
||||
unit: Unit.ratio,
|
||||
|
||||
@@ -327,16 +327,16 @@ function singleRollingRealizedTreeFull(r, title) {
|
||||
name: "Compare",
|
||||
title: title("Rolling Realized P/L Ratio"),
|
||||
bottom: [
|
||||
baseline({ metric: r.profitToLossRatio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio }),
|
||||
baseline({ metric: r.profitToLossRatio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio }),
|
||||
baseline({ metric: r.profitToLossRatio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio }),
|
||||
baseline({ metric: r.profitToLossRatio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio }),
|
||||
baseline({ metric: r.profitToLossRatio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio, base: 1 }),
|
||||
baseline({ metric: r.profitToLossRatio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio, base: 1 }),
|
||||
baseline({ metric: r.profitToLossRatio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio, base: 1 }),
|
||||
baseline({ metric: r.profitToLossRatio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio, base: 1 }),
|
||||
],
|
||||
},
|
||||
{ name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: [baseline({ metric: r.profitToLossRatio._24h, name: "P/L Ratio", unit: Unit.ratio })] },
|
||||
{ name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: [baseline({ metric: r.profitToLossRatio._1w, name: "P/L Ratio", unit: Unit.ratio })] },
|
||||
{ name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: [baseline({ metric: r.profitToLossRatio._1m, name: "P/L Ratio", unit: Unit.ratio })] },
|
||||
{ name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio })] },
|
||||
{ name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: [baseline({ metric: r.profitToLossRatio._24h, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] },
|
||||
{ name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: [baseline({ metric: r.profitToLossRatio._1w, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] },
|
||||
{ name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: [baseline({ metric: r.profitToLossRatio._1m, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] },
|
||||
{ name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] },
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -397,7 +397,7 @@ function realizedSubfolderFull(r, title) {
|
||||
{
|
||||
name: "P/L Ratio",
|
||||
title: title("Realized Profit/Loss Ratio"),
|
||||
bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio })],
|
||||
bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio, base: 1 })],
|
||||
},
|
||||
{
|
||||
name: "Peak Regret",
|
||||
@@ -750,7 +750,7 @@ function groupedRealizedPnlSumFull(list, all, title) {
|
||||
name: "P/L Ratio",
|
||||
title: title("Realized Profit/Loss Ratio"),
|
||||
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
|
||||
baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio }),
|
||||
baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio, base: 1 }),
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -801,10 +801,10 @@ function groupedRollingRealizedChartsFull(list, all, title) {
|
||||
{
|
||||
name: "P/L Ratio",
|
||||
tree: [
|
||||
{ name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._24h, name, color, unit: Unit.ratio })) },
|
||||
{ name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1w, name, color, unit: Unit.ratio })) },
|
||||
{ name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1m, name, color, unit: Unit.ratio })) },
|
||||
{ name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio })) },
|
||||
{ name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._24h, name, color, unit: Unit.ratio, base: 1 })) },
|
||||
{ name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1w, name, color, unit: Unit.ratio, base: 1 })) },
|
||||
{ name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1m, name, color, unit: Unit.ratio, base: 1 })) },
|
||||
{ name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio, base: 1 })) },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
price,
|
||||
percentRatio,
|
||||
percentRatioBaseline,
|
||||
ROLLING_WINDOWS,
|
||||
} from "./series.js";
|
||||
import { periodIdToName } from "./utils.js";
|
||||
|
||||
@@ -996,98 +997,15 @@ export function createMarketSection() {
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "1 Day",
|
||||
title: "MACD (1d)",
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `MACD (${w.name})`,
|
||||
bottom: [
|
||||
line({
|
||||
metric: technical.macd._24h.line,
|
||||
name: "MACD",
|
||||
color: colors.indicator.fast,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
line({
|
||||
metric: technical.macd._24h.signal,
|
||||
name: "Signal",
|
||||
color: colors.indicator.slow,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
histogram({
|
||||
metric: technical.macd._24h.histogram,
|
||||
name: "Histogram",
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
line({ metric: technical.macd[w.key].line, name: "MACD", color: colors.indicator.fast, unit: Unit.usd }),
|
||||
line({ metric: technical.macd[w.key].signal, name: "Signal", color: colors.indicator.slow, unit: Unit.usd }),
|
||||
histogram({ metric: technical.macd[w.key].histogram, name: "Histogram", unit: Unit.usd }),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "1 Week",
|
||||
title: "MACD (1w)",
|
||||
bottom: [
|
||||
line({
|
||||
metric: technical.macd._1w.line,
|
||||
name: "MACD",
|
||||
color: colors.indicator.fast,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
line({
|
||||
metric: technical.macd._1w.signal,
|
||||
name: "Signal",
|
||||
color: colors.indicator.slow,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
histogram({
|
||||
metric: technical.macd._1w.histogram,
|
||||
name: "Histogram",
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "1 Month",
|
||||
title: "MACD (1m)",
|
||||
bottom: [
|
||||
line({
|
||||
metric: technical.macd._1m.line,
|
||||
name: "MACD",
|
||||
color: colors.indicator.fast,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
line({
|
||||
metric: technical.macd._1m.signal,
|
||||
name: "Signal",
|
||||
color: colors.indicator.slow,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
histogram({
|
||||
metric: technical.macd._1m.histogram,
|
||||
name: "Histogram",
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "1 Year",
|
||||
title: "MACD (1y)",
|
||||
bottom: [
|
||||
line({
|
||||
metric: technical.macd._1y.line,
|
||||
name: "MACD",
|
||||
color: colors.indicator.fast,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
line({
|
||||
metric: technical.macd._1y.signal,
|
||||
name: "Signal",
|
||||
color: colors.indicator.slow,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
histogram({
|
||||
metric: technical.macd._1y.histogram,
|
||||
name: "Histogram",
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
],
|
||||
},
|
||||
})),
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -133,6 +133,23 @@ export function createMiningSection() {
|
||||
name: "sum",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "Rolling",
|
||||
tree: [
|
||||
{
|
||||
name: "Compare",
|
||||
title: `Rewards: ${name} Rolling`,
|
||||
bottom: ROLLING_WINDOWS.flatMap((w) =>
|
||||
satsBtcUsd({ pattern: pool.rewards.sum[w.key], name: w.name, color: w.color }),
|
||||
),
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `Rewards: ${name} (${w.name})`,
|
||||
bottom: satsBtcUsd({ pattern: pool.rewards.sum[w.key], name: w.name, color: w.color }),
|
||||
})),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `Rewards: ${name} (Total)`,
|
||||
|
||||
@@ -819,12 +819,12 @@ export function createNetworkSection() {
|
||||
title: "Transaction Velocity",
|
||||
bottom: [
|
||||
line({
|
||||
metric: supply.velocity.btc,
|
||||
metric: supply.velocity.native,
|
||||
name: "BTC",
|
||||
unit: Unit.ratio,
|
||||
}),
|
||||
line({
|
||||
metric: supply.velocity.usd,
|
||||
metric: supply.velocity.fiat,
|
||||
name: "USD",
|
||||
color: colors.usd,
|
||||
unit: Unit.ratio,
|
||||
|
||||
Reference in New Issue
Block a user