mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-26 17:54:44 -07:00
global: add datasets and charts + fixes
This commit is contained in:
@@ -26,6 +26,8 @@ pub struct Vecs {
|
||||
pub constant_4: ComputedVecsFromHeight<StoredU16>,
|
||||
pub constant_50: ComputedVecsFromHeight<StoredU16>,
|
||||
pub constant_100: ComputedVecsFromHeight<StoredU16>,
|
||||
pub constant_144: ComputedVecsFromHeight<StoredU16>,
|
||||
pub constant_600: ComputedVecsFromHeight<StoredU16>,
|
||||
pub constant_minus_1: ComputedVecsFromHeight<StoredI16>,
|
||||
pub constant_minus_2: ComputedVecsFromHeight<StoredI16>,
|
||||
pub constant_minus_3: ComputedVecsFromHeight<StoredI16>,
|
||||
@@ -93,6 +95,22 @@ impl Vecs {
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
constant_144: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"constant_144",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
constant_600: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"constant_600",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
constant_minus_1: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"constant_minus_1",
|
||||
@@ -149,192 +167,62 @@ impl Vecs {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.constant_0.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(0)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
[
|
||||
(&mut self.constant_0, 0),
|
||||
(&mut self.constant_1, 1),
|
||||
(&mut self.constant_2, 2),
|
||||
(&mut self.constant_3, 3),
|
||||
(&mut self.constant_4, 4),
|
||||
(&mut self.constant_50, 50),
|
||||
(&mut self.constant_100, 100),
|
||||
(&mut self.constant_144, 144),
|
||||
(&mut self.constant_600, 600),
|
||||
]
|
||||
.into_iter()
|
||||
.try_for_each(|(vec, value)| {
|
||||
vec.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(value)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
})?;
|
||||
|
||||
self.constant_1.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(1)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_2.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(2)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_3.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(3)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_4.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(4)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_50.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(50)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_100.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredU16::new(100)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_minus_1.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredI16::new(-1)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_minus_2.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredI16::new(-2)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_minus_3.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredI16::new(-3)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
self.constant_minus_4.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredI16::new(-4)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
[
|
||||
(&mut self.constant_minus_1, -1),
|
||||
(&mut self.constant_minus_2, -2),
|
||||
(&mut self.constant_minus_3, 3),
|
||||
(&mut self.constant_minus_4, 4),
|
||||
]
|
||||
.into_iter()
|
||||
.try_for_each(|(vec, value)| {
|
||||
vec.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_to(
|
||||
starting_indexes.height,
|
||||
indexes.height_to_date.len(),
|
||||
indexes.height_to_date.version(),
|
||||
|i| (i, StoredI16::new(value)),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -348,6 +236,8 @@ impl Vecs {
|
||||
self.constant_4.vecs(),
|
||||
self.constant_50.vecs(),
|
||||
self.constant_100.vecs(),
|
||||
self.constant_144.vecs(),
|
||||
self.constant_600.vecs(),
|
||||
self.constant_minus_1.vecs(),
|
||||
self.constant_minus_2.vecs(),
|
||||
self.constant_minus_3.vecs(),
|
||||
|
||||
@@ -320,26 +320,25 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
price: &price::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
date_to_price_opt: Option<&impl AnyIterableVec<DateIndex, Dollars>>,
|
||||
price_opt: Option<&impl AnyIterableVec<DateIndex, Dollars>>,
|
||||
) -> Result<()> {
|
||||
let date_to_price = date_to_price_opt.unwrap_or_else(|| unsafe {
|
||||
let closes = price.timeindexes_to_close.dateindex.as_ref().unwrap();
|
||||
|
||||
let price = price_opt.unwrap_or_else(|| unsafe {
|
||||
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
|
||||
});
|
||||
|
||||
let closes = price.timeindexes_to_close.dateindex.as_ref().unwrap();
|
||||
|
||||
self.ratio.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
let mut price = date_to_price.iter();
|
||||
v.compute_transform(
|
||||
v.compute_transform2(
|
||||
starting_indexes.dateindex,
|
||||
closes,
|
||||
|(i, close, ..)| {
|
||||
let price = price.unwrap_get_inner(i);
|
||||
price,
|
||||
|(i, close, price, ..)| {
|
||||
if price == Dollars::ZERO {
|
||||
(i, StoredF32::from(1.0))
|
||||
} else {
|
||||
@@ -553,7 +552,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
)?;
|
||||
|
||||
let date_to_price = date_to_price_opt.unwrap_or_else(|| unsafe {
|
||||
let date_to_price = price_opt.unwrap_or_else(|| unsafe {
|
||||
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
|
||||
});
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ impl Computer {
|
||||
indexer: &Indexer,
|
||||
fetcher: Option<Fetcher>,
|
||||
) -> Result<Self> {
|
||||
info!("Importing computer...");
|
||||
|
||||
let computed_path = outputs_path.join("computed");
|
||||
|
||||
let indexes =
|
||||
|
||||
@@ -48,6 +48,21 @@ pub struct Vecs {
|
||||
pub indexes_to_200w_sma: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_4y_sma: ComputedRatioVecsFromDateIndex,
|
||||
|
||||
pub indexes_to_1w_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_8d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_13d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_21d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_1m_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_34d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_55d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_89d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_144d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_200d_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_1y_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_2y_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_200w_ema: ComputedRatioVecsFromDateIndex,
|
||||
pub indexes_to_4y_ema: ComputedRatioVecsFromDateIndex,
|
||||
|
||||
pub indexes_to_200d_sma_x2_4: ComputedVecsFromDateIndex<Dollars>,
|
||||
pub indexes_to_200d_sma_x0_8: ComputedVecsFromDateIndex<Dollars>,
|
||||
|
||||
@@ -350,6 +365,119 @@ impl Vecs {
|
||||
true,
|
||||
)?,
|
||||
|
||||
indexes_to_1w_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"1w_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_8d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"8d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_13d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"13d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_21d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"21d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_1m_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"1m_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_34d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"34d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_55d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"55d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_89d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"89d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_144d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"144d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_200d_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"200d_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_1y_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"1y_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_2y_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"2y_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_200w_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"200w_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
indexes_to_4y_ema: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"4y_ema",
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
true,
|
||||
)?,
|
||||
|
||||
_1d_returns: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"1d_returns",
|
||||
@@ -1827,25 +1955,69 @@ impl Vecs {
|
||||
|
||||
thread::scope(|s| -> Result<()> {
|
||||
[
|
||||
(&mut self.indexes_to_1w_sma, 7),
|
||||
(&mut self.indexes_to_8d_sma, 8),
|
||||
(&mut self.indexes_to_13d_sma, 13),
|
||||
(&mut self.indexes_to_21d_sma, 21),
|
||||
(&mut self.indexes_to_1m_sma, 30),
|
||||
(&mut self.indexes_to_34d_sma, 34),
|
||||
(&mut self.indexes_to_55d_sma, 55),
|
||||
(&mut self.indexes_to_89d_sma, 89),
|
||||
(&mut self.indexes_to_144d_sma, 144),
|
||||
(&mut self.indexes_to_200d_sma, 200),
|
||||
(&mut self.indexes_to_1y_sma, 365),
|
||||
(&mut self.indexes_to_2y_sma, 2 * 365),
|
||||
(&mut self.indexes_to_200w_sma, 200 * 7),
|
||||
(&mut self.indexes_to_4y_sma, 4 * 365),
|
||||
(&mut self.indexes_to_1w_sma, &mut self.indexes_to_1w_ema, 7),
|
||||
(&mut self.indexes_to_8d_sma, &mut self.indexes_to_8d_ema, 8),
|
||||
(
|
||||
&mut self.indexes_to_13d_sma,
|
||||
&mut self.indexes_to_13d_ema,
|
||||
13,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_21d_sma,
|
||||
&mut self.indexes_to_21d_ema,
|
||||
21,
|
||||
),
|
||||
(&mut self.indexes_to_1m_sma, &mut self.indexes_to_1m_ema, 30),
|
||||
(
|
||||
&mut self.indexes_to_34d_sma,
|
||||
&mut self.indexes_to_34d_ema,
|
||||
34,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_55d_sma,
|
||||
&mut self.indexes_to_55d_ema,
|
||||
55,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_89d_sma,
|
||||
&mut self.indexes_to_89d_ema,
|
||||
89,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_144d_sma,
|
||||
&mut self.indexes_to_144d_ema,
|
||||
144,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_200d_sma,
|
||||
&mut self.indexes_to_200d_ema,
|
||||
200,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_1y_sma,
|
||||
&mut self.indexes_to_1y_ema,
|
||||
365,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_2y_sma,
|
||||
&mut self.indexes_to_2y_ema,
|
||||
2 * 365,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_200w_sma,
|
||||
&mut self.indexes_to_200w_ema,
|
||||
200 * 7,
|
||||
),
|
||||
(
|
||||
&mut self.indexes_to_4y_sma,
|
||||
&mut self.indexes_to_4y_ema,
|
||||
4 * 365,
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.for_each(|(vecs, sma)| {
|
||||
.for_each(|(sma, ema, days)| {
|
||||
s.spawn(move || -> Result<()> {
|
||||
vecs.compute_all(
|
||||
sma.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1855,7 +2027,24 @@ impl Vecs {
|
||||
v.compute_sma(
|
||||
starting_indexes.dateindex,
|
||||
price.timeindexes_to_close.dateindex.as_ref().unwrap(),
|
||||
sma,
|
||||
days,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
ema.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_ema(
|
||||
starting_indexes.dateindex,
|
||||
price.timeindexes_to_close.dateindex.as_ref().unwrap(),
|
||||
days,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
@@ -1935,6 +2124,20 @@ impl Vecs {
|
||||
self.indexes_to_2y_sma.vecs(),
|
||||
self.indexes_to_200w_sma.vecs(),
|
||||
self.indexes_to_4y_sma.vecs(),
|
||||
self.indexes_to_1w_ema.vecs(),
|
||||
self.indexes_to_8d_ema.vecs(),
|
||||
self.indexes_to_13d_ema.vecs(),
|
||||
self.indexes_to_21d_ema.vecs(),
|
||||
self.indexes_to_1m_ema.vecs(),
|
||||
self.indexes_to_34d_ema.vecs(),
|
||||
self.indexes_to_55d_ema.vecs(),
|
||||
self.indexes_to_89d_ema.vecs(),
|
||||
self.indexes_to_144d_ema.vecs(),
|
||||
self.indexes_to_200d_ema.vecs(),
|
||||
self.indexes_to_1y_ema.vecs(),
|
||||
self.indexes_to_2y_ema.vecs(),
|
||||
self.indexes_to_200w_ema.vecs(),
|
||||
self.indexes_to_4y_ema.vecs(),
|
||||
self.indexes_to_200d_sma_x0_8.vecs(),
|
||||
self.indexes_to_200d_sma_x2_4.vecs(),
|
||||
self.price_1d_ago.vecs(),
|
||||
|
||||
@@ -50,10 +50,14 @@ pub struct Vecs {
|
||||
|
||||
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||
pub dateindex_to_spent_output_profit_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_spent_output_profit_ratio_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_adjusted_spent_output_profit_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_adjusted_spent_output_profit_ratio_7d_ema:
|
||||
Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub indexes_to_realized_cap_30d_change: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_spent_output_profit_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_sell_side_risk_ratio_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub indexes_to_adjusted_value_created: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_adjusted_value_destroyed: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_negative_realized_loss: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
@@ -599,6 +603,15 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_sell_side_risk_ratio_7d_ema: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("sell_side_risk_ratio_7d_ema"),
|
||||
version + VERSION + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_spent_output_profit_ratio: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
@@ -608,6 +621,15 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_spent_output_profit_ratio_7d_ema: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("spent_output_profit_ratio_7d_ema"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_adjusted_spent_output_profit_ratio: (compute_dollars && compute_adjusted).then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
@@ -617,6 +639,15 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_adjusted_spent_output_profit_ratio_7d_ema: (compute_dollars && compute_adjusted).then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("adjusted_spent_output_profit_ratio_7d_ema"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_halved_supply_value: ComputedHeightValueVecs::forced_import(
|
||||
db,
|
||||
&suffix("halved_supply"),
|
||||
@@ -2177,6 +2208,18 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_spent_output_profit_ratio_7d_ema
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute_ema(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_spent_output_profit_ratio
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
7,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_sell_side_risk_ratio
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
@@ -2195,6 +2238,16 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_sell_side_risk_ratio_7d_ema
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute_ema(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_sell_side_risk_ratio.as_ref().unwrap(),
|
||||
7,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.indexes_to_supply_in_profit
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
@@ -2757,6 +2810,18 @@ impl Vecs {
|
||||
.unwrap_sum(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_adjusted_spent_output_profit_ratio_7d_ema
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute_ema(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_adjusted_spent_output_profit_ratio
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
7,
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2823,9 +2888,15 @@ impl Vecs {
|
||||
self.dateindex_to_spent_output_profit_ratio
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]),
|
||||
self.dateindex_to_spent_output_profit_ratio_7d_ema
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]),
|
||||
self.dateindex_to_adjusted_spent_output_profit_ratio
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]),
|
||||
self.dateindex_to_adjusted_spent_output_profit_ratio_7d_ema
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]),
|
||||
self.indexes_to_value_destroyed
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
@@ -2844,6 +2915,9 @@ impl Vecs {
|
||||
self.dateindex_to_sell_side_risk_ratio
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v]),
|
||||
self.dateindex_to_sell_side_risk_ratio_7d_ema
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v]),
|
||||
self.height_to_supply_in_profit
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v]),
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Vecs {
|
||||
db,
|
||||
None,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
version + VERSION + Version::ONE,
|
||||
indexes,
|
||||
price,
|
||||
None,
|
||||
@@ -1644,7 +1644,13 @@ impl Vecs {
|
||||
let by_size_range = self.0.amount_range.as_vec();
|
||||
|
||||
[
|
||||
vec![(&mut self.0.all.1, self.0.epoch.vecs().to_vec())],
|
||||
vec![(
|
||||
&mut self.0.all.1,
|
||||
by_date_range
|
||||
.into_iter()
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)],
|
||||
self.0
|
||||
.min_age
|
||||
.as_mut_vec()
|
||||
|
||||
Reference in New Issue
Block a user