computer: add tx annualized volume + tx velocity + rename _in_usd/_in_btc to _usd/_btc

This commit is contained in:
nym21
2025-09-13 00:29:34 +02:00
parent e3b4b9b618
commit 38d5c7dff6
11 changed files with 466 additions and 335 deletions

View File

@@ -29,12 +29,12 @@ pub struct ComputedRatioVecsFromDateIndex {
pub ratio_pct5: Option<ComputedVecsFromDateIndex<StoredF32>>,
pub ratio_pct2: Option<ComputedVecsFromDateIndex<StoredF32>>,
pub ratio_pct1: Option<ComputedVecsFromDateIndex<StoredF32>>,
pub ratio_pct99_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct98_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct95_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct5_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct2_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct1_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct99_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct98_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct95_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct5_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct2_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_pct1_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub ratio_sd: Option<ComputedStandardDeviationVecsFromDateIndex>,
pub ratio_4y_sd: Option<ComputedStandardDeviationVecsFromDateIndex>,
@@ -212,10 +212,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct99_in_usd: extended.then(|| {
ratio_pct99_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct99_in_usd"),
&format!("{name}_ratio_pct99_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -223,10 +223,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct98_in_usd: extended.then(|| {
ratio_pct98_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct98_in_usd"),
&format!("{name}_ratio_pct98_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -234,10 +234,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct95_in_usd: extended.then(|| {
ratio_pct95_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct95_in_usd"),
&format!("{name}_ratio_pct95_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -245,10 +245,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct5_in_usd: extended.then(|| {
ratio_pct5_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct5_in_usd"),
&format!("{name}_ratio_pct5_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -256,10 +256,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct2_in_usd: extended.then(|| {
ratio_pct2_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct2_in_usd"),
&format!("{name}_ratio_pct2_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -267,10 +267,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
ratio_pct1_in_usd: extended.then(|| {
ratio_pct1_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_ratio_pct1_in_usd"),
&format!("{name}_ratio_pct1_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -529,7 +529,7 @@ impl ComputedRatioVecsFromDateIndex {
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
});
self.ratio_pct99_in_usd
self.ratio_pct99_usd
.as_mut()
.unwrap()
.compute_all(starting_indexes, exit, |vec| {
@@ -553,10 +553,10 @@ impl ComputedRatioVecsFromDateIndex {
Ok(())
})?;
let compute_in_usd =
|in_usd: Option<&mut ComputedVecsFromDateIndex<Dollars>>,
let compute_usd =
|usd: Option<&mut ComputedVecsFromDateIndex<Dollars>>,
source: Option<&ComputedVecsFromDateIndex<StoredF32>>| {
in_usd.unwrap().compute_all(starting_indexes, exit, |vec| {
usd.unwrap().compute_all(starting_indexes, exit, |vec| {
let mut iter = source.unwrap().dateindex.as_ref().unwrap().into_iter();
vec.compute_transform(
starting_indexes.dateindex,
@@ -571,12 +571,12 @@ impl ComputedRatioVecsFromDateIndex {
})
};
compute_in_usd(self.ratio_pct1_in_usd.as_mut(), self.ratio_pct1.as_ref())?;
compute_in_usd(self.ratio_pct2_in_usd.as_mut(), self.ratio_pct2.as_ref())?;
compute_in_usd(self.ratio_pct5_in_usd.as_mut(), self.ratio_pct5.as_ref())?;
compute_in_usd(self.ratio_pct95_in_usd.as_mut(), self.ratio_pct95.as_ref())?;
compute_in_usd(self.ratio_pct98_in_usd.as_mut(), self.ratio_pct98.as_ref())?;
compute_in_usd(self.ratio_pct99_in_usd.as_mut(), self.ratio_pct99.as_ref())?;
compute_usd(self.ratio_pct1_usd.as_mut(), self.ratio_pct1.as_ref())?;
compute_usd(self.ratio_pct2_usd.as_mut(), self.ratio_pct2.as_ref())?;
compute_usd(self.ratio_pct5_usd.as_mut(), self.ratio_pct5.as_ref())?;
compute_usd(self.ratio_pct95_usd.as_mut(), self.ratio_pct95.as_ref())?;
compute_usd(self.ratio_pct98_usd.as_mut(), self.ratio_pct98.as_ref())?;
compute_usd(self.ratio_pct99_usd.as_mut(), self.ratio_pct99.as_ref())?;
self.ratio_sd.as_mut().unwrap().compute_all(
starting_indexes,
@@ -717,42 +717,42 @@ impl ComputedRatioVecsFromDateIndex {
);
iter = Box::new(
iter.chain(
self.ratio_pct1_in_usd
self.ratio_pct1_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.ratio_pct2_in_usd
self.ratio_pct2_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.ratio_pct5_in_usd
self.ratio_pct5_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.ratio_pct95_in_usd
self.ratio_pct95_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.ratio_pct98_in_usd
self.ratio_pct98_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.ratio_pct99_in_usd
self.ratio_pct99_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),

View File

@@ -32,19 +32,19 @@ pub struct ComputedStandardDeviationVecsFromDateIndex {
pub m2_5sd: Option<ComputedVecsFromDateIndex<StoredF32>>,
pub m3sd: Option<ComputedVecsFromDateIndex<StoredF32>>,
pub _0sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p0_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p1sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p1_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p2sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p2_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p3sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m0_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m1sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m1_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m2sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m2_5sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m3sd_in_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub _0sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p0_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p1sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p1_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p2sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p2_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub p3sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m0_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m1sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m1_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m2sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m2_5sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
pub m3sd_usd: Option<ComputedVecsFromDateIndex<Dollars>>,
}
#[derive(Debug, Default)]
@@ -259,10 +259,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
_0sd_in_usd: options.price_bands().then(|| {
_0sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_0sd_in_usd"),
&format!("{name}_0sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -270,10 +270,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p0_5sd_in_usd: options.price_bands().then(|| {
p0_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p0_5sd_in_usd"),
&format!("{name}_p0_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -281,10 +281,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p1sd_in_usd: options.price_bands().then(|| {
p1sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p1sd_in_usd"),
&format!("{name}_p1sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -292,10 +292,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p1_5sd_in_usd: options.price_bands().then(|| {
p1_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p1_5sd_in_usd"),
&format!("{name}_p1_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -303,10 +303,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p2sd_in_usd: options.price_bands().then(|| {
p2sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p2sd_in_usd"),
&format!("{name}_p2sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -314,10 +314,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p2_5sd_in_usd: options.price_bands().then(|| {
p2_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p2_5sd_in_usd"),
&format!("{name}_p2_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -325,10 +325,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
p3sd_in_usd: options.price_bands().then(|| {
p3sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_p3sd_in_usd"),
&format!("{name}_p3sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -336,10 +336,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m0_5sd_in_usd: options.price_bands().then(|| {
m0_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m0_5sd_in_usd"),
&format!("{name}_m0_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -347,10 +347,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m1sd_in_usd: options.price_bands().then(|| {
m1sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m1sd_in_usd"),
&format!("{name}_m1sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -358,10 +358,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m1_5sd_in_usd: options.price_bands().then(|| {
m1_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m1_5sd_in_usd"),
&format!("{name}_m1_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -369,10 +369,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m2sd_in_usd: options.price_bands().then(|| {
m2sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m2sd_in_usd"),
&format!("{name}_m2sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -380,10 +380,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m2_5sd_in_usd: options.price_bands().then(|| {
m2_5sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m2_5sd_in_usd"),
&format!("{name}_m2_5sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -391,10 +391,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
.unwrap()
}),
m3sd_in_usd: options.price_bands().then(|| {
m3sd_usd: options.price_bands().then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_m3sd_in_usd"),
&format!("{name}_m3sd_usd"),
Source::Compute,
version + Version::ZERO,
indexes,
@@ -630,10 +630,10 @@ impl ComputedStandardDeviationVecsFromDateIndex {
return Ok(());
};
let compute_in_usd =
|in_usd: &mut ComputedVecsFromDateIndex<Dollars>,
let compute_usd =
|usd: &mut ComputedVecsFromDateIndex<Dollars>,
mut iter: BoxedVecIterator<DateIndex, StoredF32>| {
in_usd.compute_all(starting_indexes, exit, |vec| {
usd.compute_all(starting_indexes, exit, |vec| {
vec.compute_transform(
starting_indexes.dateindex,
price,
@@ -647,13 +647,13 @@ impl ComputedStandardDeviationVecsFromDateIndex {
})
};
if self._0sd_in_usd.is_none() {
if self._0sd_usd.is_none() {
return Ok(());
}
compute_in_usd(self._0sd_in_usd.as_mut().unwrap(), sma.iter())?;
compute_in_usd(
self.p0_5sd_in_usd.as_mut().unwrap(),
compute_usd(self._0sd_usd.as_mut().unwrap(), sma.iter())?;
compute_usd(
self.p0_5sd_usd.as_mut().unwrap(),
self.p0_5sd
.as_ref()
.unwrap()
@@ -662,8 +662,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.p1sd_in_usd.as_mut().unwrap(),
compute_usd(
self.p1sd_usd.as_mut().unwrap(),
self.p1sd
.as_ref()
.unwrap()
@@ -672,8 +672,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.p1_5sd_in_usd.as_mut().unwrap(),
compute_usd(
self.p1_5sd_usd.as_mut().unwrap(),
self.p1_5sd
.as_ref()
.unwrap()
@@ -682,8 +682,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.p2sd_in_usd.as_mut().unwrap(),
compute_usd(
self.p2sd_usd.as_mut().unwrap(),
self.p2sd
.as_ref()
.unwrap()
@@ -692,8 +692,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.p2_5sd_in_usd.as_mut().unwrap(),
compute_usd(
self.p2_5sd_usd.as_mut().unwrap(),
self.p2_5sd
.as_ref()
.unwrap()
@@ -702,8 +702,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.p3sd_in_usd.as_mut().unwrap(),
compute_usd(
self.p3sd_usd.as_mut().unwrap(),
self.p3sd
.as_ref()
.unwrap()
@@ -712,8 +712,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m0_5sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m0_5sd_usd.as_mut().unwrap(),
self.m0_5sd
.as_ref()
.unwrap()
@@ -722,8 +722,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m1sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m1sd_usd.as_mut().unwrap(),
self.m1sd
.as_ref()
.unwrap()
@@ -732,8 +732,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m1_5sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m1_5sd_usd.as_mut().unwrap(),
self.m1_5sd
.as_ref()
.unwrap()
@@ -742,8 +742,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m2sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m2sd_usd.as_mut().unwrap(),
self.m2sd
.as_ref()
.unwrap()
@@ -752,8 +752,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m2_5sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m2_5sd_usd.as_mut().unwrap(),
self.m2_5sd
.as_ref()
.unwrap()
@@ -762,8 +762,8 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.unwrap()
.iter(),
)?;
compute_in_usd(
self.m3sd_in_usd.as_mut().unwrap(),
compute_usd(
self.m3sd_usd.as_mut().unwrap(),
self.m3sd
.as_ref()
.unwrap()
@@ -822,97 +822,55 @@ impl ComputedStandardDeviationVecsFromDateIndex {
iter = Box::new(iter.chain(self.m2sd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(iter.chain(self.m2_5sd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(iter.chain(self.m3sd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(iter.chain(self._0sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self._0sd_in_usd
self.p0_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.p1sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self.p0_5sd_in_usd
self.p1_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.p2sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self.p1sd_in_usd
self.p2_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.p3sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self.p1_5sd_in_usd
self.m0_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.m1sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self.p2sd_in_usd
self.m1_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.m2sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(
iter.chain(
self.p2_5sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.p3sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m0_5sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m1sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m1_5sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m2sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m2_5sd_in_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(
iter.chain(
self.m3sd_in_usd
self.m2_5sd_usd
.iter()
.flat_map(|v| v.iter_any_collectable()),
),
);
iter = Box::new(iter.chain(self.m3sd_usd.iter().flat_map(|v| v.iter_any_collectable())));
iter = Box::new(iter.chain(self.zscore.iter().flat_map(|v| v.iter_any_collectable())));
iter

View File

@@ -42,7 +42,7 @@ impl ComputedValueVecsFromDateIndex {
)?,
bitcoin: ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_in_btc"),
&format!("{name}_btc"),
Source::Compute,
version + VERSION,
indexes,
@@ -51,7 +51,7 @@ impl ComputedValueVecsFromDateIndex {
dollars: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
&format!("{name}_in_usd"),
&format!("{name}_usd"),
Source::Compute,
version + VERSION,
indexes,

View File

@@ -43,7 +43,7 @@ impl ComputedValueVecsFromHeight {
)?,
bitcoin: ComputedVecsFromHeight::forced_import(
db,
&format!("{name}_in_btc"),
&format!("{name}_btc"),
Source::Compute,
version + VERSION,
indexes,
@@ -52,7 +52,7 @@ impl ComputedValueVecsFromHeight {
dollars: compute_dollars.then(|| {
ComputedVecsFromHeight::forced_import(
db,
&format!("{name}_in_usd"),
&format!("{name}_usd"),
Source::Compute,
version + VERSION,
indexes,

View File

@@ -38,8 +38,8 @@ impl ComputedValueVecsFromTxindex {
) -> Result<Self> {
let compute_dollars = price.is_some();
let name_in_btc = format!("{name}_in_btc");
let name_in_usd = format!("{name}_in_usd");
let name_btc = format!("{name}_btc");
let name_usd = format!("{name}_usd");
let sats = ComputedVecsFromTxindex::forced_import(
db,
@@ -53,7 +53,7 @@ impl ComputedValueVecsFromTxindex {
let source_vec = source.vec();
let bitcoin_txindex = LazyVecFrom1::init(
&name_in_btc,
&name_btc,
version + VERSION,
source_vec.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s),
|txindex: TxIndex, iter| {
@@ -66,7 +66,7 @@ impl ComputedValueVecsFromTxindex {
let bitcoin = ComputedVecsFromTxindex::forced_import(
db,
&name_in_btc,
&name_btc,
Source::None,
version + VERSION,
indexes,
@@ -75,29 +75,27 @@ impl ComputedValueVecsFromTxindex {
let dollars_txindex = price.map(|price| {
LazyVecFrom3::init(
&name_in_usd,
&name_usd,
version + VERSION,
bitcoin_txindex.boxed_clone(),
indexes.txindex_to_height.boxed_clone(),
price.chainindexes_to_price_close.height.boxed_clone(),
|txindex: TxIndex,
txindex_to_in_btc_iter,
txindex_to_btc_iter,
txindex_to_height_iter,
height_to_price_close_iter| {
let txindex = txindex.unwrap_to_usize();
txindex_to_in_btc_iter
.next_at(txindex)
.and_then(|(_, value)| {
let btc = value.into_owned();
txindex_to_height_iter
.next_at(txindex)
.and_then(|(_, value)| {
let height = value.into_owned();
height_to_price_close_iter
.next_at(height.unwrap_to_usize())
.map(|(_, close)| *close.into_owned() * btc)
})
})
txindex_to_btc_iter.next_at(txindex).and_then(|(_, value)| {
let btc = value.into_owned();
txindex_to_height_iter
.next_at(txindex)
.and_then(|(_, value)| {
let height = value.into_owned();
height_to_price_close_iter
.next_at(height.unwrap_to_usize())
.map(|(_, close)| *close.into_owned() * btc)
})
})
},
)
});
@@ -110,7 +108,7 @@ impl ComputedValueVecsFromTxindex {
dollars: compute_dollars.then(|| {
ComputedVecsFromTxindex::forced_import(
db,
&name_in_usd,
&name_usd,
Source::None,
version + VERSION,
indexes,

View File

@@ -34,14 +34,14 @@ impl ComputedHeightValueVecs {
}),
bitcoin: EagerVec::forced_import(
db,
&format!("{name}_in_btc"),
&format!("{name}_btc"),
version + VERSION + Version::ZERO,
format,
)?,
dollars: compute_dollars.then(|| {
EagerVec::forced_import(
db,
&format!("{name}_in_usd"),
&format!("{name}_usd"),
version + VERSION + Version::ZERO,
format,
)