mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -2021,6 +2021,28 @@ impl BaseBtcCentsSatsUsdPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct CoinblocksCoindaysSentPattern {
|
||||
pub coinblocks_destroyed: CumulativeHeightPattern<StoredF64>,
|
||||
pub coindays_destroyed: CumulativeHeightSumPattern<StoredF64>,
|
||||
pub sent: MetricPattern1<Sats>,
|
||||
pub sent_sum: _24hPattern<Sats>,
|
||||
pub sent_sum_extended: _1m1w1yPattern<Sats>,
|
||||
}
|
||||
|
||||
impl CoinblocksCoindaysSentPattern {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
coinblocks_destroyed: CumulativeHeightPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")),
|
||||
coindays_destroyed: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")),
|
||||
sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")),
|
||||
sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")),
|
||||
sent_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct EmaHistogramLineSignalPattern {
|
||||
pub ema_fast: MetricPattern1<StoredF32>,
|
||||
@@ -2043,28 +2065,6 @@ impl EmaHistogramLineSignalPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct SupplyPattern2 {
|
||||
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
}
|
||||
|
||||
impl SupplyPattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")),
|
||||
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_own_supply")),
|
||||
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")),
|
||||
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_own_supply")),
|
||||
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _1m1w1y24hHeightPattern<T> {
|
||||
pub _1m: MetricPattern1<T>,
|
||||
@@ -2187,26 +2187,6 @@ impl BtcCentsSatsUsdPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct CoinblocksCoindaysSentPattern {
|
||||
pub coinblocks_destroyed: CumulativeHeightPattern<StoredF64>,
|
||||
pub coindays_destroyed: CumulativeHeightSumPattern<StoredF64>,
|
||||
pub sent: BaseCumulativePattern,
|
||||
pub sent_ema: _2wPattern,
|
||||
}
|
||||
|
||||
impl CoinblocksCoindaysSentPattern {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
coinblocks_destroyed: CumulativeHeightPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")),
|
||||
coindays_destroyed: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")),
|
||||
sent: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent")),
|
||||
sent_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_ema_2w")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct InvestedMaxMinPercentilesPattern {
|
||||
pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern,
|
||||
@@ -2375,6 +2355,24 @@ impl ChangeHalvedTotalPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct SupplyPattern2 {
|
||||
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
|
||||
}
|
||||
|
||||
impl SupplyPattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")),
|
||||
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")),
|
||||
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _1m1w1yPattern<T> {
|
||||
pub _1m: MetricPattern1<T>,
|
||||
@@ -2575,16 +2573,16 @@ impl SdSmaPattern {
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct SentPattern {
|
||||
pub sent: BaseCumulativePattern,
|
||||
pub sent_ema: _2wPattern,
|
||||
pub sent: MetricPattern1<Sats>,
|
||||
pub sent_sum: _24hPattern<Sats>,
|
||||
}
|
||||
|
||||
impl SentPattern {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
sent: BaseCumulativePattern::new(client.clone(), acc.clone()),
|
||||
sent_ema: _2wPattern::new(client.clone(), _m(&acc, "ema_2w")),
|
||||
sent: MetricPattern1::new(client.clone(), acc.clone()),
|
||||
sent_sum: _24hPattern::new(client.clone(), _m(&acc, "24h")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2637,20 +2635,6 @@ impl<T: DeserializeOwned> CumulativeHeightPattern<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _2wPattern {
|
||||
pub _2w: BtcCentsSatsUsdPattern,
|
||||
}
|
||||
|
||||
impl _2wPattern {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
_2w: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _24hPattern<T> {
|
||||
pub _24h: MetricPattern1<T>,
|
||||
@@ -5575,12 +5559,12 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Adjusted {
|
||||
|
||||
/// Metrics tree node.
|
||||
pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative {
|
||||
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
|
||||
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
|
||||
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
|
||||
pub nupl: MetricPattern1<StoredF32>,
|
||||
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
|
||||
pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern,
|
||||
pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
|
||||
pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern,
|
||||
@@ -5589,12 +5573,12 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative {
|
||||
impl MetricsTree_Distribution_UtxoCohorts_All_Relative {
|
||||
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
|
||||
Self {
|
||||
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()),
|
||||
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()),
|
||||
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_market_cap".to_string()),
|
||||
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_market_cap".to_string()),
|
||||
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_market_cap".to_string()),
|
||||
nupl: MetricPattern1::new(client.clone(), "nupl".to_string()),
|
||||
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()),
|
||||
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()),
|
||||
unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()),
|
||||
unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()),
|
||||
net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()),
|
||||
|
||||
@@ -3,35 +3,36 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{Height, Indexes, Sats, Version};
|
||||
use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec};
|
||||
|
||||
use crate::internal::{RollingEmas2w, ValueFromHeightCumulative};
|
||||
use crate::internal::{ComputedFromHeight, RollingWindow24h};
|
||||
|
||||
use crate::{blocks, distribution::metrics::ImportConfig, prices};
|
||||
use crate::{blocks, distribution::metrics::ImportConfig};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct ActivityBase<M: StorageMode = Rw> {
|
||||
pub sent: ValueFromHeightCumulative<M>,
|
||||
pub sent_ema: RollingEmas2w<M>,
|
||||
pub sent: ComputedFromHeight<Sats, M>,
|
||||
pub sent_sum: RollingWindow24h<Sats, M>,
|
||||
}
|
||||
|
||||
impl ActivityBase {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v1 = Version::ONE;
|
||||
Ok(Self {
|
||||
sent: cfg.import("sent", Version::ZERO)?,
|
||||
sent_ema: cfg.import("sent", Version::ZERO)?,
|
||||
sent: cfg.import("sent", v1)?,
|
||||
sent_sum: cfg.import("sent", v1)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_len(&self) -> usize {
|
||||
self.sent.base.sats.height.len()
|
||||
self.sent.height.len()
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> {
|
||||
self.sent.base.sats.height.truncate_push(height, sent)?;
|
||||
self.sent.height.truncate_push(height, sent)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
vec![&mut self.sent.base.sats.height as &mut dyn AnyStoredVec]
|
||||
vec![&mut self.sent.height as &mut dyn AnyStoredVec]
|
||||
}
|
||||
|
||||
pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> {
|
||||
@@ -44,11 +45,11 @@ impl ActivityBase {
|
||||
others: &[&Self],
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.sent.base.sats.height.compute_sum_of_others(
|
||||
self.sent.height.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&others
|
||||
.iter()
|
||||
.map(|v| &v.sent.base.sats.height)
|
||||
.map(|v| &v.sent.height)
|
||||
.collect::<Vec<_>>(),
|
||||
exit,
|
||||
)?;
|
||||
@@ -58,21 +59,15 @@ impl ActivityBase {
|
||||
pub(crate) fn compute_rest_part1(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
prices: &prices::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.sent
|
||||
.compute(prices, starting_indexes.height, exit)?;
|
||||
|
||||
self.sent_ema.compute(
|
||||
self.sent_sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_2w_ago,
|
||||
&self.sent.base.sats.height,
|
||||
&self.sent.base.cents.height,
|
||||
&blocks.count.height_24h_ago,
|
||||
&self.sent.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec};
|
||||
|
||||
use crate::internal::{ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum};
|
||||
use crate::internal::{
|
||||
ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum, RollingWindowsFrom1w,
|
||||
};
|
||||
|
||||
use crate::{blocks, distribution::metrics::ImportConfig, prices};
|
||||
use crate::{blocks, distribution::metrics::ImportConfig};
|
||||
|
||||
use super::ActivityBase;
|
||||
|
||||
@@ -19,15 +21,19 @@ pub struct ActivityFull<M: StorageMode = Rw> {
|
||||
|
||||
pub coinblocks_destroyed: ComputedFromHeightCumulative<StoredF64, M>,
|
||||
pub coindays_destroyed: ComputedFromHeightCumulativeSum<StoredF64, M>,
|
||||
|
||||
pub sent_sum_extended: RollingWindowsFrom1w<Sats, M>,
|
||||
}
|
||||
|
||||
impl ActivityFull {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v1 = Version::ONE;
|
||||
Ok(Self {
|
||||
base: ActivityBase::forced_import(cfg)?,
|
||||
coinblocks_destroyed: cfg
|
||||
.import("coinblocks_destroyed", Version::ONE)?,
|
||||
coindays_destroyed: cfg.import("coindays_destroyed", Version::ONE)?,
|
||||
.import("coinblocks_destroyed", v1)?,
|
||||
coindays_destroyed: cfg.import("coindays_destroyed", v1)?,
|
||||
sent_sum_extended: cfg.import("sent", v1)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -59,7 +65,7 @@ impl ActivityFull {
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
vec![
|
||||
&mut self.base.sent.base.sats.height as &mut dyn AnyStoredVec,
|
||||
&mut self.base.sent.height as &mut dyn AnyStoredVec,
|
||||
&mut self.coinblocks_destroyed.height as &mut dyn AnyStoredVec,
|
||||
&mut self.coindays_destroyed.height as &mut dyn AnyStoredVec,
|
||||
]
|
||||
@@ -87,12 +93,11 @@ impl ActivityFull {
|
||||
pub(crate) fn compute_rest_part1(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
prices: &prices::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.base
|
||||
.compute_rest_part1(blocks, prices, starting_indexes, exit)?;
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.coinblocks_destroyed
|
||||
.compute_rest(starting_indexes.height, exit)?;
|
||||
@@ -101,6 +106,13 @@ impl ActivityFull {
|
||||
self.coindays_destroyed
|
||||
.compute_rest(starting_indexes.height, &window_starts, exit)?;
|
||||
|
||||
self.sent_sum_extended.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.base.sent.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ impl AllCohortMetrics {
|
||||
self.dormancy.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.activity.coindays_destroyed.height,
|
||||
&self.activity.sent.base.sats.height,
|
||||
&self.activity.sent.height,
|
||||
|(i, cdd, sent_sats, ..)| {
|
||||
let sent_btc = f64::from(Bitcoin::from(sent_sats));
|
||||
if sent_btc == 0.0 {
|
||||
@@ -139,7 +139,7 @@ impl AllCohortMetrics {
|
||||
|
||||
self.velocity.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.activity.sent.base.sats.height,
|
||||
&self.activity.sent.height,
|
||||
&self.supply.total.sats.height,
|
||||
|(i, sent_sats, supply_sats, ..)| {
|
||||
let supply = supply_sats.as_u128() as f64;
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{blocks, prices};
|
||||
|
||||
use crate::distribution::metrics::{
|
||||
ActivityFull, CohortMetricsBase, CostBasisBase, ImportConfig, OutputsMetrics, RealizedBase,
|
||||
RelativeBaseWithRelToAll, SupplyMetrics, UnrealizedBase,
|
||||
RelativeToAll, SupplyMetrics, UnrealizedBase,
|
||||
};
|
||||
|
||||
/// Basic cohort metrics: no extensions, with relative (rel_to_all).
|
||||
@@ -23,7 +23,7 @@ pub struct BasicCohortMetrics<M: StorageMode = Rw> {
|
||||
pub realized: Box<RealizedBase<M>>,
|
||||
pub cost_basis: Box<CostBasisBase<M>>,
|
||||
pub unrealized: Box<UnrealizedBase<M>>,
|
||||
pub relative: Box<RelativeBaseWithRelToAll<M>>,
|
||||
pub relative: Box<RelativeToAll<M>>,
|
||||
}
|
||||
|
||||
impl CohortMetricsBase for BasicCohortMetrics {
|
||||
@@ -51,7 +51,7 @@ impl BasicCohortMetrics {
|
||||
let unrealized = UnrealizedBase::forced_import(cfg)?;
|
||||
let realized = RealizedBase::forced_import(cfg)?;
|
||||
|
||||
let relative = RelativeBaseWithRelToAll::forced_import(cfg)?;
|
||||
let relative = RelativeToAll::forced_import(cfg)?;
|
||||
|
||||
Ok(Self {
|
||||
filter: cfg.filter.clone(),
|
||||
@@ -83,7 +83,8 @@ impl BasicCohortMetrics {
|
||||
|
||||
self.relative.compute(
|
||||
starting_indexes.height,
|
||||
&self.unrealized.core,
|
||||
&self.unrealized.supply_in_profit.sats.height,
|
||||
&self.unrealized.supply_in_loss.sats.height,
|
||||
&self.supply.total.sats.height,
|
||||
all_supply_sats,
|
||||
exit,
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{blocks, prices};
|
||||
|
||||
use crate::distribution::metrics::{
|
||||
ActivityBase, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics,
|
||||
RelativeBaseWithRelToAll, SupplyMetrics, UnrealizedCore,
|
||||
RelativeToAll, SupplyMetrics, UnrealizedCore,
|
||||
};
|
||||
|
||||
#[derive(Traversable)]
|
||||
@@ -20,7 +20,7 @@ pub struct CoreCohortMetrics<M: StorageMode = Rw> {
|
||||
pub activity: Box<ActivityBase<M>>,
|
||||
pub realized: Box<RealizedCore<M>>,
|
||||
pub unrealized: Box<UnrealizedCore<M>>,
|
||||
pub relative: Box<RelativeBaseWithRelToAll<M>>,
|
||||
pub relative: Box<RelativeToAll<M>>,
|
||||
}
|
||||
|
||||
impl CoreCohortMetrics {
|
||||
@@ -32,7 +32,7 @@ impl CoreCohortMetrics {
|
||||
activity: Box::new(ActivityBase::forced_import(cfg)?),
|
||||
realized: Box::new(RealizedCore::forced_import(cfg)?),
|
||||
unrealized: Box::new(UnrealizedCore::forced_import(cfg)?),
|
||||
relative: Box::new(RelativeBaseWithRelToAll::forced_import(cfg)?),
|
||||
relative: Box::new(RelativeToAll::forced_import(cfg)?),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl CoreCohortMetrics {
|
||||
.compute_rest(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.activity
|
||||
.compute_rest_part1(blocks, prices, starting_indexes, exit)?;
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.realized
|
||||
.compute_rest_part1(starting_indexes, exit)?;
|
||||
@@ -140,7 +140,8 @@ impl CoreCohortMetrics {
|
||||
|
||||
self.relative.compute(
|
||||
starting_indexes.height,
|
||||
&self.unrealized,
|
||||
&self.unrealized.supply_in_profit.sats.height,
|
||||
&self.unrealized.supply_in_loss.sats.height,
|
||||
&self.supply.total.sats.height,
|
||||
all_supply_sats,
|
||||
exit,
|
||||
|
||||
@@ -105,7 +105,7 @@ impl ExtendedCohortMetrics {
|
||||
self.dormancy.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.activity.coindays_destroyed.height,
|
||||
&self.activity.sent.base.sats.height,
|
||||
&self.activity.sent.height,
|
||||
|(i, cdd, sent_sats, ..)| {
|
||||
let sent_btc = f64::from(Bitcoin::from(sent_sats));
|
||||
if sent_btc == 0.0 {
|
||||
@@ -119,7 +119,7 @@ impl ExtendedCohortMetrics {
|
||||
|
||||
self.velocity.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.activity.sent.base.sats.height,
|
||||
&self.activity.sent.height,
|
||||
&self.supply.total.sats.height,
|
||||
|(i, sent_sats, supply_sats, ..)| {
|
||||
let supply = supply_sats.as_u128() as f64;
|
||||
|
||||
@@ -191,7 +191,7 @@ impl MinimalCohortMetrics {
|
||||
self.outputs
|
||||
.compute_rest(blocks, starting_indexes, exit)?;
|
||||
self.activity
|
||||
.compute_rest_part1(blocks, prices, starting_indexes, exit)?;
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
self.realized
|
||||
.compute_rest_part1(starting_indexes, exit)?;
|
||||
self.unrealized
|
||||
|
||||
@@ -55,7 +55,7 @@ pub use realized::{
|
||||
RealizedAdjusted, RealizedBase, RealizedCore, RealizedFull, RealizedLike, RealizedMinimal,
|
||||
};
|
||||
pub use relative::{
|
||||
RelativeBaseWithRelToAll, RelativeForAll, RelativeWithExtended,
|
||||
RelativeForAll, RelativeToAll, RelativeWithExtended,
|
||||
};
|
||||
pub use supply::SupplyMetrics;
|
||||
pub use unrealized::{UnrealizedBase, UnrealizedCore, UnrealizedFull, UnrealizedLike};
|
||||
@@ -200,10 +200,7 @@ pub trait CohortMetricsBase: CohortMetricsState<Realized = RealizedState> + Send
|
||||
self.outputs_mut()
|
||||
.compute_rest(blocks, starting_indexes, exit)?;
|
||||
self.activity_mut()
|
||||
.sent
|
||||
.compute(prices, starting_indexes.height, exit)?;
|
||||
self.activity_mut()
|
||||
.compute_rest_part1(blocks, prices, starting_indexes, exit)?;
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.realized_mut()
|
||||
.compute_rest_part1(starting_indexes, exit)?;
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BasisPoints16, Height, Sats, Version};
|
||||
use vecdb::{Exit, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::internal::{PercentFromHeight, RatioSatsBp16};
|
||||
|
||||
use crate::distribution::metrics::{ImportConfig, UnrealizedCore};
|
||||
|
||||
/// Relative metrics for the Complete tier.
|
||||
#[derive(Traversable)]
|
||||
pub struct RelativeBase<M: StorageMode = Rw> {
|
||||
pub supply_in_profit_rel_to_own_supply: PercentFromHeight<BasisPoints16, M>,
|
||||
pub supply_in_loss_rel_to_own_supply: PercentFromHeight<BasisPoints16, M>,
|
||||
}
|
||||
|
||||
impl RelativeBase {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v1 = Version::ONE;
|
||||
|
||||
Ok(Self {
|
||||
supply_in_profit_rel_to_own_supply: cfg
|
||||
.import("supply_in_profit_rel_to_own_supply", v1)?,
|
||||
supply_in_loss_rel_to_own_supply: cfg
|
||||
.import("supply_in_loss_rel_to_own_supply", v1)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
max_from: Height,
|
||||
unrealized: &UnrealizedCore,
|
||||
supply_total_sats: &impl ReadableVec<Height, Sats>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.supply_in_profit_rel_to_own_supply
|
||||
.compute_binary::<Sats, Sats, RatioSatsBp16>(
|
||||
max_from,
|
||||
&unrealized.supply_in_profit.sats.height,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
self.supply_in_loss_rel_to_own_supply
|
||||
.compute_binary::<Sats, Sats, RatioSatsBp16>(
|
||||
max_from,
|
||||
&unrealized.supply_in_loss.sats.height,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,20 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
Bps32ToFloat, LazyFromHeight, PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32,
|
||||
RatioSatsBp16,
|
||||
};
|
||||
|
||||
use crate::distribution::metrics::{ImportConfig, UnrealizedCore};
|
||||
|
||||
use super::RelativeBase;
|
||||
|
||||
/// Full relative metrics (Source/Extended tier).
|
||||
#[derive(Deref, DerefMut, Traversable)]
|
||||
/// Full relative metrics (sth/lth/all tier).
|
||||
#[derive(Traversable)]
|
||||
pub struct RelativeFull<M: StorageMode = Rw> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
#[traversable(flatten)]
|
||||
pub base: RelativeBase<M>,
|
||||
pub supply_in_profit_rel_to_own_supply: PercentFromHeight<BasisPoints16, M>,
|
||||
pub supply_in_loss_rel_to_own_supply: PercentFromHeight<BasisPoints16, M>,
|
||||
|
||||
pub unrealized_profit_rel_to_market_cap: PercentFromHeight<BasisPoints16, M>,
|
||||
pub unrealized_loss_rel_to_market_cap: PercentFromHeight<BasisPoints16, M>,
|
||||
@@ -30,8 +26,7 @@ pub struct RelativeFull<M: StorageMode = Rw> {
|
||||
|
||||
impl RelativeFull {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let base = RelativeBase::forced_import(cfg)?;
|
||||
|
||||
let v1 = Version::ONE;
|
||||
let v2 = Version::new(2);
|
||||
let v3 = Version::new(3);
|
||||
|
||||
@@ -49,7 +44,10 @@ impl RelativeFull {
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
base,
|
||||
supply_in_profit_rel_to_own_supply: cfg
|
||||
.import("supply_in_profit_rel_to_own_supply", v1)?,
|
||||
supply_in_loss_rel_to_own_supply: cfg
|
||||
.import("supply_in_loss_rel_to_own_supply", v1)?,
|
||||
unrealized_profit_rel_to_market_cap: cfg
|
||||
.import("unrealized_profit_rel_to_market_cap", v2)?,
|
||||
unrealized_loss_rel_to_market_cap: cfg
|
||||
@@ -67,12 +65,20 @@ impl RelativeFull {
|
||||
market_cap: &impl ReadableVec<Height, Dollars>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.base.compute(
|
||||
max_from,
|
||||
unrealized,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
self.supply_in_profit_rel_to_own_supply
|
||||
.compute_binary::<Sats, Sats, RatioSatsBp16>(
|
||||
max_from,
|
||||
&unrealized.supply_in_profit.sats.height,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
self.supply_in_loss_rel_to_own_supply
|
||||
.compute_binary::<Sats, Sats, RatioSatsBp16>(
|
||||
max_from,
|
||||
&unrealized.supply_in_loss.sats.height,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.unrealized_profit_rel_to_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
mod base;
|
||||
mod extended_own_market_cap;
|
||||
mod extended_own_pnl;
|
||||
mod for_all;
|
||||
mod full;
|
||||
mod to_all;
|
||||
mod with_extended;
|
||||
mod with_rel_to_all;
|
||||
|
||||
pub use base::RelativeBase;
|
||||
pub use extended_own_market_cap::RelativeExtendedOwnMarketCap;
|
||||
pub use extended_own_pnl::RelativeExtendedOwnPnl;
|
||||
pub use for_all::RelativeForAll;
|
||||
pub use full::RelativeFull;
|
||||
pub use to_all::RelativeToAll;
|
||||
pub use with_extended::RelativeWithExtended;
|
||||
pub use with_rel_to_all::RelativeBaseWithRelToAll;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, Sats};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use vecdb::{Exit, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::distribution::metrics::{ImportConfig, UnrealizedCore};
|
||||
|
||||
use super::{RelativeBase, RelativeToAll};
|
||||
|
||||
/// Base relative metrics with rel_to_all.
|
||||
/// Used by: age_range, epoch, class, min_age, max_age cohorts.
|
||||
#[derive(Deref, DerefMut, Traversable)]
|
||||
pub struct RelativeBaseWithRelToAll<M: StorageMode = Rw> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
#[traversable(flatten)]
|
||||
pub base: RelativeBase<M>,
|
||||
#[traversable(flatten)]
|
||||
pub rel_to_all: RelativeToAll<M>,
|
||||
}
|
||||
|
||||
impl RelativeBaseWithRelToAll {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
Ok(Self {
|
||||
base: RelativeBase::forced_import(cfg)?,
|
||||
rel_to_all: RelativeToAll::forced_import(cfg)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
max_from: Height,
|
||||
unrealized: &UnrealizedCore,
|
||||
supply_total_sats: &impl ReadableVec<Height, Sats>,
|
||||
all_supply_sats: &impl ReadableVec<Height, Sats>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.base.compute(
|
||||
max_from,
|
||||
unrealized,
|
||||
supply_total_sats,
|
||||
exit,
|
||||
)?;
|
||||
self.rel_to_all.compute(
|
||||
max_from,
|
||||
&unrealized.supply_in_profit.sats.height,
|
||||
&unrealized.supply_in_loss.sats.height,
|
||||
supply_total_sats,
|
||||
all_supply_sats,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -2745,6 +2745,31 @@ function createBaseBtcCentsSatsUsdPattern(client, acc) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} CoinblocksCoindaysSentPattern
|
||||
* @property {CumulativeHeightPattern<StoredF64>} coinblocksDestroyed
|
||||
* @property {CumulativeHeightSumPattern<StoredF64>} coindaysDestroyed
|
||||
* @property {MetricPattern1<Sats>} sent
|
||||
* @property {_24hPattern<Sats>} sentSum
|
||||
* @property {_1m1w1yPattern<Sats>} sentSumExtended
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a CoinblocksCoindaysSentPattern pattern node
|
||||
* @param {BrkClientBase} client
|
||||
* @param {string} acc - Accumulated metric name
|
||||
* @returns {CoinblocksCoindaysSentPattern}
|
||||
*/
|
||||
function createCoinblocksCoindaysSentPattern(client, acc) {
|
||||
return {
|
||||
coinblocksDestroyed: createCumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')),
|
||||
coindaysDestroyed: createCumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')),
|
||||
sent: createMetricPattern1(client, _m(acc, 'sent')),
|
||||
sentSum: create_24hPattern(client, _m(acc, 'sent_24h')),
|
||||
sentSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent')),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} EmaHistogramLineSignalPattern
|
||||
* @property {MetricPattern1<StoredF32>} emaFast
|
||||
@@ -2770,31 +2795,6 @@ function createEmaHistogramLineSignalPattern(client, acc) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} SupplyPattern2
|
||||
* @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a SupplyPattern2 pattern node
|
||||
* @param {BrkClientBase} client
|
||||
* @param {string} acc - Accumulated metric name
|
||||
* @returns {SupplyPattern2}
|
||||
*/
|
||||
function createSupplyPattern2(client, acc) {
|
||||
return {
|
||||
supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')),
|
||||
supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_own_supply')),
|
||||
supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')),
|
||||
supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_own_supply')),
|
||||
supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {Object} _1m1w1y24hHeightPattern
|
||||
@@ -2937,29 +2937,6 @@ function createBtcCentsSatsUsdPattern(client, acc) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} CoinblocksCoindaysSentPattern
|
||||
* @property {CumulativeHeightPattern<StoredF64>} coinblocksDestroyed
|
||||
* @property {CumulativeHeightSumPattern<StoredF64>} coindaysDestroyed
|
||||
* @property {BaseCumulativePattern} sent
|
||||
* @property {_2wPattern} sentEma
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a CoinblocksCoindaysSentPattern pattern node
|
||||
* @param {BrkClientBase} client
|
||||
* @param {string} acc - Accumulated metric name
|
||||
* @returns {CoinblocksCoindaysSentPattern}
|
||||
*/
|
||||
function createCoinblocksCoindaysSentPattern(client, acc) {
|
||||
return {
|
||||
coinblocksDestroyed: createCumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')),
|
||||
coindaysDestroyed: createCumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')),
|
||||
sent: createBaseCumulativePattern(client, _m(acc, 'sent')),
|
||||
sentEma: create_2wPattern(client, _m(acc, 'sent_ema_2w')),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} InvestedMaxMinPercentilesPattern
|
||||
* @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital
|
||||
@@ -3157,6 +3134,27 @@ function createChangeHalvedTotalPattern(client, acc) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} SupplyPattern2
|
||||
* @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply
|
||||
* @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a SupplyPattern2 pattern node
|
||||
* @param {BrkClientBase} client
|
||||
* @param {string} acc - Accumulated metric name
|
||||
* @returns {SupplyPattern2}
|
||||
*/
|
||||
function createSupplyPattern2(client, acc) {
|
||||
return {
|
||||
supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')),
|
||||
supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')),
|
||||
supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {Object} _1m1w1yPattern
|
||||
@@ -3399,8 +3397,8 @@ function createSdSmaPattern(client, acc) {
|
||||
|
||||
/**
|
||||
* @typedef {Object} SentPattern
|
||||
* @property {BaseCumulativePattern} sent
|
||||
* @property {_2wPattern} sentEma
|
||||
* @property {MetricPattern1<Sats>} sent
|
||||
* @property {_24hPattern<Sats>} sentSum
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -3411,8 +3409,8 @@ function createSdSmaPattern(client, acc) {
|
||||
*/
|
||||
function createSentPattern(client, acc) {
|
||||
return {
|
||||
sent: createBaseCumulativePattern(client, acc),
|
||||
sentEma: create_2wPattern(client, _m(acc, 'ema_2w')),
|
||||
sent: createMetricPattern1(client, acc),
|
||||
sentSum: create_24hPattern(client, _m(acc, '24h')),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3475,23 +3473,6 @@ function createCumulativeHeightPattern(client, acc) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} _2wPattern
|
||||
* @property {BtcCentsSatsUsdPattern} _2w
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a _2wPattern pattern node
|
||||
* @param {BrkClientBase} client
|
||||
* @param {string} acc - Accumulated metric name
|
||||
* @returns {_2wPattern}
|
||||
*/
|
||||
function create_2wPattern(client, acc) {
|
||||
return {
|
||||
_2w: createBtcCentsSatsUsdPattern(client, acc),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {Object} _24hPattern
|
||||
@@ -4803,12 +4784,12 @@ function create_24hPattern(client, acc) {
|
||||
|
||||
/**
|
||||
* @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative
|
||||
* @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap
|
||||
* @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap
|
||||
* @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap
|
||||
* @property {MetricPattern1<StoredF32>} nupl
|
||||
* @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply
|
||||
* @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnGrossPnl
|
||||
* @property {BpsPercentRatioPattern} unrealizedLossRelToOwnGrossPnl
|
||||
* @property {BpsPercentRatioPattern} netUnrealizedPnlRelToOwnGrossPnl
|
||||
@@ -7014,12 +6995,12 @@ class BrkClient extends BrkClientBase {
|
||||
adjustedSoprEma: create_1m1wPattern(this, 'adjusted_sopr_24h_ema'),
|
||||
},
|
||||
relative: {
|
||||
supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'),
|
||||
supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_loss_rel_to_own_supply'),
|
||||
unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_market_cap'),
|
||||
unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_market_cap'),
|
||||
netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_market_cap'),
|
||||
nupl: createMetricPattern1(this, 'nupl'),
|
||||
supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'),
|
||||
supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_loss_rel_to_own_supply'),
|
||||
unrealizedProfitRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'),
|
||||
unrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'),
|
||||
netUnrealizedPnlRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'),
|
||||
|
||||
@@ -2607,6 +2607,17 @@ class BaseBtcCentsSatsUsdPattern:
|
||||
self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'rewards_cumulative'))
|
||||
self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'rewards_cumulative_usd'))
|
||||
|
||||
class CoinblocksCoindaysSentPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self.coinblocks_destroyed: CumulativeHeightPattern[StoredF64] = CumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed'))
|
||||
self.coindays_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed'))
|
||||
self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent'))
|
||||
self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h'))
|
||||
self.sent_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent'))
|
||||
|
||||
class EmaHistogramLineSignalPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
@@ -2618,17 +2629,6 @@ class EmaHistogramLineSignalPattern:
|
||||
self.line: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'line_24h'))
|
||||
self.signal: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'signal_24h'))
|
||||
|
||||
class SupplyPattern2:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply'))
|
||||
self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_own_supply'))
|
||||
self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply'))
|
||||
self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_own_supply'))
|
||||
self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply'))
|
||||
|
||||
class _1m1w1y24hHeightPattern(Generic[T]):
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
@@ -2690,16 +2690,6 @@ class BtcCentsSatsUsdPattern:
|
||||
self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc)
|
||||
self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd'))
|
||||
|
||||
class CoinblocksCoindaysSentPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self.coinblocks_destroyed: CumulativeHeightPattern[StoredF64] = CumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed'))
|
||||
self.coindays_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed'))
|
||||
self.sent: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent'))
|
||||
self.sent_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_ema_2w'))
|
||||
|
||||
class InvestedMaxMinPercentilesPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
@@ -2784,6 +2774,15 @@ class ChangeHalvedTotalPattern:
|
||||
self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved'))
|
||||
self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc)
|
||||
|
||||
class SupplyPattern2:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply'))
|
||||
self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply'))
|
||||
self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply'))
|
||||
|
||||
class _1m1w1yPattern(Generic[T]):
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
@@ -2888,8 +2887,8 @@ class SentPattern:
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self.sent: BaseCumulativePattern = BaseCumulativePattern(client, acc)
|
||||
self.sent_ema: _2wPattern = _2wPattern(client, _m(acc, 'ema_2w'))
|
||||
self.sent: MetricPattern1[Sats] = MetricPattern1(client, acc)
|
||||
self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, '24h'))
|
||||
|
||||
class SupplyPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
@@ -2915,13 +2914,6 @@ class CumulativeHeightPattern(Generic[T]):
|
||||
self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative'))
|
||||
self.height: MetricPattern18[T] = MetricPattern18(client, acc)
|
||||
|
||||
class _2wPattern:
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, acc: str):
|
||||
"""Create pattern node with accumulated metric name."""
|
||||
self._2w: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc)
|
||||
|
||||
class _24hPattern(Generic[T]):
|
||||
"""Pattern struct for repeated tree structure."""
|
||||
|
||||
@@ -4262,12 +4254,12 @@ class MetricsTree_Distribution_UtxoCohorts_All_Relative:
|
||||
"""Metrics tree node."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, base_path: str = ''):
|
||||
self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply')
|
||||
self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_loss_rel_to_own_supply')
|
||||
self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_market_cap')
|
||||
self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_market_cap')
|
||||
self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_market_cap')
|
||||
self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, 'nupl')
|
||||
self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply')
|
||||
self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_loss_rel_to_own_supply')
|
||||
self.unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_own_gross_pnl')
|
||||
self.unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_own_gross_pnl')
|
||||
self.net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl')
|
||||
|
||||
Reference in New Issue
Block a user