mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
computer: add tx annualized volume + tx velocity + rename _in_usd/_in_btc to _usd/_btc
This commit is contained in:
@@ -4,13 +4,13 @@ use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
CheckedSub, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch, Height,
|
||||
InputIndex, MonthIndex, OutputIndex, QuarterIndex, Sats, SemesterIndex, StoredBool, StoredF32,
|
||||
StoredF64, StoredU32, StoredU64, Timestamp, TxIndex, TxVersion, Version, WeekIndex, Weight,
|
||||
YearIndex,
|
||||
Bitcoin, CheckedSub, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch,
|
||||
Height, InputIndex, MonthIndex, OutputIndex, QuarterIndex, Sats, SemesterIndex, StoredBool,
|
||||
StoredF32, StoredF64, StoredU32, StoredU64, Timestamp, TxIndex, TxVersion, Version, WeekIndex,
|
||||
Weight, YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, AnyVec, Database, EagerVec, Exit,
|
||||
AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit,
|
||||
LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, PAGE_SIZE, StoredIndex, VecIterator,
|
||||
};
|
||||
|
||||
@@ -21,7 +21,6 @@ use crate::grouped::{
|
||||
|
||||
use super::{Indexes, indexes, price};
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
const TARGET_BLOCKS_PER_DAY_F64: f64 = 144.0;
|
||||
const TARGET_BLOCKS_PER_DAY_F32: f32 = 144.0;
|
||||
const TARGET_BLOCKS_PER_DAY: u64 = 144;
|
||||
@@ -51,7 +50,7 @@ pub struct Vecs {
|
||||
pub height_to_interval: EagerVec<Height, Timestamp>,
|
||||
pub height_to_24h_block_count: EagerVec<Height, StoredU32>,
|
||||
pub height_to_24h_coinbase_sum: EagerVec<Height, Sats>,
|
||||
pub height_to_24h_coinbase_in_usd_sum: EagerVec<Height, Dollars>,
|
||||
pub height_to_24h_coinbase_usd_sum: EagerVec<Height, Dollars>,
|
||||
pub height_to_vbytes: EagerVec<Height, StoredU64>,
|
||||
pub difficultyepoch_to_timestamp: EagerVec<DifficultyEpoch, Timestamp>,
|
||||
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
|
||||
@@ -134,24 +133,31 @@ pub struct Vecs {
|
||||
pub indexes_to_blocks_before_next_halving: ComputedVecsFromHeight<StoredU32>,
|
||||
pub indexes_to_days_before_next_halving: ComputedVecsFromHeight<StoredF32>,
|
||||
pub indexes_to_inflation_rate: ComputedVecsFromDateIndex<StoredF32>,
|
||||
pub indexes_to_annualized_volume: ComputedVecsFromDateIndex<Sats>,
|
||||
pub indexes_to_annualized_volume_btc: ComputedVecsFromDateIndex<Bitcoin>,
|
||||
pub indexes_to_annualized_volume_usd: ComputedVecsFromDateIndex<Dollars>,
|
||||
pub indexes_to_velocity_btc: ComputedVecsFromDateIndex<StoredF64>,
|
||||
pub indexes_to_velocity_usd: ComputedVecsFromDateIndex<StoredF64>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(
|
||||
parent: &Path,
|
||||
version: Version,
|
||||
parent_path: &Path,
|
||||
parent_version: Version,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
) -> Result<Self> {
|
||||
let db = Database::open(&parent.join("chain"))?;
|
||||
let db = Database::open(&parent_path.join("chain"))?;
|
||||
db.set_min_len(PAGE_SIZE * 10_000_000)?;
|
||||
|
||||
let version = parent_version + Version::ZERO;
|
||||
|
||||
let compute_dollars = price.is_some();
|
||||
|
||||
let inputindex_to_value = LazyVecFrom2::init(
|
||||
"value",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.inputindex_to_outputindex.boxed_clone(),
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
|index: InputIndex, inputindex_to_outputindex_iter, outputindex_to_value_iter| {
|
||||
@@ -175,7 +181,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_weight = LazyVecFrom2::init(
|
||||
"weight",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_base_size.boxed_clone(),
|
||||
indexer.vecs.txindex_to_total_size.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_base_size_iter, txindex_to_total_size_iter| {
|
||||
@@ -200,7 +206,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_vsize = LazyVecFrom1::init(
|
||||
"vsize",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
txindex_to_weight.boxed_clone(),
|
||||
|index: TxIndex, iter| {
|
||||
let index = index.unwrap_to_usize();
|
||||
@@ -214,7 +220,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_is_coinbase = LazyVecFrom2::init(
|
||||
"is_coinbase",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.txindex_to_height.boxed_clone(),
|
||||
indexer.vecs.height_to_first_txindex.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_height_iter, height_to_first_txindex_iter| {
|
||||
@@ -234,7 +240,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_input_value = LazyVecFrom3::init(
|
||||
"input_value",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_inputindex.boxed_clone(),
|
||||
indexes.txindex_to_input_count.boxed_clone(),
|
||||
inputindex_to_value.boxed_clone(),
|
||||
@@ -270,7 +276,7 @@ impl Vecs {
|
||||
// db,
|
||||
// "input_value",
|
||||
// true,
|
||||
// version + VERSION + Version::ZERO,
|
||||
// version + Version::ZERO,
|
||||
// format,
|
||||
// computation,
|
||||
// StorableVecGeneatorOptions::default()
|
||||
@@ -281,7 +287,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_output_value = LazyVecFrom3::init(
|
||||
"output_value",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_outputindex.boxed_clone(),
|
||||
indexes.txindex_to_output_count.boxed_clone(),
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
@@ -317,7 +323,7 @@ impl Vecs {
|
||||
// db,
|
||||
// "output_value",
|
||||
// true,
|
||||
// version + VERSION + Version::ZERO,
|
||||
// version + Version::ZERO,
|
||||
// format,
|
||||
// computation,
|
||||
// StorableVecGeneatorOptions::default()
|
||||
@@ -327,50 +333,50 @@ impl Vecs {
|
||||
// )?;
|
||||
|
||||
let txindex_to_fee =
|
||||
EagerVec::forced_import_compressed(&db, "fee", version + VERSION + Version::ZERO)?;
|
||||
EagerVec::forced_import_compressed(&db, "fee", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_fee_rate =
|
||||
EagerVec::forced_import_compressed(&db, "fee_rate", version + VERSION + Version::ZERO)?;
|
||||
EagerVec::forced_import_compressed(&db, "fee_rate", version + Version::ZERO)?;
|
||||
|
||||
let dateindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.dateindex_to_dateindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_DAY)),
|
||||
);
|
||||
let weekindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.weekindex_to_weekindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_WEEK)),
|
||||
);
|
||||
let monthindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.monthindex_to_monthindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_MONTH)),
|
||||
);
|
||||
let quarterindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.quarterindex_to_quarterindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_QUARTER)),
|
||||
);
|
||||
let semesterindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.semesterindex_to_semesterindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_SEMESTER)),
|
||||
);
|
||||
let yearindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.yearindex_to_yearindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_YEAR)),
|
||||
);
|
||||
let decadeindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes.decadeindex_to_decadeindex.boxed_clone(),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_DECADE)),
|
||||
);
|
||||
@@ -386,13 +392,13 @@ impl Vecs {
|
||||
height_to_interval: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"interval",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
timeindexes_to_timestamp: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"timestamp",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_first(),
|
||||
)?,
|
||||
@@ -400,7 +406,7 @@ impl Vecs {
|
||||
&db,
|
||||
"block_interval",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_percentiles()
|
||||
@@ -411,7 +417,7 @@ impl Vecs {
|
||||
&db,
|
||||
"block_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||
)?,
|
||||
@@ -419,7 +425,7 @@ impl Vecs {
|
||||
&db,
|
||||
"1w_block_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -427,7 +433,7 @@ impl Vecs {
|
||||
&db,
|
||||
"1m_block_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -435,7 +441,7 @@ impl Vecs {
|
||||
&db,
|
||||
"1y_block_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -443,7 +449,7 @@ impl Vecs {
|
||||
&db,
|
||||
"block_weight",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_sum()
|
||||
@@ -456,7 +462,7 @@ impl Vecs {
|
||||
&db,
|
||||
"block_size",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_sum()
|
||||
@@ -468,28 +474,28 @@ impl Vecs {
|
||||
height_to_vbytes: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"vbytes",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_block_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"24h_block_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_coinbase_sum: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"24h_coinbase_sum",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_coinbase_in_usd_sum: EagerVec::forced_import_compressed(
|
||||
height_to_24h_coinbase_usd_sum: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"24h_coinbase_in_usd_sum",
|
||||
version + VERSION + Version::ZERO,
|
||||
"24h_coinbase_usd_sum",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
indexes_to_block_vbytes: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"block_vbytes",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_sum()
|
||||
@@ -501,29 +507,29 @@ impl Vecs {
|
||||
difficultyepoch_to_timestamp: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"timestamp",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_timestamp: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"timestamp",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
|
||||
dateindex_to_fee_dominance: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"fee_dominance",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_subsidy_dominance: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"subsidy_dominance",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
indexes_to_difficulty: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"difficulty",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -531,7 +537,7 @@ impl Vecs {
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -539,7 +545,7 @@ impl Vecs {
|
||||
&db,
|
||||
"halvingepoch",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -547,7 +553,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -560,7 +566,7 @@ impl Vecs {
|
||||
&db,
|
||||
"input_count",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -573,7 +579,7 @@ impl Vecs {
|
||||
&db,
|
||||
"output_count",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -586,7 +592,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_v1",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||
)?,
|
||||
@@ -594,7 +600,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_v2",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||
)?,
|
||||
@@ -602,7 +608,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_v3",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||
)?,
|
||||
@@ -610,7 +616,7 @@ impl Vecs {
|
||||
&db,
|
||||
"sent",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
VecBuilderOptions::default().add_sum(),
|
||||
compute_dollars,
|
||||
indexes,
|
||||
@@ -620,7 +626,7 @@ impl Vecs {
|
||||
"fee",
|
||||
indexes,
|
||||
Source::Vec(txindex_to_fee.boxed_clone()),
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
price,
|
||||
VecBuilderOptions::default()
|
||||
.add_sum()
|
||||
@@ -633,7 +639,7 @@ impl Vecs {
|
||||
&db,
|
||||
"fee_rate",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_percentiles()
|
||||
@@ -644,7 +650,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_vsize",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_percentiles()
|
||||
@@ -655,7 +661,7 @@ impl Vecs {
|
||||
&db,
|
||||
"tx_weight",
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_percentiles()
|
||||
@@ -666,7 +672,7 @@ impl Vecs {
|
||||
&db,
|
||||
"subsidy",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
VecBuilderOptions::default()
|
||||
.add_percentiles()
|
||||
.add_sum()
|
||||
@@ -680,7 +686,7 @@ impl Vecs {
|
||||
&db,
|
||||
"coinbase",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
VecBuilderOptions::default()
|
||||
.add_sum()
|
||||
.add_cumulative()
|
||||
@@ -694,7 +700,7 @@ impl Vecs {
|
||||
&db,
|
||||
"unclaimed_rewards",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||
compute_dollars,
|
||||
indexes,
|
||||
@@ -703,7 +709,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2a_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -716,7 +722,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2ms_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -729,7 +735,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2pk33_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -742,7 +748,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2pk65_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -755,7 +761,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2pkh_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -768,7 +774,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2sh_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -781,7 +787,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2tr_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -794,7 +800,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2wpkh_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -807,7 +813,7 @@ impl Vecs {
|
||||
&db,
|
||||
"p2wsh_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -820,7 +826,7 @@ impl Vecs {
|
||||
&db,
|
||||
"opreturn_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -833,7 +839,7 @@ impl Vecs {
|
||||
&db,
|
||||
"unknownoutput_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -846,7 +852,7 @@ impl Vecs {
|
||||
&db,
|
||||
"emptyoutput_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
@@ -859,7 +865,7 @@ impl Vecs {
|
||||
&db,
|
||||
"exact_utxo_count",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -868,7 +874,7 @@ impl Vecs {
|
||||
&db,
|
||||
"subsidy_usd_1y_sma",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)
|
||||
@@ -879,7 +885,7 @@ impl Vecs {
|
||||
&db,
|
||||
"puell_multiple",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)
|
||||
@@ -889,7 +895,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_rate",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(5),
|
||||
version + Version::new(5),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -897,7 +903,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_rate_1w_sma",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -905,7 +911,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_rate_1m_sma",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -913,7 +919,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_rate_2m_sma",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -921,7 +927,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_rate_1y_sma",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -929,7 +935,7 @@ impl Vecs {
|
||||
&db,
|
||||
"difficulty_as_hash",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -937,7 +943,7 @@ impl Vecs {
|
||||
&db,
|
||||
"difficulty_adjustment",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_sum(),
|
||||
)?,
|
||||
@@ -946,7 +952,7 @@ impl Vecs {
|
||||
&db,
|
||||
"blocks_before_next_difficulty_adjustment",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::TWO,
|
||||
version + Version::TWO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -955,7 +961,7 @@ impl Vecs {
|
||||
&db,
|
||||
"days_before_next_difficulty_adjustment",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::TWO,
|
||||
version + Version::TWO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -963,7 +969,7 @@ impl Vecs {
|
||||
&db,
|
||||
"blocks_before_next_halving",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::TWO,
|
||||
version + Version::TWO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -971,7 +977,7 @@ impl Vecs {
|
||||
&db,
|
||||
"days_before_next_halving",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::TWO,
|
||||
version + Version::TWO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -979,7 +985,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_price_ths",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -987,7 +993,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_price_phs",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -995,7 +1001,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_value_ths",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1003,7 +1009,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_value_phs",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1011,7 +1017,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_price_ths_min",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1019,7 +1025,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_price_phs_min",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1027,7 +1033,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_price_rebound",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1035,7 +1041,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_value_ths_min",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1043,7 +1049,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_value_phs_min",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1051,7 +1057,7 @@ impl Vecs {
|
||||
&db,
|
||||
"hash_value_rebound",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::new(4),
|
||||
version + Version::new(4),
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1059,7 +1065,47 @@ impl Vecs {
|
||||
&db,
|
||||
"inflation_rate",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_annualized_volume: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"annualized_volume",
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_annualized_volume_btc: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"annualized_volume_btc",
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_annualized_volume_usd: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"annualized_volume_usd",
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_velocity_btc: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"velocity_btc",
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_velocity_usd: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"velocity_usd",
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -1506,7 +1552,7 @@ impl Vecs {
|
||||
.as_ref()
|
||||
.map(|c| c.height.as_ref().unwrap().into_iter())
|
||||
{
|
||||
self.height_to_24h_coinbase_in_usd_sum.compute_transform(
|
||||
self.height_to_24h_coinbase_usd_sum.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.height_to_24h_block_count,
|
||||
|(h, count, ..)| {
|
||||
@@ -1977,7 +2023,7 @@ impl Vecs {
|
||||
.compute_all(indexes, starting_indexes, exit, |v| {
|
||||
v.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.height_to_24h_coinbase_in_usd_sum,
|
||||
&self.height_to_24h_coinbase_usd_sum,
|
||||
self.indexes_to_hash_rate.height.as_ref().unwrap(),
|
||||
|(i, coinbase_sum, hashrate, ..)| {
|
||||
(i, (*coinbase_sum / (*hashrate / ONE_TERA_HASH)).into())
|
||||
@@ -2092,6 +2138,77 @@ impl Vecs {
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_annualized_volume
|
||||
.compute_all(starting_indexes, exit, |v| {
|
||||
v.compute_sum(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_sent.sats.dateindex.unwrap_sum(),
|
||||
365,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_annualized_volume_btc
|
||||
.compute_all(starting_indexes, exit, |v| {
|
||||
v.compute_sum(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_sent.bitcoin.dateindex.unwrap_sum(),
|
||||
365,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_velocity_btc
|
||||
.compute_all(starting_indexes, exit, |v| {
|
||||
v.compute_divide(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_annualized_volume_btc
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
self.indexes_to_subsidy
|
||||
.bitcoin
|
||||
.dateindex
|
||||
.unwrap_cumulative(),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
if let Some(indexes_to_sent) = self.indexes_to_sent.dollars.as_ref() {
|
||||
self.indexes_to_annualized_volume_usd
|
||||
.compute_all(starting_indexes, exit, |v| {
|
||||
v.compute_sum(
|
||||
starting_indexes.dateindex,
|
||||
indexes_to_sent.dateindex.unwrap_sum(),
|
||||
365,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_velocity_usd
|
||||
.compute_all(starting_indexes, exit, |v| {
|
||||
v.compute_divide(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_annualized_volume_usd
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
self.indexes_to_subsidy
|
||||
.dollars
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.dateindex
|
||||
.unwrap_cumulative(),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2121,7 +2238,7 @@ impl Vecs {
|
||||
&self.decadeindex_to_block_count_target,
|
||||
&self.height_to_24h_block_count,
|
||||
&self.height_to_24h_coinbase_sum,
|
||||
&self.height_to_24h_coinbase_in_usd_sum,
|
||||
&self.height_to_24h_coinbase_usd_sum,
|
||||
]
|
||||
.into_iter(),
|
||||
);
|
||||
@@ -2206,6 +2323,11 @@ impl Vecs {
|
||||
iter = Box::new(iter.chain(self.indexes_to_subsidy.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_exact_utxo_count.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_unclaimed_rewards.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_annualized_volume.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_annualized_volume_btc.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_annualized_volume_usd.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_velocity_btc.iter_any_collectable()));
|
||||
iter = Box::new(iter.chain(self.indexes_to_velocity_usd.iter_any_collectable()));
|
||||
iter = Box::new(
|
||||
iter.chain(
|
||||
self.indexes_to_subsidy_usd_1y_sma
|
||||
|
||||
@@ -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()),
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user