global: snapshot

This commit is contained in:
nym21
2026-03-18 21:04:12 +01:00
parent 92e1a0ccaf
commit d8b55340f7
16 changed files with 215 additions and 143 deletions

View File

@@ -1073,7 +1073,7 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 {
pub struct CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern {
pub cap: CentsDeltaToUsdPattern,
pub gross_pnl: BaseCumulativeSumPattern3,
pub investor: InvestorPricePattern,
pub investor: PricePattern,
pub loss: BaseCapitulationCumulativeNegativeSumToValuePattern,
pub mvrv: SeriesPattern1<StoredF32>,
pub net_pnl: BaseChangeCumulativeDeltaSumToPattern,
@@ -2507,24 +2507,6 @@ pub struct GreedNetPainPattern {
pub pain_index: CentsUsdPattern2,
}
/// Pattern struct for repeated tree structure.
pub struct InvestorPricePattern {
pub investor_lower_band: CentsSatsUsdPattern,
pub investor_upper_band: CentsSatsUsdPattern,
pub price: BpsCentsPercentilesRatioSatsUsdPattern,
}
impl InvestorPricePattern {
/// Create a new pattern node with accumulated series name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
investor_lower_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_band")),
investor_upper_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_band")),
price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), _m(&acc, "price")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct LossNuplProfitPattern {
pub loss: BaseCumulativeNegativeSumPattern,
@@ -2896,6 +2878,20 @@ impl NuplPattern {
}
}
/// Pattern struct for repeated tree structure.
pub struct PricePattern {
pub price: BpsCentsPercentilesRatioSatsUsdPattern,
}
impl PricePattern {
/// Create a new pattern node with accumulated series name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), acc.clone()),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct UnspentPattern {
pub unspent_count: BaseDeltaPattern,
@@ -6313,7 +6309,7 @@ pub struct SeriesTree_Cohorts_Utxo_All_Realized {
pub gross_pnl: BaseCumulativeSumPattern3,
pub sell_side_risk_ratio: _1m1w1y24hPattern6,
pub peak_regret: BaseCumulativeToPattern,
pub investor: InvestorPricePattern,
pub investor: PricePattern,
pub profit_to_loss_ratio: _1m1w1y24hPattern<StoredF64>,
}
@@ -6330,7 +6326,7 @@ impl SeriesTree_Cohorts_Utxo_All_Realized {
gross_pnl: BaseCumulativeSumPattern3::new(client.clone(), "realized_gross_pnl".to_string()),
sell_side_risk_ratio: _1m1w1y24hPattern6::new(client.clone(), "sell_side_risk_ratio".to_string()),
peak_regret: BaseCumulativeToPattern::new(client.clone(), "realized_peak_regret".to_string()),
investor: InvestorPricePattern::new(client.clone(), "investor".to_string()),
investor: PricePattern::new(client.clone(), "investor_price".to_string()),
profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "realized_profit_to_loss_ratio".to_string()),
}
}
@@ -6812,7 +6808,7 @@ pub struct SeriesTree_Cohorts_Utxo_Sth_Realized {
pub gross_pnl: BaseCumulativeSumPattern3,
pub sell_side_risk_ratio: _1m1w1y24hPattern6,
pub peak_regret: BaseCumulativeToPattern,
pub investor: InvestorPricePattern,
pub investor: PricePattern,
pub profit_to_loss_ratio: _1m1w1y24hPattern<StoredF64>,
}
@@ -6829,7 +6825,7 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized {
gross_pnl: BaseCumulativeSumPattern3::new(client.clone(), "sth_realized_gross_pnl".to_string()),
sell_side_risk_ratio: _1m1w1y24hPattern6::new(client.clone(), "sth_sell_side_risk_ratio".to_string()),
peak_regret: BaseCumulativeToPattern::new(client.clone(), "sth_realized_peak_regret".to_string()),
investor: InvestorPricePattern::new(client.clone(), "sth_investor".to_string()),
investor: PricePattern::new(client.clone(), "sth_investor_price".to_string()),
profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "sth_realized_profit_to_loss_ratio".to_string()),
}
}
@@ -7250,7 +7246,7 @@ pub struct SeriesTree_Cohorts_Utxo_Lth_Realized {
pub gross_pnl: BaseCumulativeSumPattern3,
pub sell_side_risk_ratio: _1m1w1y24hPattern6,
pub peak_regret: BaseCumulativeToPattern,
pub investor: InvestorPricePattern,
pub investor: PricePattern,
pub profit_to_loss_ratio: _1m1w1y24hPattern<StoredF64>,
}
@@ -7267,7 +7263,7 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized {
gross_pnl: BaseCumulativeSumPattern3::new(client.clone(), "lth_realized_gross_pnl".to_string()),
sell_side_risk_ratio: _1m1w1y24hPattern6::new(client.clone(), "lth_sell_side_risk_ratio".to_string()),
peak_regret: BaseCumulativeToPattern::new(client.clone(), "lth_realized_peak_regret".to_string()),
investor: InvestorPricePattern::new(client.clone(), "lth_investor".to_string()),
investor: PricePattern::new(client.clone(), "lth_investor_price".to_string()),
profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()),
}
}

