mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-21 20:12:15 -07:00
global: snapshot
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
dots,
|
||||
line,
|
||||
price,
|
||||
sumsTree,
|
||||
sumsArray,
|
||||
multiSeriesTree,
|
||||
percentRatioDots,
|
||||
} from "./series.js";
|
||||
@@ -311,7 +311,7 @@ export function createCointimeSection() {
|
||||
}),
|
||||
],
|
||||
},
|
||||
sumsTree({ windows: pattern.sum, title, unit: Unit.coinblocks }),
|
||||
...sumsArray({ windows: pattern.sum, title, unit: Unit.coinblocks }),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
@@ -366,7 +366,7 @@ export function createCointimeSection() {
|
||||
line({ series: pattern.base, name, color, unit: Unit.usd }),
|
||||
],
|
||||
},
|
||||
sumsTree({ windows: pattern.sum, title, unit: Unit.usd }),
|
||||
...sumsArray({ windows: pattern.sum, title, unit: Unit.usd }),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
@@ -402,7 +402,7 @@ export function createCointimeSection() {
|
||||
}),
|
||||
],
|
||||
},
|
||||
sumsTree({
|
||||
...sumsArray({
|
||||
windows: vocdd.pattern.sum,
|
||||
title: vocdd.title,
|
||||
unit: Unit.usd,
|
||||
|
||||
@@ -44,7 +44,7 @@ export function buildCohortData() {
|
||||
color: colors.bitcoin,
|
||||
tree: utxoCohorts.all,
|
||||
addressCount: {
|
||||
inner: addrs.funded.all,
|
||||
base: addrs.funded.all,
|
||||
delta: addrs.delta.all,
|
||||
},
|
||||
};
|
||||
@@ -170,7 +170,7 @@ export function buildCohortData() {
|
||||
color: colors.at(i, arr.length),
|
||||
tree: utxoCohorts.type[key],
|
||||
addressCount: {
|
||||
inner: addrs.funded[key],
|
||||
base: addrs.funded[key],
|
||||
delta: addrs.delta[key],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -481,7 +481,14 @@ export function statsAtWindow(pattern, window) {
|
||||
* @param {(args: {series: AnySeriesPattern, name: string, color: Color, unit: Unit}) => AnyFetchedSeriesBlueprint} [args.series]
|
||||
* @returns {PartialOptionsGroup}
|
||||
*/
|
||||
function rollingWindowsTree({ windows, title, windowTitle, unit, name, series = line }) {
|
||||
function rollingWindowsTree({
|
||||
windows,
|
||||
title,
|
||||
windowTitle,
|
||||
unit,
|
||||
name,
|
||||
series = line,
|
||||
}) {
|
||||
return {
|
||||
name,
|
||||
tree: [
|
||||
@@ -514,7 +521,25 @@ function rollingWindowsTree({ windows, title, windowTitle, unit, name, series =
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolling sums tree
|
||||
* Flat array of rolling sum charts (one per window)
|
||||
* @param {Object} args
|
||||
* @param {{ _24h: AnySeriesPattern, _1w: AnySeriesPattern, _1m: AnySeriesPattern, _1y: AnySeriesPattern }} args.windows
|
||||
* @param {string} args.title
|
||||
* @param {Unit} args.unit
|
||||
* @returns {PartialChartOption[]}
|
||||
*/
|
||||
export function sumsArray({ windows, title, unit }) {
|
||||
return ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `${title} ${w.title} Sum`,
|
||||
bottom: [
|
||||
line({ series: windows[w.key], name: w.name, color: w.color, unit }),
|
||||
],
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolling sums tree (Compare + individual windows in a folder)
|
||||
* @param {Object} args
|
||||
* @param {{ _24h: AnySeriesPattern, _1w: AnySeriesPattern, _1m: AnySeriesPattern, _1y: AnySeriesPattern }} args.windows
|
||||
* @param {string} args.title
|
||||
@@ -523,7 +548,14 @@ function rollingWindowsTree({ windows, title, windowTitle, unit, name, series =
|
||||
* @returns {PartialOptionsGroup}
|
||||
*/
|
||||
export function sumsTree({ windows, title, unit, series }) {
|
||||
return rollingWindowsTree({ windows, title, windowTitle: (w) => `${title} ${w.title} Sum`, unit, name: "Sums", ...(series ? { series } : {}) });
|
||||
return rollingWindowsTree({
|
||||
windows,
|
||||
title,
|
||||
windowTitle: (w) => `${title} ${w.title} Sum`,
|
||||
unit,
|
||||
name: "Sums",
|
||||
...(series ? { series } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,7 +568,13 @@ export function sumsTree({ windows, title, unit, series }) {
|
||||
* @returns {PartialOptionsGroup}
|
||||
*/
|
||||
export function averagesTree({ windows, title, unit, name = "Averages" }) {
|
||||
return rollingWindowsTree({ windows, title, windowTitle: (w) => `${title} ${w.title} Average`, unit, name });
|
||||
return rollingWindowsTree({
|
||||
windows,
|
||||
title,
|
||||
windowTitle: (w) => `${title} ${w.title} Average`,
|
||||
unit,
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,7 +594,12 @@ export function distributionWindowsTree({ pattern, base, title, unit }) {
|
||||
name: "Compare",
|
||||
title: `${title} Average`,
|
||||
bottom: ROLLING_WINDOWS.map((w) =>
|
||||
line({ series: pattern.average[w.key], name: w.name, color: w.color, unit }),
|
||||
line({
|
||||
series: pattern.average[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
unit,
|
||||
}),
|
||||
),
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
@@ -658,8 +701,20 @@ export function fromSupplyPattern({ pattern, title, color }) {
|
||||
*/
|
||||
export function percentRatio({ pattern, name, color, defaultActive }) {
|
||||
return [
|
||||
line({ series: pattern.percent, name, color, defaultActive, unit: Unit.percentage }),
|
||||
line({ series: pattern.ratio, name, color, defaultActive, unit: Unit.ratio }),
|
||||
line({
|
||||
series: pattern.percent,
|
||||
name,
|
||||
color,
|
||||
defaultActive,
|
||||
unit: Unit.percentage,
|
||||
}),
|
||||
line({
|
||||
series: pattern.ratio,
|
||||
name,
|
||||
color,
|
||||
defaultActive,
|
||||
unit: Unit.ratio,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -674,8 +729,20 @@ export function percentRatio({ pattern, name, color, defaultActive }) {
|
||||
*/
|
||||
export function percentRatioDots({ pattern, name, color, defaultActive }) {
|
||||
return [
|
||||
dots({ series: pattern.percent, name, color, defaultActive, unit: Unit.percentage }),
|
||||
dots({ series: pattern.ratio, name, color, defaultActive, unit: Unit.ratio }),
|
||||
dots({
|
||||
series: pattern.percent,
|
||||
name,
|
||||
color,
|
||||
defaultActive,
|
||||
unit: Unit.percentage,
|
||||
}),
|
||||
dots({
|
||||
series: pattern.ratio,
|
||||
name,
|
||||
color,
|
||||
defaultActive,
|
||||
unit: Unit.ratio,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -690,7 +757,12 @@ export function percentRatioDots({ pattern, name, color, defaultActive }) {
|
||||
*/
|
||||
export function percentRatioBaseline({ pattern, name, defaultActive }) {
|
||||
return [
|
||||
baseline({ series: pattern.percent, name, defaultActive, unit: Unit.percentage }),
|
||||
baseline({
|
||||
series: pattern.percent,
|
||||
name,
|
||||
defaultActive,
|
||||
unit: Unit.percentage,
|
||||
}),
|
||||
baseline({ series: pattern.ratio, name, defaultActive, unit: Unit.ratio }),
|
||||
];
|
||||
}
|
||||
@@ -704,7 +776,12 @@ export function percentRatioBaseline({ pattern, name, defaultActive }) {
|
||||
* @param {(args: {pattern: { percent: AnySeriesPattern, ratio: AnySeriesPattern }, name: string, color?: Color}) => AnyFetchedSeriesBlueprint[]} [args.series]
|
||||
* @returns {PartialOptionsGroup}
|
||||
*/
|
||||
export function rollingPercentRatioTree({ windows, title, name = "Sums", series = percentRatio }) {
|
||||
export function rollingPercentRatioTree({
|
||||
windows,
|
||||
title,
|
||||
name = "Sums",
|
||||
series = percentRatio,
|
||||
}) {
|
||||
return {
|
||||
name,
|
||||
tree: [
|
||||
@@ -712,7 +789,11 @@ export function rollingPercentRatioTree({ windows, title, name = "Sums", series
|
||||
name: "Compare",
|
||||
title: `${title} Rolling`,
|
||||
bottom: ROLLING_WINDOWS.flatMap((w) =>
|
||||
percentRatio({ pattern: windows[w.key], name: w.name, color: w.color }),
|
||||
percentRatio({
|
||||
pattern: windows[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
}),
|
||||
),
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
@@ -764,7 +845,12 @@ export function deltaTree({ delta, title, unit, extract }) {
|
||||
})),
|
||||
],
|
||||
},
|
||||
rollingPercentRatioTree({ windows: delta.rate, title: `${title} Growth Rate`, name: "Growth Rate", series: percentRatioBaseline }),
|
||||
rollingPercentRatioTree({
|
||||
windows: delta.rate,
|
||||
title: `${title} Growth Rate`,
|
||||
name: "Growth Rate",
|
||||
series: percentRatioBaseline,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -785,7 +871,6 @@ export function simpleDeltaTree({ delta, title, unit }) {
|
||||
// ============================================================================
|
||||
// These split patterns into separate Sum/Distribution/Cumulative charts
|
||||
|
||||
|
||||
/**
|
||||
* Create btc/sats/usd series from patterns
|
||||
* @param {Object} args
|
||||
@@ -870,7 +955,7 @@ export const chartsFromFullPerBlock = (args) =>
|
||||
/**
|
||||
* Split pattern with sum + distribution + cumulative into 3 charts (no base)
|
||||
* @param {Object} args
|
||||
* @param {FullStatsPattern} args.pattern
|
||||
* @param {AggregatedPattern} args.pattern
|
||||
* @param {string} args.title
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.distributionSuffix]
|
||||
@@ -893,7 +978,11 @@ export function chartsFromAggregated({
|
||||
bottom: [{ series: pattern.sum, title: "base", color: stat.sum, unit }],
|
||||
},
|
||||
sumsTree({ windows: pattern.rolling.sum, title, unit }),
|
||||
distributionWindowsTree({ pattern: pattern.rolling, title: distTitle, unit }),
|
||||
distributionWindowsTree({
|
||||
pattern: pattern.rolling,
|
||||
title: distTitle,
|
||||
unit,
|
||||
}),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
@@ -905,7 +994,7 @@ export function chartsFromAggregated({
|
||||
/**
|
||||
* Split pattern into 3 charts with "per Block" in distribution title (no base)
|
||||
* @param {Object} args
|
||||
* @param {FullStatsPattern} args.pattern
|
||||
* @param {AggregatedPattern} args.pattern
|
||||
* @param {string} args.title
|
||||
* @param {Unit} args.unit
|
||||
* @returns {PartialOptionsTree}
|
||||
@@ -947,7 +1036,7 @@ export function chartsFromBlockAnd6b({ pattern, title, unit }) {
|
||||
*/
|
||||
export function chartsFromSumsCumulative({ pattern, title, unit, color }) {
|
||||
return [
|
||||
sumsTree({ windows: pattern.sum, title, unit }),
|
||||
...sumsArray({ windows: pattern.sum, title, unit }),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
|
||||
@@ -231,31 +231,15 @@ export function satsBtcUsdFullTree({ pattern, name, title, color }) {
|
||||
title,
|
||||
bottom: satsBtcUsd({ pattern: pattern.base, name, color }),
|
||||
},
|
||||
{
|
||||
name: "Sums",
|
||||
tree: [
|
||||
{
|
||||
name: "Compare",
|
||||
title: `${title} Rolling`,
|
||||
bottom: ROLLING_WINDOWS.flatMap((w) =>
|
||||
satsBtcUsd({
|
||||
pattern: pattern.sum[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
}),
|
||||
),
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `${title} (${w.name})`,
|
||||
bottom: satsBtcUsd({
|
||||
pattern: pattern.sum[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
}),
|
||||
})),
|
||||
],
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `${title} ${w.title} Sum`,
|
||||
bottom: satsBtcUsd({
|
||||
pattern: pattern.sum[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
}),
|
||||
})),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
* @property {string} title
|
||||
* @property {Color} color
|
||||
* @property {PatternAll} tree
|
||||
* @property {AddressCountDeltaPattern} addressCount
|
||||
* @property {AddrCountPattern} addressCount
|
||||
*
|
||||
* Full cohort: adjustedSopr + percentiles + RelToMarketCap (term.short)
|
||||
* @typedef {Object} CohortFull
|
||||
@@ -265,7 +265,7 @@
|
||||
* ============================================================================
|
||||
*
|
||||
* Addressable cohort with address count (for "type" cohorts - uses OutputsRealizedSupplyUnrealizedPattern2)
|
||||
* @typedef {{ name: string, title: string, color: Color, tree: EmptyPattern, addressCount: AddressCountDeltaPattern }} CohortAddr
|
||||
* @typedef {{ name: string, title: string, color: Color, tree: EmptyPattern, addressCount: AddrCountPattern }} CohortAddr
|
||||
*
|
||||
* ============================================================================
|
||||
* Cohort Group Types (by capability)
|
||||
@@ -333,7 +333,7 @@
|
||||
* @property {string} title
|
||||
* @property {Color} color
|
||||
* @property {AddrCohortPattern} tree
|
||||
* @property {AddressCountDeltaPattern} addressCount
|
||||
* @property {AddrCountPattern} addressCount
|
||||
*
|
||||
* @typedef {UtxoCohortObject | AddrCohortObject | CohortWithoutRelative} CohortObject
|
||||
*
|
||||
|
||||
+15
-12
@@ -2,7 +2,7 @@
|
||||
* @import { IChartApi, ISeriesApi as _ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, BaselineData as _BaselineData, HistogramData as _HistogramData, SeriesType as LCSeriesType, IPaneApi, LineSeriesPartialOptions as _LineSeriesPartialOptions, HistogramSeriesPartialOptions as _HistogramSeriesPartialOptions, BaselineSeriesPartialOptions as _BaselineSeriesPartialOptions, CandlestickSeriesPartialOptions as _CandlestickSeriesPartialOptions, WhitespaceData, DeepPartial, ChartOptions, Time, LineData as _LineData, createChart as CreateLCChart, LineStyle, createSeriesMarkers as CreateSeriesMarkers, SeriesMarker, ISeriesMarkersPluginApi } from './modules/lightweight-charts/5.1.0/dist/typings.js'
|
||||
*
|
||||
* @import * as Brk from "./modules/brk-client/index.js"
|
||||
* @import { BrkClient, Index, Series as BrkSeries, SeriesData } from "./modules/brk-client/index.js"
|
||||
* @import { BrkClient, Index, SeriesData } from "./modules/brk-client/index.js"
|
||||
*
|
||||
* @import { Options } from './options/full.js'
|
||||
*
|
||||
@@ -61,18 +61,17 @@
|
||||
* AnyRatioPattern: full ratio pattern with percentiles, SMAs, and std dev bands
|
||||
* @typedef {Brk.BpsCentsPercentilesRatioSatsSmaStdUsdPattern} AnyRatioPattern
|
||||
* ValuePattern: patterns with base + cumulative (no rolling)
|
||||
* @typedef {Brk.BaseCumulativeSumPattern<number> | Brk.BaseCumulativeRelPattern} ValuePattern
|
||||
* @typedef {Brk.BaseCumulativeSumPattern<number> | Brk.BaseCumulativeToPattern} ValuePattern
|
||||
* FullValuePattern: base + cumulative + rolling windows (flattened)
|
||||
* @typedef {Brk.BaseCumulativeSumPattern4} FullValuePattern
|
||||
* RollingWindowSlot: a single rolling window with stats (average, pct10, pct25, median, pct75, pct90, max, min) per unit
|
||||
* @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern<number>} RollingWindowSlot
|
||||
* AnyValuePatternType: union of all value pattern types
|
||||
* @typedef {Brk.BaseCumulativeSumPattern4 | Brk.BaseCumulativeSumPattern<number> | Brk.BaseCumulativeRelPattern} AnyValuePatternType
|
||||
* @typedef {Brk.BaseCumulativeSumPattern4 | Brk.BaseCumulativeSumPattern<number> | Brk.BaseCumulativeToPattern} AnyValuePatternType
|
||||
* @typedef {Brk.AnySeriesPattern} AnySeriesPattern
|
||||
* @typedef {Brk.CentsSatsUsdPattern} ActivePricePattern
|
||||
* @typedef {Brk.AnySeriesEndpoint} AnySeriesEndpoint
|
||||
* @typedef {Brk.AnySeriesData} AnySeriesData
|
||||
* @typedef {Brk.AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} AddrCountPattern
|
||||
* Relative patterns by capability:
|
||||
* - BasicRelativePattern: minimal relative (investedCapitalIn*Pct, supplyIn*RelToOwnSupply only)
|
||||
* - GlobalRelativePattern: has RelToMarketCap series (netUnrealizedPnlRelToMarketCap, etc)
|
||||
@@ -103,10 +102,10 @@
|
||||
* @typedef {Brk.CoindaysCoinyearsDormancyTransferPattern} FullActivityPattern
|
||||
*
|
||||
* Profit distribution detail (base + cumulative + distribution flow + rel + sum + value)
|
||||
* @typedef {Brk.BaseCumulativeDistributionRelSumValuePattern} ProfitDetailPattern
|
||||
* @typedef {Brk.BaseCumulativeDistributionSumToValuePattern} ProfitDetailPattern
|
||||
*
|
||||
* Loss detail with capitulation (base + capitulation + cumulative + negative + rel + sum + value)
|
||||
* @typedef {Brk.BaseCapitulationCumulativeNegativeRelSumValuePattern} LossDetailPattern
|
||||
* @typedef {Brk.BaseCapitulationCumulativeNegativeSumToValuePattern} LossDetailPattern
|
||||
*
|
||||
* BPS + ratio pattern (for NUPL and similar)
|
||||
* @typedef {Brk.BpsRatioPattern} NuplPattern
|
||||
@@ -115,7 +114,7 @@
|
||||
* @typedef {Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} LthRealizedPattern
|
||||
*
|
||||
* Net PnL pattern with change (base + change + cumulative + delta + rel + sum)
|
||||
* @typedef {Brk.BaseChangeCumulativeDeltaRelSumPattern} NetPnlFullPattern
|
||||
* @typedef {Brk.BaseChangeCumulativeDeltaSumToPattern} NetPnlFullPattern
|
||||
*
|
||||
* Net PnL basic pattern (base + cumulative + delta + sum)
|
||||
* @typedef {Brk.BaseCumulativeDeltaSumPattern} NetPnlBasicPattern
|
||||
@@ -129,8 +128,8 @@
|
||||
* Moving average price ratio pattern (bps + cents + ratio + sats + usd)
|
||||
* @typedef {Brk.BpsCentsRatioSatsUsdPattern} MaPriceRatioPattern
|
||||
*
|
||||
* Address count delta pattern (inner delta with absolute + rate)
|
||||
* @typedef {Brk.DeltaInnerPattern} AddressCountDeltaPattern
|
||||
* Address count pattern (base + delta with absolute + rate)
|
||||
* @typedef {Brk.BaseDeltaPattern} AddrCountPattern
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -156,15 +155,19 @@
|
||||
*/
|
||||
/**
|
||||
* Full stats pattern: cumulative, sum, average, min, max, percentiles + rolling
|
||||
* @typedef {Brk.AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern} FullStatsPattern
|
||||
* @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern<number>} FullStatsPattern
|
||||
*/
|
||||
/**
|
||||
* Aggregated pattern: cumulative + rolling (with distribution stats) + sum (no base)
|
||||
* @typedef {Brk.CumulativeRollingSumPattern} AggregatedPattern
|
||||
*/
|
||||
/**
|
||||
* Sum stats pattern: cumulative, sum, average, min, max, percentiles + rolling (same as FullStatsPattern)
|
||||
* @typedef {Brk.AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern} SumStatsPattern
|
||||
* @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern<number>} SumStatsPattern
|
||||
*/
|
||||
/**
|
||||
* Full stats pattern for Bitcoin (non-generic variant) - same as FullStatsPattern
|
||||
* @typedef {Brk.AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern} BtcFullStatsPattern
|
||||
* @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern<number>} BtcFullStatsPattern
|
||||
*/
|
||||
/**
|
||||
* Count pattern: height, cumulative, and rolling sum windows
|
||||
|
||||
Reference in New Issue
Block a user