computer: renames

This commit is contained in:
nym21
2026-03-26 23:39:28 +01:00
parent 66680368b6
commit 19d4a193ff
10 changed files with 118 additions and 101 deletions

View File

@@ -5246,10 +5246,10 @@ impl SeriesTree_Investing {
/// Series tree node.
pub struct SeriesTree_Investing_Period {
pub stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3,
pub cost_basis: SeriesTree_Investing_Period_CostBasis,
pub return_: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2,
pub cagr: _10y2y3y4y5y6y8yPattern,
pub dca_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3,
pub dca_cost_basis: SeriesTree_Investing_Period_DcaCostBasis,
pub dca_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2,
pub dca_cagr: _10y2y3y4y5y6y8yPattern,
pub lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3,
pub lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2,
}
@@ -5257,10 +5257,10 @@ pub struct SeriesTree_Investing_Period {
impl SeriesTree_Investing_Period {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "dca_stack".to_string()),
cost_basis: SeriesTree_Investing_Period_CostBasis::new(client.clone(), format!("{base_path}_cost_basis")),
return_: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "dca_return".to_string()),
cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "dca_cagr".to_string()),
dca_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "dca_stack".to_string()),
dca_cost_basis: SeriesTree_Investing_Period_DcaCostBasis::new(client.clone(), format!("{base_path}_dca_cost_basis")),
dca_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "dca_return".to_string()),
dca_cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "dca_cagr".to_string()),
lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "lump_sum_stack".to_string()),
lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "lump_sum_return".to_string()),
}
@@ -5268,7 +5268,7 @@ impl SeriesTree_Investing_Period {
}
/// Series tree node.
pub struct SeriesTree_Investing_Period_CostBasis {
pub struct SeriesTree_Investing_Period_DcaCostBasis {
pub _1w: CentsSatsUsdPattern,
pub _1m: CentsSatsUsdPattern,
pub _3m: CentsSatsUsdPattern,
@@ -5283,7 +5283,7 @@ pub struct SeriesTree_Investing_Period_CostBasis {
pub _10y: CentsSatsUsdPattern,
}
impl SeriesTree_Investing_Period_CostBasis {
impl SeriesTree_Investing_Period_DcaCostBasis {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
_1w: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_1w".to_string()),
@@ -5304,23 +5304,23 @@ impl SeriesTree_Investing_Period_CostBasis {
/// Series tree node.
pub struct SeriesTree_Investing_Class {
pub stack: SeriesTree_Investing_Class_Stack,
pub cost_basis: SeriesTree_Investing_Class_CostBasis,
pub return_: SeriesTree_Investing_Class_Return,
pub dca_stack: SeriesTree_Investing_Class_DcaStack,
pub dca_cost_basis: SeriesTree_Investing_Class_DcaCostBasis,
pub dca_return: SeriesTree_Investing_Class_DcaReturn,
}
impl SeriesTree_Investing_Class {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
stack: SeriesTree_Investing_Class_Stack::new(client.clone(), format!("{base_path}_stack")),
cost_basis: SeriesTree_Investing_Class_CostBasis::new(client.clone(), format!("{base_path}_cost_basis")),
return_: SeriesTree_Investing_Class_Return::new(client.clone(), format!("{base_path}_return")),
dca_stack: SeriesTree_Investing_Class_DcaStack::new(client.clone(), format!("{base_path}_dca_stack")),
dca_cost_basis: SeriesTree_Investing_Class_DcaCostBasis::new(client.clone(), format!("{base_path}_dca_cost_basis")),
dca_return: SeriesTree_Investing_Class_DcaReturn::new(client.clone(), format!("{base_path}_dca_return")),
}
}
}
/// Series tree node.
pub struct SeriesTree_Investing_Class_Stack {
pub struct SeriesTree_Investing_Class_DcaStack {
pub from_2015: BtcCentsSatsUsdPattern3,
pub from_2016: BtcCentsSatsUsdPattern3,
pub from_2017: BtcCentsSatsUsdPattern3,
@@ -5335,7 +5335,7 @@ pub struct SeriesTree_Investing_Class_Stack {
pub from_2026: BtcCentsSatsUsdPattern3,
}
impl SeriesTree_Investing_Class_Stack {
impl SeriesTree_Investing_Class_DcaStack {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
from_2015: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2015".to_string()),
@@ -5355,7 +5355,7 @@ impl SeriesTree_Investing_Class_Stack {
}
/// Series tree node.
pub struct SeriesTree_Investing_Class_CostBasis {
pub struct SeriesTree_Investing_Class_DcaCostBasis {
pub from_2015: CentsSatsUsdPattern,
pub from_2016: CentsSatsUsdPattern,
pub from_2017: CentsSatsUsdPattern,
@@ -5370,7 +5370,7 @@ pub struct SeriesTree_Investing_Class_CostBasis {
pub from_2026: CentsSatsUsdPattern,
}
impl SeriesTree_Investing_Class_CostBasis {
impl SeriesTree_Investing_Class_DcaCostBasis {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
from_2015: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2015".to_string()),
@@ -5390,7 +5390,7 @@ impl SeriesTree_Investing_Class_CostBasis {
}
/// Series tree node.
pub struct SeriesTree_Investing_Class_Return {
pub struct SeriesTree_Investing_Class_DcaReturn {
pub from_2015: BpsPercentRatioPattern,
pub from_2016: BpsPercentRatioPattern,
pub from_2017: BpsPercentRatioPattern,
@@ -5405,7 +5405,7 @@ pub struct SeriesTree_Investing_Class_Return {
pub from_2026: BpsPercentRatioPattern,
}
impl SeriesTree_Investing_Class_Return {
impl SeriesTree_Investing_Class_DcaReturn {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
from_2015: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2015".to_string()),

View File

@@ -52,7 +52,7 @@ impl Vecs {
}
// DCA by period - stack (rolling sum via _start vecs)
for (stack, days) in self.period.stack.iter_mut_with_days() {
for (stack, days) in self.period.dca_stack.iter_mut_with_days() {
let window_starts = blocks.lookback.start_vec(days as usize);
stack.sats.height.compute_rolling_sum(
starting_indexes.height,
@@ -63,14 +63,16 @@ impl Vecs {
}
// DCA by period - stack cents (sats × price)
for stack in self.period.stack.iter_mut() {
for stack in self.period.dca_stack.iter_mut() {
stack.compute(prices, starting_indexes.height, exit)?;
}
// DCA by period - average price (derived from stack)
let starting_height = starting_indexes.height.to_usize();
for (average_price, stack, days) in
self.period.cost_basis.zip_mut_with_days(&self.period.stack)
for (average_price, stack, days) in self
.period
.dca_cost_basis
.zip_mut_with_days(&self.period.dca_stack)
{
let days = days as usize;
average_price.cents.height.compute_transform2(
@@ -94,9 +96,9 @@ impl Vecs {
// DCA by period - returns (compute from average price)
for (returns, (average_price, _)) in self
.period
.r#return
.dca_return
.iter_mut()
.zip(self.period.cost_basis.iter_with_days())
.zip(self.period.dca_cost_basis.iter_with_days())
{
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
starting_indexes.height,
@@ -107,7 +109,11 @@ impl Vecs {
}
// DCA by period - CAGR (computed from returns at height level)
for (cagr, returns, days) in self.period.cagr.zip_mut_with_period(&self.period.r#return) {
for (cagr, returns, days) in self
.period
.dca_cagr
.zip_mut_with_period(&self.period.dca_return)
{
let years = days as f64 / 365.0;
cagr.bps.height.compute_transform(
starting_indexes.height,
@@ -165,11 +171,15 @@ impl Vecs {
// DCA by year class - stack (cumulative sum from class start date)
let start_days = super::ByDcaClass::<()>::start_days();
for (stack, day1) in self.class.stack.iter_mut().zip(start_days) {
for (stack, day1) in self.class.dca_stack.iter_mut().zip(start_days) {
let mut last_di: Option<Day1> = None;
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()
stack
.sats
.height
.collect_one_at(cls_start - 1)
.unwrap_or_default()
} else {
Sats::ZERO
};
@@ -216,7 +226,7 @@ impl Vecs {
}
// DCA by year class - stack cents (sats × price)
for stack in self.class.stack.iter_mut() {
for stack in self.class.dca_stack.iter_mut() {
stack.compute(prices, starting_indexes.height, exit)?;
}
@@ -224,9 +234,9 @@ impl Vecs {
let start_days = super::ByDcaClass::<()>::start_days();
for ((average_price, stack), from) in self
.class
.cost_basis
.dca_cost_basis
.iter_mut()
.zip(self.class.stack.iter())
.zip(self.class.dca_stack.iter())
.zip(start_days)
{
let from_usize = from.to_usize();
@@ -250,9 +260,9 @@ impl Vecs {
// DCA by year class - returns (compute from average price)
for (returns, average_price) in self
.class
.r#return
.dca_return
.iter_mut()
.zip(self.class.cost_basis.iter())
.zip(self.class.dca_cost_basis.iter())
{
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
starting_indexes.height,

View File

@@ -4,13 +4,13 @@ use brk_error::Result;
use brk_types::Version;
use vecdb::ImportableVec;
use super::{ByDcaCagr, ByDcaClass, ByDcaPeriod, Vecs};
use super::vecs::{ClassVecs, PeriodVecs};
use super::{ByDcaCagr, ByDcaClass, ByDcaPeriod, Vecs};
use crate::{
indexes,
internal::{
db_utils::{finalize_db, open_db},
AmountPerBlock, PercentPerBlock, Price,
db_utils::{finalize_db, open_db},
},
};
@@ -66,17 +66,17 @@ impl Vecs {
let this = Self {
sats_per_day: ImportableVec::forced_import(&db, "dca_sats_per_day", version)?,
period: PeriodVecs {
stack,
cost_basis,
r#return,
cagr,
dca_stack: stack,
dca_cost_basis: cost_basis,
dca_return: r#return,
dca_cagr: cagr,
lump_sum_stack,
lump_sum_return,
},
class: ClassVecs {
stack: class_stack,
cost_basis: class_cost_basis,
r#return: class_return,
dca_stack: class_stack,
dca_cost_basis: class_cost_basis,
dca_return: class_return,
},
db,
};

View File

@@ -7,19 +7,19 @@ use crate::internal::{AmountPerBlock, PerBlock, PercentPerBlock, Price};
#[derive(Traversable)]
pub struct PeriodVecs<M: StorageMode = Rw> {
pub stack: ByDcaPeriod<AmountPerBlock<M>>,
pub cost_basis: ByDcaPeriod<Price<PerBlock<Cents, M>>>,
pub r#return: ByDcaPeriod<PercentPerBlock<BasisPointsSigned32, M>>,
pub cagr: ByDcaCagr<PercentPerBlock<BasisPointsSigned32, M>>,
pub dca_stack: ByDcaPeriod<AmountPerBlock<M>>,
pub dca_cost_basis: ByDcaPeriod<Price<PerBlock<Cents, M>>>,
pub dca_return: ByDcaPeriod<PercentPerBlock<BasisPointsSigned32, M>>,
pub dca_cagr: ByDcaCagr<PercentPerBlock<BasisPointsSigned32, M>>,
pub lump_sum_stack: ByDcaPeriod<AmountPerBlock<M>>,
pub lump_sum_return: ByDcaPeriod<PercentPerBlock<BasisPointsSigned32, M>>,
}
#[derive(Traversable)]
pub struct ClassVecs<M: StorageMode = Rw> {
pub stack: ByDcaClass<AmountPerBlock<M>>,
pub cost_basis: ByDcaClass<Price<PerBlock<Cents, M>>>,
pub r#return: ByDcaClass<PercentPerBlock<BasisPointsSigned32, M>>,
pub dca_stack: ByDcaClass<AmountPerBlock<M>>,
pub dca_cost_basis: ByDcaClass<Price<PerBlock<Cents, M>>>,
pub dca_return: ByDcaClass<PercentPerBlock<BasisPointsSigned32, M>>,
}
#[derive(Traversable)]