View File

@@ -1,8 +1,7 @@
use brk_traversable::Traversable;
use brk_types::Dollars;
use vecdb::{Rw, StorageMode};
use crate::internal::{PerBlock, PriceWithRatioExtendedPerBlock};
use crate::internal::PriceWithRatioExtendedPerBlock;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {

View File

@@ -14,7 +14,7 @@ use crate::{
blocks,
distribution::state::{WithCapital, CohortState, CostBasisData, RealizedState},
internal::{
CentsUnsignedToDollars, PerBlock, PerBlockCumulative,
CentsUnsignedToDollars, PerBlockCumulative,
PerBlockCumulativeWithSums, FiatPerBlockCumulativeWithSums,
LazyPerBlock, PercentPerBlock, PercentRollingWindows,
PriceWithRatioExtendedPerBlock, RatioCents64, RatioCentsBp32,

View File

@@ -146,4 +146,5 @@ mod tests {
assert_eq!(ep.count(), 0);
assert_eq!(quantile(&ep, 0.5), 0);
}
}

View File

@@ -33,7 +33,11 @@ pub struct RatioPerBlockPercentiles<M: StorageMode = Rw> {
expanding_pct: ExpandingPercentiles,
}
const VERSION: Version = Version::new(4);
const VERSION: Version = Version::new(5);
/// First height included in ratio percentile computation (first halving).
/// Earlier blocks lack meaningful market data and pollute the distribution.
const MIN_HEIGHT: usize = 210_000;
impl RatioPerBlockPercentiles {
pub(crate) fn forced_import(
@@ -100,11 +104,11 @@ impl RatioPerBlockPercentiles {
let ratio_len = ratio_source.len();
if ratio_len > start {
let pct_count = self.expanding_pct.count() as usize;
if pct_count != start {
let expected_count = start.saturating_sub(MIN_HEIGHT);
if self.expanding_pct.count() as usize != expected_count {
self.expanding_pct.reset();
if start > 0 {
let historical = ratio_source.collect_range_at(0, start);
if start > MIN_HEIGHT {
let historical = ratio_source.collect_range_at(MIN_HEIGHT, start);
self.expanding_pct.add_bulk(&historical);
}
}
@@ -125,8 +129,10 @@ impl RatioPerBlockPercentiles {
vec.truncate_if_needed_at(start)?;
}
for &ratio in new_ratios.iter() {
self.expanding_pct.add(*ratio);
for (i, &ratio) in new_ratios.iter().enumerate() {
if start + i >= MIN_HEIGHT {
self.expanding_pct.add(*ratio);
}
self.expanding_pct.quantiles(&PCTS, &mut out);
for (vec, &val) in pct_vecs.iter_mut().zip(out.iter()) {
vec.push(BasisPoints32::from(val));

View File

@@ -49,7 +49,7 @@ pub struct Computer<M: StorageMode = Rw> {
pub outputs: Box<outputs::Vecs<M>>,
}
const VERSION: Version = Version::new(5);
const VERSION: Version = Version::new(6);
impl Computer {
pub fn forced_import(outputs_path: &Path, indexer: &Indexer) -> Result<Self> {

View File

@@ -165,8 +165,9 @@ impl Vecs {
let start_days = super::ByDcaClass::<()>::start_days();
for (stack, day1) in self.class.stack.iter_mut().zip(start_days) {
let mut last_di: Option<Day1> = None;
let mut prev_value = if starting_height > 0 {
stack.sats.height.collect_one_at(starting_height - 1).unwrap_or_default()
let cls_start = stack.sats.height.len().min(starting_height);
let mut prev_value = if cls_start > 0 {
stack.sats.height.collect_one_at(cls_start - 1).unwrap_or_default()
} else {
Sats::ZERO
};

View File

@@ -16,7 +16,6 @@ pub struct Date(u32);
impl Date {
pub const INDEX_ZERO: Self = Self(20090101);
pub const INDEX_ZERO_: Date_ = Date_::constant(2009, 1, 1);
pub const MIN_RATIO: Self = Self(20120101);
pub fn new(year: u16, month: u8, day: u8) -> Self {
Self(year as u32 * 1_00_00 + month as u32 * 1_00 + day as u32)

View File

@@ -1783,7 +1783,7 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) {
* @typedef {Object} CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern
* @property {CentsDeltaToUsdPattern} cap
* @property {BaseCumulativeSumPattern3} grossPnl
* @property {InvestorPricePattern} investor
* @property {PricePattern} investor
* @property {BaseCapitulationCumulativeNegativeSumToValuePattern} loss
* @property {SeriesPattern1<StoredF32>} mvrv
* @property {BaseChangeCumulativeDeltaSumToPattern} netPnl
@@ -3407,27 +3407,6 @@ function createDeltaHalfTotalPattern(client, acc) {
* @property {CentsUsdPattern2} painIndex
*/
/**
* @typedef {Object} InvestorPricePattern
* @property {CentsSatsUsdPattern} investorLowerBand
* @property {CentsSatsUsdPattern} investorUpperBand
* @property {BpsCentsPercentilesRatioSatsUsdPattern} price
*/
/**
* Create a InvestorPricePattern pattern node
* @param {BrkClientBase} client
* @param {string} acc - Accumulated series name
* @returns {InvestorPricePattern}
*/
function createInvestorPricePattern(client, acc) {
return {
investorLowerBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_band')),
investorUpperBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_band')),
price: createBpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'price')),
};
}
/**
* @typedef {Object} LossNuplProfitPattern
* @property {BaseCumulativeNegativeSumPattern} loss
@@ -3870,6 +3849,23 @@ function createNuplPattern(client, acc) {
};
}
/**
* @typedef {Object} PricePattern
* @property {BpsCentsPercentilesRatioSatsUsdPattern} price
*/
/**
* Create a PricePattern pattern node
* @param {BrkClientBase} client
* @param {string} acc - Accumulated series name
* @returns {PricePattern}
*/
function createPricePattern(client, acc) {
return {
price: createBpsCentsPercentilesRatioSatsUsdPattern(client, acc),
};
}
/**
* @typedef {Object} UnspentPattern
* @property {BaseDeltaPattern} unspentCount
@@ -5378,7 +5374,7 @@ function createUnspentPattern(client, acc) {
* @property {BaseCumulativeSumPattern3} grossPnl
* @property {_1m1w1y24hPattern6} sellSideRiskRatio
* @property {BaseCumulativeToPattern} peakRegret
* @property {InvestorPricePattern} investor
* @property {PricePattern} investor
* @property {_1m1w1y24hPattern<StoredF64>} profitToLossRatio
*/
@@ -5599,7 +5595,7 @@ function createUnspentPattern(client, acc) {
* @property {BaseCumulativeSumPattern3} grossPnl
* @property {_1m1w1y24hPattern6} sellSideRiskRatio
* @property {BaseCumulativeToPattern} peakRegret
* @property {InvestorPricePattern} investor
* @property {PricePattern} investor
* @property {_1m1w1y24hPattern<StoredF64>} profitToLossRatio
*/
@@ -5794,7 +5790,7 @@ function createUnspentPattern(client, acc) {
* @property {BaseCumulativeSumPattern3} grossPnl
* @property {_1m1w1y24hPattern6} sellSideRiskRatio
* @property {BaseCumulativeToPattern} peakRegret
* @property {InvestorPricePattern} investor
* @property {PricePattern} investor
* @property {_1m1w1y24hPattern<StoredF64>} profitToLossRatio
*/
@@ -8601,7 +8597,7 @@ class BrkClient extends BrkClientBase {
grossPnl: createBaseCumulativeSumPattern3(this, 'realized_gross_pnl'),
sellSideRiskRatio: create_1m1w1y24hPattern6(this, 'sell_side_risk_ratio'),
peakRegret: createBaseCumulativeToPattern(this, 'realized_peak_regret'),
investor: createInvestorPricePattern(this, 'investor'),
investor: createPricePattern(this, 'investor_price'),
profitToLossRatio: create_1m1w1y24hPattern(this, 'realized_profit_to_loss_ratio'),
},
costBasis: {
@@ -8766,7 +8762,7 @@ class BrkClient extends BrkClientBase {
grossPnl: createBaseCumulativeSumPattern3(this, 'sth_realized_gross_pnl'),
sellSideRiskRatio: create_1m1w1y24hPattern6(this, 'sth_sell_side_risk_ratio'),
peakRegret: createBaseCumulativeToPattern(this, 'sth_realized_peak_regret'),
investor: createInvestorPricePattern(this, 'sth_investor'),
investor: createPricePattern(this, 'sth_investor_price'),
profitToLossRatio: create_1m1w1y24hPattern(this, 'sth_realized_profit_to_loss_ratio'),
},
costBasis: {
@@ -8909,7 +8905,7 @@ class BrkClient extends BrkClientBase {
grossPnl: createBaseCumulativeSumPattern3(this, 'lth_realized_gross_pnl'),
sellSideRiskRatio: create_1m1w1y24hPattern6(this, 'lth_sell_side_risk_ratio'),
peakRegret: createBaseCumulativeToPattern(this, 'lth_realized_peak_regret'),
investor: createInvestorPricePattern(this, 'lth_investor'),
investor: createPricePattern(this, 'lth_investor_price'),
profitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'),
},
costBasis: {

View File

@@ -2921,15 +2921,6 @@ class GreedNetPainPattern:
"""Pattern struct for repeated tree structure."""
pass
class InvestorPricePattern:
"""Pattern struct for repeated tree structure."""
def __init__(self, client: BrkClientBase, acc: str):
"""Create pattern node with accumulated series name."""
self.investor_lower_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_band'))
self.investor_upper_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_band'))
self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'price'))
class LossNuplProfitPattern:
"""Pattern struct for repeated tree structure."""
@@ -3117,6 +3108,13 @@ class NuplPattern:
"""Create pattern node with accumulated series name."""
self.nupl: BpsRatioPattern = BpsRatioPattern(client, acc)
class PricePattern:
"""Pattern struct for repeated tree structure."""
def __init__(self, client: BrkClientBase, acc: str):
"""Create pattern node with accumulated series name."""
self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, acc)
class UnspentPattern:
"""Pattern struct for repeated tree structure."""
@@ -4847,7 +4845,7 @@ class SeriesTree_Cohorts_Utxo_All_Realized:
self.gross_pnl: BaseCumulativeSumPattern3 = BaseCumulativeSumPattern3(client, 'realized_gross_pnl')
self.sell_side_risk_ratio: _1m1w1y24hPattern6 = _1m1w1y24hPattern6(client, 'sell_side_risk_ratio')
self.peak_regret: BaseCumulativeToPattern = BaseCumulativeToPattern(client, 'realized_peak_regret')
self.investor: InvestorPricePattern = InvestorPricePattern(client, 'investor')
self.investor: PricePattern = PricePattern(client, 'investor_price')
self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'realized_profit_to_loss_ratio')
class SeriesTree_Cohorts_Utxo_All_CostBasis:
@@ -5087,7 +5085,7 @@ class SeriesTree_Cohorts_Utxo_Sth_Realized:
self.gross_pnl: BaseCumulativeSumPattern3 = BaseCumulativeSumPattern3(client, 'sth_realized_gross_pnl')
self.sell_side_risk_ratio: _1m1w1y24hPattern6 = _1m1w1y24hPattern6(client, 'sth_sell_side_risk_ratio')
self.peak_regret: BaseCumulativeToPattern = BaseCumulativeToPattern(client, 'sth_realized_peak_regret')
self.investor: InvestorPricePattern = InvestorPricePattern(client, 'sth_investor')
self.investor: PricePattern = PricePattern(client, 'sth_investor_price')
self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'sth_realized_profit_to_loss_ratio')
class SeriesTree_Cohorts_Utxo_Sth_CostBasis:
@@ -5289,7 +5287,7 @@ class SeriesTree_Cohorts_Utxo_Lth_Realized:
self.gross_pnl: BaseCumulativeSumPattern3 = BaseCumulativeSumPattern3(client, 'lth_realized_gross_pnl')
self.sell_side_risk_ratio: _1m1w1y24hPattern6 = _1m1w1y24hPattern6(client, 'lth_sell_side_risk_ratio')
self.peak_regret: BaseCumulativeToPattern = BaseCumulativeToPattern(client, 'lth_realized_peak_regret')
self.investor: InvestorPricePattern = InvestorPricePattern(client, 'lth_investor')
self.investor: PricePattern = PricePattern(client, 'lth_investor_price')
self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_realized_profit_to_loss_ratio')
class SeriesTree_Cohorts_Utxo_Lth_CostBasis:

View File

@@ -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,

View File

@@ -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],
},
};

View File

@@ -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)`,

View File

@@ -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)`,

View File

@@ -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
*

View File

@@ -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