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)]

View File

@@ -5046,16 +5046,16 @@ function createTransferPattern(client, acc) {
/**
* @typedef {Object} SeriesTree_Investing_Period
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} stack
* @property {SeriesTree_Investing_Period_CostBasis} costBasis
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} return
* @property {_10y2y3y4y5y6y8yPattern} cagr
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} dcaStack
* @property {SeriesTree_Investing_Period_DcaCostBasis} dcaCostBasis
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} dcaReturn
* @property {_10y2y3y4y5y6y8yPattern} dcaCagr
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} lumpSumStack
* @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} lumpSumReturn
*/
/**
* @typedef {Object} SeriesTree_Investing_Period_CostBasis
* @typedef {Object} SeriesTree_Investing_Period_DcaCostBasis
* @property {CentsSatsUsdPattern} _1w
* @property {CentsSatsUsdPattern} _1m
* @property {CentsSatsUsdPattern} _3m
@@ -5072,13 +5072,13 @@ function createTransferPattern(client, acc) {
/**
* @typedef {Object} SeriesTree_Investing_Class
* @property {SeriesTree_Investing_Class_Stack} stack
* @property {SeriesTree_Investing_Class_CostBasis} costBasis
* @property {SeriesTree_Investing_Class_Return} return
* @property {SeriesTree_Investing_Class_DcaStack} dcaStack
* @property {SeriesTree_Investing_Class_DcaCostBasis} dcaCostBasis
* @property {SeriesTree_Investing_Class_DcaReturn} dcaReturn
*/
/**
* @typedef {Object} SeriesTree_Investing_Class_Stack
* @typedef {Object} SeriesTree_Investing_Class_DcaStack
* @property {BtcCentsSatsUsdPattern3} from2015
* @property {BtcCentsSatsUsdPattern3} from2016
* @property {BtcCentsSatsUsdPattern3} from2017
@@ -5094,7 +5094,7 @@ function createTransferPattern(client, acc) {
*/
/**
* @typedef {Object} SeriesTree_Investing_Class_CostBasis
* @typedef {Object} SeriesTree_Investing_Class_DcaCostBasis
* @property {CentsSatsUsdPattern} from2015
* @property {CentsSatsUsdPattern} from2016
* @property {CentsSatsUsdPattern} from2017
@@ -5110,7 +5110,7 @@ function createTransferPattern(client, acc) {
*/
/**
* @typedef {Object} SeriesTree_Investing_Class_Return
* @typedef {Object} SeriesTree_Investing_Class_DcaReturn
* @property {BpsPercentRatioPattern} from2015
* @property {BpsPercentRatioPattern} from2016
* @property {BpsPercentRatioPattern} from2017
@@ -8158,8 +8158,8 @@ class BrkClient extends BrkClientBase {
investing: {
satsPerDay: createSeriesPattern18(this, 'dca_sats_per_day'),
period: {
stack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'dca_stack'),
costBasis: {
dcaStack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'dca_stack'),
dcaCostBasis: {
_1w: createCentsSatsUsdPattern(this, 'dca_cost_basis_1w'),
_1m: createCentsSatsUsdPattern(this, 'dca_cost_basis_1m'),
_3m: createCentsSatsUsdPattern(this, 'dca_cost_basis_3m'),
@@ -8173,13 +8173,13 @@ class BrkClient extends BrkClientBase {
_8y: createCentsSatsUsdPattern(this, 'dca_cost_basis_8y'),
_10y: createCentsSatsUsdPattern(this, 'dca_cost_basis_10y'),
},
return: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'dca_return'),
cagr: create_10y2y3y4y5y6y8yPattern(this, 'dca_cagr'),
dcaReturn: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'dca_return'),
dcaCagr: create_10y2y3y4y5y6y8yPattern(this, 'dca_cagr'),
lumpSumStack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'lump_sum_stack'),
lumpSumReturn: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'lump_sum_return'),
},
class: {
stack: {
dcaStack: {
from2015: createBtcCentsSatsUsdPattern3(this, 'dca_stack_from_2015'),
from2016: createBtcCentsSatsUsdPattern3(this, 'dca_stack_from_2016'),
from2017: createBtcCentsSatsUsdPattern3(this, 'dca_stack_from_2017'),
@@ -8193,7 +8193,7 @@ class BrkClient extends BrkClientBase {
from2025: createBtcCentsSatsUsdPattern3(this, 'dca_stack_from_2025'),
from2026: createBtcCentsSatsUsdPattern3(this, 'dca_stack_from_2026'),
},
costBasis: {
dcaCostBasis: {
from2015: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2015'),
from2016: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2016'),
from2017: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2017'),
@@ -8207,7 +8207,7 @@ class BrkClient extends BrkClientBase {
from2025: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2025'),
from2026: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2026'),
},
return: {
dcaReturn: {
from2015: createBpsPercentRatioPattern(this, 'dca_return_from_2015'),
from2016: createBpsPercentRatioPattern(this, 'dca_return_from_2016'),
from2017: createBpsPercentRatioPattern(this, 'dca_return_from_2017'),

View File

@@ -4220,7 +4220,7 @@ class SeriesTree_Indicators:
self.seller_exhaustion: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'seller_exhaustion')
self.realized_envelope: SeriesTree_Indicators_RealizedEnvelope = SeriesTree_Indicators_RealizedEnvelope(client)
class SeriesTree_Investing_Period_CostBasis:
class SeriesTree_Investing_Period_DcaCostBasis:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -4241,14 +4241,14 @@ class SeriesTree_Investing_Period:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'dca_stack')
self.cost_basis: SeriesTree_Investing_Period_CostBasis = SeriesTree_Investing_Period_CostBasis(client)
self.return_: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'dca_return')
self.cagr: _10y2y3y4y5y6y8yPattern = _10y2y3y4y5y6y8yPattern(client, 'dca_cagr')
self.dca_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'dca_stack')
self.dca_cost_basis: SeriesTree_Investing_Period_DcaCostBasis = SeriesTree_Investing_Period_DcaCostBasis(client)
self.dca_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'dca_return')
self.dca_cagr: _10y2y3y4y5y6y8yPattern = _10y2y3y4y5y6y8yPattern(client, 'dca_cagr')
self.lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'lump_sum_stack')
self.lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'lump_sum_return')
class SeriesTree_Investing_Class_Stack:
class SeriesTree_Investing_Class_DcaStack:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -4265,7 +4265,7 @@ class SeriesTree_Investing_Class_Stack:
self.from_2025: BtcCentsSatsUsdPattern3 = BtcCentsSatsUsdPattern3(client, 'dca_stack_from_2025')
self.from_2026: BtcCentsSatsUsdPattern3 = BtcCentsSatsUsdPattern3(client, 'dca_stack_from_2026')
class SeriesTree_Investing_Class_CostBasis:
class SeriesTree_Investing_Class_DcaCostBasis:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -4282,7 +4282,7 @@ class SeriesTree_Investing_Class_CostBasis:
self.from_2025: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_from_2025')
self.from_2026: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_from_2026')
class SeriesTree_Investing_Class_Return:
class SeriesTree_Investing_Class_DcaReturn:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -4303,9 +4303,9 @@ class SeriesTree_Investing_Class:
"""Series tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.stack: SeriesTree_Investing_Class_Stack = SeriesTree_Investing_Class_Stack(client)
self.cost_basis: SeriesTree_Investing_Class_CostBasis = SeriesTree_Investing_Class_CostBasis(client)
self.return_: SeriesTree_Investing_Class_Return = SeriesTree_Investing_Class_Return(client)
self.dca_stack: SeriesTree_Investing_Class_DcaStack = SeriesTree_Investing_Class_DcaStack(client)
self.dca_cost_basis: SeriesTree_Investing_Class_DcaCostBasis = SeriesTree_Investing_Class_DcaCostBasis(client)
self.dca_return: SeriesTree_Investing_Class_DcaReturn = SeriesTree_Investing_Class_DcaReturn(client)
class SeriesTree_Investing:
"""Series tree node."""

View File

@@ -44,13 +44,13 @@ def test_fetch_typed_series():
c = client.series.prices.split.close.usd.by.day1().tail(10).fetch()
print(c)
d = (
client.series.market.dca.period.lump_sum_stack._10y.usd.by.day1()
client.series.investing.period.lump_sum_stack._10y.usd.by.day1()
.tail(10)
.fetch()
)
print(d)
e = (
client.series.market.dca.class_.cost_basis.from_2017.usd.by.day1()
client.series.investing.class_.dca_cost_basis.from_2017.usd.by.day1()
.tail(10)
.fetch()
)

View File

@@ -50,7 +50,7 @@ wheels = [
[[package]]
name = "brk-client"
version = "0.1.9"
version = "0.2.2"
source = { editable = "." }
[package.dev-dependencies]

View File

@@ -79,9 +79,9 @@ function buildYearEntry(investing, year, i) {
return {
name: `${year}`,
color: colors.at(i, ALL_YEARS.length),
costBasis: investing.class.costBasis[key],
returns: investing.class.return[key],
stack: investing.class.stack[key],
costBasis: investing.class.dcaCostBasis[key],
returns: investing.class.dcaReturn[key],
stack: investing.class.dcaStack[key],
};
}
@@ -231,7 +231,10 @@ function createSingleEntryTree(item, returnsBottom) {
* @param {BaseEntryItem & { titlePrefix?: string }} item
*/
function createShortSingleEntry(item) {
return createSingleEntryTree(item, percentRatioBaseline({ pattern: item.returns, name: "Return" }));
return createSingleEntryTree(
item,
percentRatioBaseline({ pattern: item.returns, name: "Return" }),
);
}
/**
@@ -239,7 +242,15 @@ function createShortSingleEntry(item) {
* @param {LongEntryItem & { titlePrefix?: string }} item
*/
function createLongSingleEntry(item) {
const { name, titlePrefix = name, color, costBasis, returns, cagr, stack } = item;
const {
name,
titlePrefix = name,
color,
costBasis,
returns,
cagr,
stack,
} = item;
const top = [price({ series: costBasis, name: "Cost Basis", color })];
return {
name,
@@ -278,7 +289,7 @@ export function createDcaVsLumpSumSection({ investing, lookback, returns }) {
/** @param {AllPeriodKey} key */
const topPane = (key) => [
price({
series: investing.period.costBasis[key],
series: investing.period.dcaCostBasis[key],
name: "DCA",
color: colors.profit,
}),
@@ -299,7 +310,7 @@ export function createDcaVsLumpSumSection({ investing, lookback, returns }) {
top: topPane(key),
bottom: [
...percentRatioBaseline({
pattern: investing.period.return[key],
pattern: investing.period.dcaReturn[key],
name: "DCA",
}),
...percentRatioBaseline({
@@ -317,7 +328,7 @@ export function createDcaVsLumpSumSection({ investing, lookback, returns }) {
top: topPane(key),
bottom: [
...percentRatioBaseline({
pattern: investing.period.cagr[key],
pattern: investing.period.dcaCagr[key],
name: "DCA",
}),
...percentRatioBaseline({
@@ -335,7 +346,7 @@ export function createDcaVsLumpSumSection({ investing, lookback, returns }) {
top: topPane(key),
bottom: [
...satsBtcUsd({
pattern: investing.period.stack[key],
pattern: investing.period.dcaStack[key],
name: "DCA",
color: colors.profit,
}),
@@ -409,20 +420,20 @@ function createPeriodSection({ investing, lookback, returns }) {
const buildBaseEntry = (key, i) => ({
name: periodName(key),
color: colors.at(i, allPeriods.length),
costBasis: isLumpSum ? lookback[key] : investing.period.costBasis[key],
costBasis: isLumpSum ? lookback[key] : investing.period.dcaCostBasis[key],
returns: isLumpSum
? investing.period.lumpSumReturn[key]
: investing.period.return[key],
: investing.period.dcaReturn[key],
stack: isLumpSum
? investing.period.lumpSumStack[key]
: investing.period.stack[key],
: investing.period.dcaStack[key],
});
/** @param {LongPeriodKey} key @param {number} i @returns {LongEntryItem} */
const buildLongEntry = (key, i) =>
withCagr(
buildBaseEntry(key, i),
isLumpSum ? returns.cagr[key] : investing.period.cagr[key],
isLumpSum ? returns.cagr[key] : investing.period.dcaCagr[key],
);
/** @param {BaseEntryItem} entry */

View File

@@ -411,10 +411,6 @@ export function revenueRollingBtcSatsUsd({ coinbase, subsidy, fee }) {
];
}
/**
* Build percentile USD mappings from a ratio pattern
* @param {AnyRatioPattern} ratio
*/
/** @param {AnyRatioPattern} ratio */
export function percentileUsdMap(ratio) {
return percentileBandsWith(ratio.percentiles, (e) => e.price);