mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-25 01:38:12 -07:00
crates: snapshot
This commit is contained in:
+140
-128
@@ -969,6 +969,55 @@ impl PricePercentilesPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pattern struct for repeated tree structure.
|
||||||
|
pub struct ActivePriceRatioPattern {
|
||||||
|
pub ratio: Indexes<StoredF32>,
|
||||||
|
pub ratio_1m_sma: Indexes<StoredF32>,
|
||||||
|
pub ratio_1w_sma: Indexes<StoredF32>,
|
||||||
|
pub ratio_1y_sd: Ratio1ySdPattern,
|
||||||
|
pub ratio_2y_sd: Ratio1ySdPattern,
|
||||||
|
pub ratio_4y_sd: Ratio1ySdPattern,
|
||||||
|
pub ratio_pct1: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct1_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_pct2: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct2_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_pct5: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct5_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_pct95: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct95_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_pct98: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct98_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_pct99: Indexes<StoredF32>,
|
||||||
|
pub ratio_pct99_usd: Indexes<Dollars>,
|
||||||
|
pub ratio_sd: Ratio1ySdPattern,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActivePriceRatioPattern {
|
||||||
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
ratio: Indexes::new(client.clone(), &format!("{base_path}/ratio")),
|
||||||
|
ratio_1m_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1m_sma")),
|
||||||
|
ratio_1w_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1w_sma")),
|
||||||
|
ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_1y_sd")),
|
||||||
|
ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_2y_sd")),
|
||||||
|
ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_4y_sd")),
|
||||||
|
ratio_pct1: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1")),
|
||||||
|
ratio_pct1_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1_usd")),
|
||||||
|
ratio_pct2: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2")),
|
||||||
|
ratio_pct2_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2_usd")),
|
||||||
|
ratio_pct5: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5")),
|
||||||
|
ratio_pct5_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5_usd")),
|
||||||
|
ratio_pct95: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95")),
|
||||||
|
ratio_pct95_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95_usd")),
|
||||||
|
ratio_pct98: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98")),
|
||||||
|
ratio_pct98_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98_usd")),
|
||||||
|
ratio_pct99: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99")),
|
||||||
|
ratio_pct99_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99_usd")),
|
||||||
|
ratio_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_sd")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct RelativePattern2 {
|
pub struct RelativePattern2 {
|
||||||
pub neg_unrealized_loss_rel_to_market_cap: Indexes27<StoredF32>,
|
pub neg_unrealized_loss_rel_to_market_cap: Indexes27<StoredF32>,
|
||||||
@@ -1014,43 +1063,6 @@ impl RelativePattern2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
|
||||||
pub struct ActivePriceRatioPattern {
|
|
||||||
pub ratio: Indexes<StoredF32>,
|
|
||||||
pub ratio_1m_sma: Indexes<StoredF32>,
|
|
||||||
pub ratio_1w_sma: Indexes<StoredF32>,
|
|
||||||
pub ratio_1y_sd: Ratio1ySdPattern,
|
|
||||||
pub ratio_2y_sd: Ratio1ySdPattern,
|
|
||||||
pub ratio_4y_sd: Ratio1ySdPattern,
|
|
||||||
pub ratio_pct1: Indexes<StoredF32>,
|
|
||||||
pub ratio_pct2: Indexes<StoredF32>,
|
|
||||||
pub ratio_pct5: Indexes<StoredF32>,
|
|
||||||
pub ratio_pct95: Indexes<StoredF32>,
|
|
||||||
pub ratio_pct98: Indexes<StoredF32>,
|
|
||||||
pub ratio_pct99: Indexes<StoredF32>,
|
|
||||||
pub ratio_sd: Ratio1ySdPattern,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActivePriceRatioPattern {
|
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
|
||||||
Self {
|
|
||||||
ratio: Indexes::new(client.clone(), &format!("{base_path}/ratio")),
|
|
||||||
ratio_1m_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1m_sma")),
|
|
||||||
ratio_1w_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1w_sma")),
|
|
||||||
ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_1y_sd")),
|
|
||||||
ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_2y_sd")),
|
|
||||||
ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_4y_sd")),
|
|
||||||
ratio_pct1: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1")),
|
|
||||||
ratio_pct2: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2")),
|
|
||||||
ratio_pct5: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5")),
|
|
||||||
ratio_pct95: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95")),
|
|
||||||
ratio_pct98: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98")),
|
|
||||||
ratio_pct99: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99")),
|
|
||||||
ratio_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_sd")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct AXbtPattern {
|
pub struct AXbtPattern {
|
||||||
pub _1d_dominance: BlockCountPattern<StoredF32>,
|
pub _1d_dominance: BlockCountPattern<StoredF32>,
|
||||||
@@ -1123,31 +1135,31 @@ impl<T: DeserializeOwned> BitcoinPattern<T> {
|
|||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct BlockSizePattern<T> {
|
pub struct BlockSizePattern<T> {
|
||||||
pub average: Indexes4<T>,
|
pub average: Indexes3<T>,
|
||||||
pub cumulative: Indexes3<T>,
|
pub cumulative: Indexes3<T>,
|
||||||
pub max: Indexes4<T>,
|
pub max: Indexes3<T>,
|
||||||
pub median: Indexes5<T>,
|
pub median: Indexes2<T>,
|
||||||
pub min: Indexes4<T>,
|
pub min: Indexes3<T>,
|
||||||
pub pct10: Indexes5<T>,
|
pub pct10: Indexes2<T>,
|
||||||
pub pct25: Indexes5<T>,
|
pub pct25: Indexes2<T>,
|
||||||
pub pct75: Indexes5<T>,
|
pub pct75: Indexes2<T>,
|
||||||
pub pct90: Indexes5<T>,
|
pub pct90: Indexes2<T>,
|
||||||
pub sum: Indexes4<T>,
|
pub sum: Indexes3<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DeserializeOwned> BlockSizePattern<T> {
|
impl<T: DeserializeOwned> BlockSizePattern<T> {
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
average: Indexes4::new(client.clone(), &format!("{base_path}/average")),
|
average: Indexes3::new(client.clone(), &format!("{base_path}/average")),
|
||||||
cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")),
|
cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")),
|
||||||
max: Indexes4::new(client.clone(), &format!("{base_path}/max")),
|
max: Indexes3::new(client.clone(), &format!("{base_path}/max")),
|
||||||
median: Indexes5::new(client.clone(), &format!("{base_path}/median")),
|
median: Indexes2::new(client.clone(), &format!("{base_path}/median")),
|
||||||
min: Indexes4::new(client.clone(), &format!("{base_path}/min")),
|
min: Indexes3::new(client.clone(), &format!("{base_path}/min")),
|
||||||
pct10: Indexes5::new(client.clone(), &format!("{base_path}/pct10")),
|
pct10: Indexes2::new(client.clone(), &format!("{base_path}/pct10")),
|
||||||
pct25: Indexes5::new(client.clone(), &format!("{base_path}/pct25")),
|
pct25: Indexes2::new(client.clone(), &format!("{base_path}/pct25")),
|
||||||
pct75: Indexes5::new(client.clone(), &format!("{base_path}/pct75")),
|
pct75: Indexes2::new(client.clone(), &format!("{base_path}/pct75")),
|
||||||
pct90: Indexes5::new(client.clone(), &format!("{base_path}/pct90")),
|
pct90: Indexes2::new(client.clone(), &format!("{base_path}/pct90")),
|
||||||
sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")),
|
sum: Indexes3::new(client.clone(), &format!("{base_path}/sum")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1319,21 +1331,21 @@ impl _0satsPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct UpTo1dPattern {
|
pub struct _10yTo12yPattern {
|
||||||
pub activity: ActivityPattern,
|
pub activity: ActivityPattern,
|
||||||
pub price_paid: PricePaidPattern2,
|
pub price_paid: PricePaidPattern2,
|
||||||
pub realized: RealizedPattern3,
|
pub realized: RealizedPattern2,
|
||||||
pub relative: RelativePattern2,
|
pub relative: RelativePattern2,
|
||||||
pub supply: SupplyPattern2,
|
pub supply: SupplyPattern2,
|
||||||
pub unrealized: UnrealizedPattern,
|
pub unrealized: UnrealizedPattern,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UpTo1dPattern {
|
impl _10yTo12yPattern {
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")),
|
activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")),
|
||||||
price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")),
|
price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")),
|
||||||
realized: RealizedPattern3::new(client.clone(), &format!("{base_path}/realized")),
|
realized: RealizedPattern2::new(client.clone(), &format!("{base_path}/realized")),
|
||||||
relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")),
|
relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")),
|
||||||
supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")),
|
supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")),
|
||||||
unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")),
|
unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")),
|
||||||
@@ -1365,21 +1377,21 @@ impl _0satsPattern2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct _10yTo12yPattern {
|
pub struct UpTo1dPattern {
|
||||||
pub activity: ActivityPattern,
|
pub activity: ActivityPattern,
|
||||||
pub price_paid: PricePaidPattern2,
|
pub price_paid: PricePaidPattern2,
|
||||||
pub realized: RealizedPattern2,
|
pub realized: RealizedPattern3,
|
||||||
pub relative: RelativePattern2,
|
pub relative: RelativePattern2,
|
||||||
pub supply: SupplyPattern2,
|
pub supply: SupplyPattern2,
|
||||||
pub unrealized: UnrealizedPattern,
|
pub unrealized: UnrealizedPattern,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl _10yTo12yPattern {
|
impl UpTo1dPattern {
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")),
|
activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")),
|
||||||
price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")),
|
price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")),
|
||||||
realized: RealizedPattern2::new(client.clone(), &format!("{base_path}/realized")),
|
realized: RealizedPattern3::new(client.clone(), &format!("{base_path}/realized")),
|
||||||
relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")),
|
relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")),
|
||||||
supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")),
|
supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")),
|
||||||
unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")),
|
unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")),
|
||||||
@@ -1387,27 +1399,6 @@ impl _10yTo12yPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
|
||||||
pub struct ActivityPattern {
|
|
||||||
pub coinblocks_destroyed: BlockCountPattern<StoredF64>,
|
|
||||||
pub coindays_destroyed: BlockCountPattern<StoredF64>,
|
|
||||||
pub satblocks_destroyed: Indexes2<Sats>,
|
|
||||||
pub satdays_destroyed: Indexes2<Sats>,
|
|
||||||
pub sent: FeePattern2,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActivityPattern {
|
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
|
||||||
Self {
|
|
||||||
coinblocks_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coinblocks_destroyed")),
|
|
||||||
coindays_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coindays_destroyed")),
|
|
||||||
satblocks_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satblocks_destroyed")),
|
|
||||||
satdays_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satdays_destroyed")),
|
|
||||||
sent: FeePattern2::new(client.clone(), &format!("{base_path}/sent")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct SupplyPattern2 {
|
pub struct SupplyPattern2 {
|
||||||
pub supply: SupplyPattern,
|
pub supply: SupplyPattern,
|
||||||
@@ -1430,20 +1421,22 @@ impl SupplyPattern2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct FeePattern2 {
|
pub struct ActivityPattern {
|
||||||
pub base: Indexes2<Sats>,
|
pub coinblocks_destroyed: BlockCountPattern<StoredF64>,
|
||||||
pub bitcoin: BlockCountPattern<Bitcoin>,
|
pub coindays_destroyed: BlockCountPattern<StoredF64>,
|
||||||
pub dollars: BlockCountPattern<Dollars>,
|
pub satblocks_destroyed: Indexes2<Sats>,
|
||||||
pub sats: SatsPattern,
|
pub satdays_destroyed: Indexes2<Sats>,
|
||||||
|
pub sent: FeePattern2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FeePattern2 {
|
impl ActivityPattern {
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base: Indexes2::new(client.clone(), &format!("{base_path}/base")),
|
coinblocks_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coinblocks_destroyed")),
|
||||||
bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")),
|
coindays_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coindays_destroyed")),
|
||||||
dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")),
|
satblocks_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satblocks_destroyed")),
|
||||||
sats: SatsPattern::new(client.clone(), &format!("{base_path}/sats")),
|
satdays_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satdays_destroyed")),
|
||||||
|
sent: FeePattern2::new(client.clone(), &format!("{base_path}/sent")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1468,18 +1461,20 @@ impl SupplyPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct UnclaimedRewardsPattern {
|
pub struct FeePattern2 {
|
||||||
|
pub base: Indexes2<Sats>,
|
||||||
pub bitcoin: BlockCountPattern<Bitcoin>,
|
pub bitcoin: BlockCountPattern<Bitcoin>,
|
||||||
pub dollars: BlockCountPattern<Dollars>,
|
pub dollars: BlockCountPattern<Dollars>,
|
||||||
pub sats: BlockCountPattern<Sats>,
|
pub sats: SatsPattern,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnclaimedRewardsPattern {
|
impl FeePattern2 {
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
base: Indexes2::new(client.clone(), &format!("{base_path}/base")),
|
||||||
bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")),
|
bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")),
|
||||||
dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")),
|
dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")),
|
||||||
sats: BlockCountPattern::new(client.clone(), &format!("{base_path}/sats")),
|
sats: SatsPattern::new(client.clone(), &format!("{base_path}/sats")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1501,6 +1496,23 @@ impl ActiveSupplyPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pattern struct for repeated tree structure.
|
||||||
|
pub struct UnclaimedRewardsPattern {
|
||||||
|
pub bitcoin: BlockCountPattern<Bitcoin>,
|
||||||
|
pub dollars: BlockCountPattern<Dollars>,
|
||||||
|
pub sats: BlockCountPattern<Sats>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UnclaimedRewardsPattern {
|
||||||
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")),
|
||||||
|
dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")),
|
||||||
|
sats: BlockCountPattern::new(client.clone(), &format!("{base_path}/sats")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct CoinbasePattern {
|
pub struct CoinbasePattern {
|
||||||
pub bitcoin: BitcoinPattern<Bitcoin>,
|
pub bitcoin: BitcoinPattern<Bitcoin>,
|
||||||
@@ -1552,6 +1564,36 @@ impl<T: DeserializeOwned> BlockCountPattern<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pattern struct for repeated tree structure.
|
||||||
|
pub struct SatsPattern {
|
||||||
|
pub cumulative: Indexes3<Sats>,
|
||||||
|
pub sum: Indexes4<Sats>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SatsPattern {
|
||||||
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")),
|
||||||
|
sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pattern struct for repeated tree structure.
|
||||||
|
pub struct SupplyValuePattern {
|
||||||
|
pub bitcoin: Indexes2<Bitcoin>,
|
||||||
|
pub dollars: Indexes2<Dollars>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SupplyValuePattern {
|
||||||
|
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
bitcoin: Indexes2::new(client.clone(), &format!("{base_path}/bitcoin")),
|
||||||
|
dollars: Indexes2::new(client.clone(), &format!("{base_path}/dollars")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct _1dReturns1mSdPattern {
|
pub struct _1dReturns1mSdPattern {
|
||||||
pub sd: Indexes<StoredF32>,
|
pub sd: Indexes<StoredF32>,
|
||||||
@@ -1583,36 +1625,6 @@ impl PricePaidPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
|
||||||
pub struct SupplyValuePattern {
|
|
||||||
pub bitcoin: Indexes2<Bitcoin>,
|
|
||||||
pub dollars: Indexes2<Dollars>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SupplyValuePattern {
|
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
|
||||||
Self {
|
|
||||||
bitcoin: Indexes2::new(client.clone(), &format!("{base_path}/bitcoin")),
|
|
||||||
dollars: Indexes2::new(client.clone(), &format!("{base_path}/dollars")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
|
||||||
pub struct SatsPattern {
|
|
||||||
pub cumulative: Indexes3<Sats>,
|
|
||||||
pub sum: Indexes4<Sats>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SatsPattern {
|
|
||||||
pub fn new(client: Arc<BrkClientBase>, base_path: &str) -> Self {
|
|
||||||
Self {
|
|
||||||
cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")),
|
|
||||||
sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pattern struct for repeated tree structure.
|
/// Pattern struct for repeated tree structure.
|
||||||
pub struct BitcoinPattern2<T> {
|
pub struct BitcoinPattern2<T> {
|
||||||
pub base: Indexes2<T>,
|
pub base: Indexes2<T>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::path::Path;
|
|||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Bitcoin, CheckedSub, Dollars, StoredF32, StoredF64, Version};
|
use brk_types::{Bitcoin, CheckedSub, Dollars, StoredF32, StoredF64, Version};
|
||||||
use vecdb::{Database, Exit, IterableCloneableVec, PAGE_SIZE, TypedVecIterator};
|
use vecdb::{Database, Exit, PAGE_SIZE, TypedVecIterator};
|
||||||
|
|
||||||
use crate::{grouped::ComputedVecsFromDateIndex, utils::OptionExt};
|
use crate::{grouped::ComputedVecsFromDateIndex, utils::OptionExt};
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ impl Vecs {
|
|||||||
ComputedRatioVecsFromDateIndex::forced_import(
|
ComputedRatioVecsFromDateIndex::forced_import(
|
||||||
&db,
|
&db,
|
||||||
$name,
|
$name,
|
||||||
Source::Vec($source.dateindex.unwrap_last().boxed_clone()),
|
Some($source),
|
||||||
v0,
|
v0,
|
||||||
indexes,
|
indexes,
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use brk_types::{
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{AnyExportableVec, BinaryTransform, IterableCloneableVec, LazyVecFrom2};
|
use vecdb::{AnyExportableVec, BinaryTransform, IterableCloneableVec, LazyVecFrom2};
|
||||||
|
|
||||||
use super::{ComputedVecValue, ComputedVecsFromDateIndex, LazyTransform2Builder};
|
use super::{ComputedVecValue, ComputedVecsFromDateIndex, ComputedVecsFromHeight, LazyTransform2Builder};
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
|
|
||||||
@@ -87,6 +87,64 @@ where
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create from a `ComputedVecsFromHeight` (first source) and `ComputedVecsFromDateIndex` (second source).
|
||||||
|
/// Used for computing USD values from price (Height-based) and ratio (DateIndex-based).
|
||||||
|
pub fn from_height_and_dateindex<F: BinaryTransform<S1T, S2T, T>>(
|
||||||
|
name: &str,
|
||||||
|
version: Version,
|
||||||
|
source1: &ComputedVecsFromHeight<S1T>,
|
||||||
|
source2: &ComputedVecsFromDateIndex<S2T>,
|
||||||
|
) -> Self {
|
||||||
|
let v = version + VERSION;
|
||||||
|
|
||||||
|
Self {
|
||||||
|
dateindex: source2.dateindex.as_ref().map(|s2| {
|
||||||
|
LazyVecFrom2::transformed::<F>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
source1.dateindex.unwrap_last().boxed_clone(),
|
||||||
|
s2.boxed_clone(),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
weekindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.weekindex,
|
||||||
|
&source2.weekindex,
|
||||||
|
),
|
||||||
|
monthindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.monthindex,
|
||||||
|
&source2.monthindex,
|
||||||
|
),
|
||||||
|
quarterindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.quarterindex,
|
||||||
|
&source2.quarterindex,
|
||||||
|
),
|
||||||
|
semesterindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.semesterindex,
|
||||||
|
&source2.semesterindex,
|
||||||
|
),
|
||||||
|
yearindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.yearindex,
|
||||||
|
&source2.yearindex,
|
||||||
|
),
|
||||||
|
decadeindex: LazyTransform2Builder::from_lazy::<F, _, _, _, _>(
|
||||||
|
name,
|
||||||
|
v,
|
||||||
|
&source1.decadeindex,
|
||||||
|
&source2.decadeindex,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S1T, S2T> Traversable for LazyVecsFrom2FromDateIndex<T, S1T, S2T>
|
impl<T, S1T, S2T> Traversable for LazyVecsFrom2FromDateIndex<T, S1T, S2T>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
utils::{OptionExt, get_percentile},
|
utils::{OptionExt, get_percentile},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{ComputedVecsFromDateIndex, VecBuilderOptions};
|
use super::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone, Traversable)]
|
#[derive(Clone, Traversable)]
|
||||||
pub struct ComputedRatioVecsFromDateIndex {
|
pub struct ComputedRatioVecsFromDateIndex {
|
||||||
@@ -51,7 +51,7 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
pub fn forced_import(
|
pub fn forced_import(
|
||||||
db: &Database,
|
db: &Database,
|
||||||
name: &str,
|
name: &str,
|
||||||
source: Source<DateIndex, Dollars>,
|
metric_price: Option<&ComputedVecsFromHeight<Dollars>>,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
extended: bool,
|
extended: bool,
|
||||||
@@ -73,8 +73,9 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Create sources first so lazy vecs can reference them
|
// Create price sources first so lazy vecs can reference them
|
||||||
let price = source.is_compute().then(|| {
|
// Only compute internally when metric_price is None
|
||||||
|
let price = metric_price.is_none().then(|| {
|
||||||
ComputedVecsFromDateIndex::forced_import(db, name, Source::Compute, v, indexes, opts)
|
ComputedVecsFromDateIndex::forced_import(db, name, Source::Compute, v, indexes, opts)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
@@ -103,16 +104,29 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
let ratio_pct1 = extended.then(|| import!("ratio_pct1"));
|
let ratio_pct1 = extended.then(|| import!("ratio_pct1"));
|
||||||
|
|
||||||
// Create lazy usd vecs from price and ratio sources
|
// Create lazy usd vecs from price and ratio sources
|
||||||
|
// Use from_height_and_dateindex when metric_price is provided (external price source)
|
||||||
|
// Use from_computed when price is computed internally
|
||||||
macro_rules! lazy_usd {
|
macro_rules! lazy_usd {
|
||||||
($ratio:expr, $suffix:expr) => {
|
($ratio:expr, $suffix:expr) => {
|
||||||
price.as_ref().zip($ratio.as_ref()).map(|(p, r)| {
|
if let Some(mp) = metric_price {
|
||||||
LazyVecsFrom2FromDateIndex::from_computed::<PriceTimesRatio>(
|
$ratio.as_ref().map(|r| {
|
||||||
&format!("{name}_{}", $suffix),
|
LazyVecsFrom2FromDateIndex::from_height_and_dateindex::<PriceTimesRatio>(
|
||||||
v,
|
&format!("{name}_{}", $suffix),
|
||||||
p,
|
v,
|
||||||
r,
|
mp,
|
||||||
)
|
r,
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
price.as_ref().zip($ratio.as_ref()).map(|(p, r)| {
|
||||||
|
LazyVecsFrom2FromDateIndex::from_computed::<PriceTimesRatio>(
|
||||||
|
&format!("{name}_{}", $suffix),
|
||||||
|
v,
|
||||||
|
p,
|
||||||
|
r,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ impl Vecs {
|
|||||||
ComputedRatioVecsFromDateIndex::forced_import(
|
ComputedRatioVecsFromDateIndex::forced_import(
|
||||||
&db,
|
&db,
|
||||||
$name,
|
$name,
|
||||||
Source::Compute,
|
None,
|
||||||
version + v0,
|
version + v0,
|
||||||
indexes,
|
indexes,
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub use readers::{
|
|||||||
pub use recover::{StartMode, determine_start_mode, recover_state, reset_state};
|
pub use recover::{StartMode, determine_start_mode, recover_state, reset_state};
|
||||||
|
|
||||||
/// Flush checkpoint interval (every N blocks).
|
/// Flush checkpoint interval (every N blocks).
|
||||||
pub const FLUSH_INTERVAL: usize = 20_000;
|
pub const FLUSH_INTERVAL: usize = 10_000;
|
||||||
|
|
||||||
// BIP30 duplicate coinbase heights (special case handling)
|
// BIP30 duplicate coinbase heights (special case handling)
|
||||||
pub const BIP30_DUPLICATE_HEIGHT_1: u32 = 91_842;
|
pub const BIP30_DUPLICATE_HEIGHT_1: u32 = 91_842;
|
||||||
|
|||||||
@@ -249,12 +249,7 @@ impl RealizedMetrics {
|
|||||||
indexes_to_realized_price_extra: ComputedRatioVecsFromDateIndex::forced_import(
|
indexes_to_realized_price_extra: ComputedRatioVecsFromDateIndex::forced_import(
|
||||||
cfg.db,
|
cfg.db,
|
||||||
&cfg.name("realized_price"),
|
&cfg.name("realized_price"),
|
||||||
Source::Vec(
|
Some(&indexes_to_realized_price),
|
||||||
indexes_to_realized_price
|
|
||||||
.dateindex
|
|
||||||
.unwrap_last()
|
|
||||||
.boxed_clone(),
|
|
||||||
),
|
|
||||||
cfg.version + v0,
|
cfg.version + v0,
|
||||||
cfg.indexes,
|
cfg.indexes,
|
||||||
extended,
|
extended,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use vecdb::{
|
|||||||
|
|
||||||
use super::Indexes;
|
use super::Indexes;
|
||||||
|
|
||||||
const BATCH_SIZE: usize = 3 * 1024 * 1024 * 1024 / size_of::<Entry>();
|
const BATCH_SIZE: usize = 2 * 1024 * 1024 * 1024 / size_of::<Entry>();
|
||||||
pub const DB_NAME: &str = "txins";
|
pub const DB_NAME: &str = "txins";
|
||||||
|
|
||||||
#[derive(Clone, Traversable)]
|
#[derive(Clone, Traversable)]
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use vecdb::{
|
|||||||
use super::{Indexes, txins};
|
use super::{Indexes, txins};
|
||||||
|
|
||||||
pub const DB_NAME: &str = "txouts";
|
pub const DB_NAME: &str = "txouts";
|
||||||
|
const HEIGHT_BATCH: u32 = 10_000;
|
||||||
|
|
||||||
#[derive(Clone, Traversable)]
|
#[derive(Clone, Traversable)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
@@ -101,7 +102,6 @@ impl Vecs {
|
|||||||
starting_indexes.height
|
starting_indexes.height
|
||||||
);
|
);
|
||||||
|
|
||||||
const HEIGHT_BATCH: u32 = 20_000;
|
|
||||||
let mut pairs: Vec<(TxOutIndex, TxInIndex)> = Vec::new();
|
let mut pairs: Vec<(TxOutIndex, TxInIndex)> = Vec::new();
|
||||||
|
|
||||||
let mut batch_start_height = min_height;
|
let mut batch_start_height = min_height;
|
||||||
|
|||||||
Reference in New Issue
Block a user