diff --git a/.gitignore b/.gitignore
index 0bd55ef7f..3cc4a7322 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
target
websites/dist
vecid-to-indexes.js
+/ids.txt
# Copies
*\ copy*
diff --git a/Cargo.lock b/Cargo.lock
index c704843d3..494fe6612 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -451,9 +451,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
-version = "2.9.3"
+version = "2.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d"
+checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
dependencies = [
"serde",
]
@@ -608,6 +608,7 @@ dependencies = [
"brk_indexer",
"brk_structs",
"derive_deref",
+ "nucleo-matcher",
"schemars 1.0.4",
"serde",
"serde_json",
@@ -703,7 +704,7 @@ dependencies = [
"anyhow",
"append-only-vec",
"arcstr",
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"brk_rolldown_common",
"brk_rolldown_debug",
"brk_rolldown_ecmascript",
@@ -752,7 +753,7 @@ checksum = "23cd66173b33436aaec126f64e8f1d0938539d2eb934e88c633cf6181f7e4c53"
dependencies = [
"anyhow",
"arcstr",
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"brk_rolldown_ecmascript",
"brk_rolldown_error",
"brk_rolldown_fs",
@@ -834,7 +835,7 @@ checksum = "9fd007c612609bcf46e3dca4f9f3c79d16dc1f0bdf7cd0047bfe752fbc6fbecc"
dependencies = [
"anyhow",
"arcstr",
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"brk_rolldown_utils",
"derive_more",
"heck",
@@ -865,7 +866,7 @@ dependencies = [
"anyhow",
"arcstr",
"async-trait",
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"brk_rolldown_common",
"brk_rolldown_debug",
"brk_rolldown_ecmascript",
@@ -1144,10 +1145,11 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.2.34"
+version = "1.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42bc4aea80032b7bf409b0bc7ccad88853858911b7713a8062fdc0623867bedc"
+checksum = "590f9024a68a8c40351881787f1934dc11afd69090f5edb6831464694d836ea3"
dependencies = [
+ "find-msvc-tools",
"jobserver",
"libc",
"shlex",
@@ -1193,18 +1195,18 @@ dependencies = [
[[package]]
name = "clap"
-version = "4.5.46"
+version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c5e4fcf9c21d2e544ca1ee9d8552de13019a42aa7dbf32747fa7aaf1df76e57"
+checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
-version = "4.5.46"
+version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fecb53a0e6fcfb055f686001bc2e2592fa527efaf38dbe81a6a9563562e57d41"
+checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
dependencies = [
"anstream",
"anstyle",
@@ -1214,9 +1216,9 @@ dependencies = [
[[package]]
name = "clap_derive"
-version = "4.5.45"
+version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6"
+checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
dependencies = [
"heck",
"proc-macro2",
@@ -1551,9 +1553,9 @@ dependencies = [
[[package]]
name = "deranged"
-version = "0.4.0"
+version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
+checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc"
dependencies = [
"powerfmt",
"serde",
@@ -1764,6 +1766,12 @@ dependencies = [
"windows-sys 0.60.2",
]
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650"
+
[[package]]
name = "fixedbitset"
version = "0.5.7"
@@ -2285,7 +2293,7 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"inotify-sys",
"libc",
]
@@ -2314,7 +2322,7 @@ version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"cfg-if",
"libc",
]
@@ -2460,16 +2468,16 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"libc",
"redox_syscall",
]
[[package]]
name = "libz-rs-sys"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221"
+checksum = "840db8cf39d9ec4dd794376f38acc40d0fc65eec2a8f484f7fd375b84602becd"
dependencies = [
"zlib-rs",
]
@@ -2609,7 +2617,7 @@ version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"cfg-if",
"cfg_aliases",
"libc",
@@ -2636,7 +2644,7 @@ version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"fsevent-sys",
"inotify",
"kqueue",
@@ -2663,6 +2671,16 @@ dependencies = [
"windows-sys 0.52.0",
]
+[[package]]
+name = "nucleo-matcher"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf33f538733d1a5a3494b836ba913207f14d9d4a1d3cd67030c5061bdd2cac85"
+dependencies = [
+ "memchr",
+ "unicode-segmentation",
+]
+
[[package]]
name = "num-bigint"
version = "0.4.6"
@@ -2816,7 +2834,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989b81258ce151e23adee6f1393f7c0fb7e10e3a6c6c001f71bbaff4081c72a4"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"oxc_allocator",
"oxc_ast_macros",
"oxc_data_structures",
@@ -2857,7 +2875,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5361ef66f38635d9671596d83abf44bcdbc3e39dbff303f3517828b86ad60e8f"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"itertools",
"nonmax",
"oxc_index",
@@ -2872,7 +2890,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fde8fc6f7337632fce3e9e51c150f57fb0ef234524c6947f63e8009e1ea613cf"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"cow-utils",
"dragonbox_ecma",
"nonmax",
@@ -2950,7 +2968,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83d8c311d64fa0bf8cab1bde3f7760cd828e71ed483ca0878799f1f72542cb4d"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"oxc_allocator",
"oxc_ast",
"oxc_ast_visit",
@@ -3005,7 +3023,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70253728183a5a92d1ba964d9952201e0269ebd07c4917c4553283d564225bab"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"cow-utils",
"memchr",
"num-bigint",
@@ -3028,7 +3046,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de5bb2ed6646bb7815126e0f36787c349e13561fed2c05f95b27a1f82dd066c4"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"oxc_allocator",
"oxc_ast_macros",
"oxc_diagnostics",
@@ -3113,7 +3131,7 @@ version = "0.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72d9d80d47d2eee5c1e6dbcdf1841b42afc4f1cd1f63701fc346162616dac52f"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"cow-utils",
"dragonbox_ecma",
"nonmax",
@@ -3621,7 +3639,7 @@ version = "0.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
]
[[package]]
@@ -3735,7 +3753,7 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
dependencies = [
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"errno",
"libc",
"linux-raw-sys",
@@ -3884,9 +3902,9 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
[[package]]
name = "seqdb"
-version = "0.2.5"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c54ab988c96efa9d275ca2b12bf2d3c6adec993b8e82ea31a88c984abdaa14fa"
+checksum = "ade192d6f8a1e58c43428c8e194016124f20744f75cb14e2fcc0c79309fe4f91"
dependencies = [
"libc",
"log",
@@ -4290,12 +4308,11 @@ dependencies = [
[[package]]
name = "time"
-version = "0.3.41"
+version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
+checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031"
dependencies = [
"deranged",
- "itoa",
"num-conv",
"powerfmt",
"serde",
@@ -4305,15 +4322,15 @@ dependencies = [
[[package]]
name = "time-core"
-version = "0.1.4"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
+checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
[[package]]
name = "time-macros"
-version = "0.2.22"
+version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
+checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
dependencies = [
"num-conv",
"time-core",
@@ -4444,7 +4461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
dependencies = [
"async-compression",
- "bitflags 2.9.3",
+ "bitflags 2.9.4",
"bytes",
"futures-core",
"http",
@@ -4616,6 +4633,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
+[[package]]
+name = "unicode-segmentation"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
+
[[package]]
name = "unicode-width"
version = "0.2.1"
@@ -4672,9 +4695,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
-version = "1.18.0"
+version = "1.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be"
+checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
dependencies = [
"getrandom 0.3.3",
"js-sys",
@@ -4712,9 +4735,9 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23"
[[package]]
name = "vecdb"
-version = "0.2.5"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e5c4ec34c376be3a41435eeb7672d0ea0e9c1d60c5d1d90218912588f91abea"
+checksum = "5c3e103eeb634851690d815a886ba8fe1ab21d2f520d915c411979bc76de8419"
dependencies = [
"ctrlc",
"log",
@@ -4732,9 +4755,9 @@ dependencies = [
[[package]]
name = "vecdb_derive"
-version = "0.2.5"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "778c4874c05822465e28cae6a7dead593a73124ec80afb85b85adae5ac883368"
+checksum = "6bdf71ae8eeaf2f187cee599e8e34a49bf6fd0536977bd009d94be35e3801754"
dependencies = [
"quote",
"syn 2.0.106",
@@ -5224,9 +5247,9 @@ dependencies = [
[[package]]
name = "zlib-rs"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a"
+checksum = "2f06ae92f42f5e5c42443fd094f245eb656abf56dd7cce9b8b263236565e00f2"
[[package]]
name = "zopfli"
diff --git a/Cargo.toml b/Cargo.toml
index 39aa7d075..afdcb9821 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,7 +53,7 @@ serde_derive = "1.0.219"
serde_json = { version = "1.0.143", features = ["float_roundtrip"] }
tokio = { version = "1.47.1", features = ["rt-multi-thread"] }
# vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]}
-vecdb = { version = "0.2.5", features = ["derive"]}
+vecdb = { version = "0.2.9", features = ["derive"]}
zerocopy = "0.8.26"
zerocopy-derive = "0.8.26"
diff --git a/README.md b/README.md
index 033c385c2..bb8159fc7 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
-
+
@@ -92,7 +92,3 @@ Heartfelt thanks go out to every donor on [Nostr](https://primal.net/p/npub1jagm
## Donate
[`bc1q09 8zsm89 m7kgyz e338vf ejhpdt 92ua9p 3peuve`](bitcoin:bc1q098zsm89m7kgyze338vfejhpdt92ua9p3peuve)
-
-[`lnurl1dp68gurn8ghj7ampd3kx2ar0veekzar0wd5xjtnrdakj7tnhv4kxctttdehhwm30d3h82unvwqhkxmmww3jkuar8d35kgetj8yuq363hv4`](lightning:lnurl1dp68gurn8ghj7ampd3kx2ar0veekzar0wd5xjtnrdakj7tnhv4kxctttdehhwm30d3h82unvwqhkxmmww3jkuar8d35kgetj8yuq363hv4)
-
-[Geyser Fund](https://geyser.fund/project/brk)
diff --git a/crates/brk_cli/Cargo.toml b/crates/brk_cli/Cargo.toml
index 282f09348..882f49f35 100644
--- a/crates/brk_cli/Cargo.toml
+++ b/crates/brk_cli/Cargo.toml
@@ -20,8 +20,8 @@ brk_logger = { workspace = true }
brk_parser = { workspace = true }
brk_server = { workspace = true }
vecdb = { workspace = true }
-clap = { version = "4.5.46", features = ["string"] }
-clap_derive = "4.5.45"
+clap = { version = "4.5.47", features = ["string"] }
+clap_derive = "4.5.47"
color-eyre = "0.6.5"
log = { workspace = true }
minreq = { workspace = true }
diff --git a/crates/brk_computer/src/chain.rs b/crates/brk_computer/src/chain.rs
index 4609b3248..850930efc 100644
--- a/crates/brk_computer/src/chain.rs
+++ b/crates/brk_computer/src/chain.rs
@@ -288,7 +288,7 @@ impl Vecs {
let txindex_to_fee_rate =
EagerVec::forced_import_compressed(&db, "fee_rate", version + VERSION + Version::ZERO)?;
- Ok(Self {
+ let this = Self {
height_to_interval: EagerVec::forced_import_compressed(
&db,
"interval",
@@ -804,7 +804,16 @@ impl Vecs {
txindex_to_weight,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
diff --git a/crates/brk_computer/src/cointime.rs b/crates/brk_computer/src/cointime.rs
index 35ee20283..1dbfa6c41 100644
--- a/crates/brk_computer/src/cointime.rs
+++ b/crates/brk_computer/src/cointime.rs
@@ -43,7 +43,7 @@ pub struct Vecs {
pub indexes_to_cointime_price: ComputedVecsFromHeight,
pub indexes_to_cointime_cap: ComputedVecsFromHeight,
pub indexes_to_cointime_price_ratio: ComputedRatioVecsFromDateIndex,
- // pub indexes_to_thermo_cap_relative_to_investor_cap: ComputedValueVecsFromHeight,
+ // pub indexes_to_thermo_cap_rel_to_investor_cap: ComputedValueVecsFromHeight,
}
impl Vecs {
@@ -58,7 +58,7 @@ impl Vecs {
let compute_dollars = price.is_some();
- Ok(Self {
+ let this = Self {
indexes_to_coinblocks_created: ComputedVecsFromHeight::forced_import(
&db,
"coinblocks_created",
@@ -247,7 +247,16 @@ impl Vecs {
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
#[allow(clippy::too_many_arguments)]
@@ -597,7 +606,7 @@ impl Vecs {
// The price taken won't be correct for time based indexes
vec.compute_multiply(
starting_indexes.height,
- &price.chainindexes_to_close.height,
+ &price.chainindexes_to_price_close.height,
indexes_to_coinblocks_destroyed.height.as_ref().unwrap(),
exit,
)?;
@@ -613,7 +622,7 @@ impl Vecs {
|vec, _, _, starting_indexes, exit| {
vec.compute_multiply(
starting_indexes.height,
- &price.chainindexes_to_close.height,
+ &price.chainindexes_to_price_close.height,
self.indexes_to_coinblocks_created.height.as_ref().unwrap(),
exit,
)?;
@@ -629,7 +638,7 @@ impl Vecs {
|vec, _, _, starting_indexes, exit| {
vec.compute_multiply(
starting_indexes.height,
- &price.chainindexes_to_close.height,
+ &price.chainindexes_to_price_close.height,
self.indexes_to_coinblocks_stored.height.as_ref().unwrap(),
exit,
)?;
diff --git a/crates/brk_computer/src/constants.rs b/crates/brk_computer/src/constants.rs
index 23d034edf..d1b509cc0 100644
--- a/crates/brk_computer/src/constants.rs
+++ b/crates/brk_computer/src/constants.rs
@@ -38,7 +38,7 @@ impl Vecs {
pub fn forced_import(parent: &Path, version: Version, indexes: &indexes::Vecs) -> Result {
let db = Database::open(&parent.join("constants"))?;
- Ok(Self {
+ let this = Self {
constant_0: ComputedVecsFromHeight::forced_import(
&db,
"constant_0",
@@ -145,7 +145,16 @@ impl Vecs {
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
diff --git a/crates/brk_computer/src/fetched.rs b/crates/brk_computer/src/fetched.rs
index b20314f2f..7accefb33 100644
--- a/crates/brk_computer/src/fetched.rs
+++ b/crates/brk_computer/src/fetched.rs
@@ -16,30 +16,39 @@ pub struct Vecs {
db: Database,
fetcher: Fetcher,
- pub dateindex_to_ohlc_in_cents: RawVec,
- pub height_to_ohlc_in_cents: RawVec,
+ pub dateindex_to_price_ohlc_in_cents: RawVec,
+ pub height_to_price_ohlc_in_cents: RawVec,
}
impl Vecs {
pub fn forced_import(parent: &Path, fetcher: Fetcher, version: Version) -> Result {
let db = Database::open(&parent.join("fetched"))?;
- Ok(Self {
+ let this = Self {
fetcher,
- dateindex_to_ohlc_in_cents: RawVec::forced_import(
+ dateindex_to_price_ohlc_in_cents: RawVec::forced_import(
&db,
- "ohlc_in_cents",
+ "price_ohlc_in_cents",
version + Version::ZERO,
)?,
- height_to_ohlc_in_cents: RawVec::forced_import(
+ height_to_price_ohlc_in_cents: RawVec::forced_import(
&db,
- "ohlc_in_cents",
+ "price_ohlc_in_cents",
version + Version::ZERO,
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
@@ -64,12 +73,12 @@ impl Vecs {
let height_to_timestamp = &indexer.vecs.height_to_timestamp;
let index = starting_indexes
.height
- .min(Height::from(self.height_to_ohlc_in_cents.len()));
+ .min(Height::from(self.height_to_price_ohlc_in_cents.len()));
height_to_timestamp
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let v = v.into_owned();
- self.height_to_ohlc_in_cents.forced_push_at(
+ self.height_to_price_ohlc_in_cents.forced_push_at(
i,
self.fetcher
.get_height(
@@ -84,11 +93,11 @@ impl Vecs {
)?;
Ok(())
})?;
- self.height_to_ohlc_in_cents.safe_flush(exit)?;
+ self.height_to_price_ohlc_in_cents.safe_flush(exit)?;
let index = starting_indexes
.dateindex
- .min(DateIndex::from(self.dateindex_to_ohlc_in_cents.len()));
+ .min(DateIndex::from(self.dateindex_to_price_ohlc_in_cents.len()));
let mut prev = None;
indexes
.dateindex_to_date
@@ -98,7 +107,7 @@ impl Vecs {
if prev.is_none() {
let i = i.unwrap_to_usize();
prev.replace(if i > 0 {
- self.dateindex_to_ohlc_in_cents
+ self.dateindex_to_price_ohlc_in_cents
.into_iter()
.unwrap_get_inner_(i - 1)
} else {
@@ -106,7 +115,8 @@ impl Vecs {
});
}
- let ohlc = if i.unwrap_to_usize() + 100 >= self.dateindex_to_ohlc_in_cents.len()
+ let ohlc = if i.unwrap_to_usize() + 100
+ >= self.dateindex_to_price_ohlc_in_cents.len()
&& let Ok(mut ohlc) = self.fetcher.get_date(d)
{
let prev_open = *prev.as_ref().unwrap().close;
@@ -120,20 +130,20 @@ impl Vecs {
prev.replace(ohlc.clone());
- self.dateindex_to_ohlc_in_cents
+ self.dateindex_to_price_ohlc_in_cents
.forced_push_at(i, ohlc, exit)?;
Ok(())
})?;
- self.dateindex_to_ohlc_in_cents.safe_flush(exit)?;
+ self.dateindex_to_price_ohlc_in_cents.safe_flush(exit)?;
Ok(())
}
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
vec![
- &self.dateindex_to_ohlc_in_cents as &dyn AnyCollectableVec,
- &self.height_to_ohlc_in_cents,
+ &self.dateindex_to_price_ohlc_in_cents as &dyn AnyCollectableVec,
+ &self.height_to_price_ohlc_in_cents,
]
}
}
diff --git a/crates/brk_computer/src/grouped/builder_eager.rs b/crates/brk_computer/src/grouped/builder_eager.rs
index ee5022062..05310e3c0 100644
--- a/crates/brk_computer/src/grouped/builder_eager.rs
+++ b/crates/brk_computer/src/grouped/builder_eager.rs
@@ -144,7 +144,7 @@ where
Box::new(
EagerVec::forced_import(
db,
- &suffix("cum"),
+ &suffix("cumulative"),
version + VERSION + Version::ZERO,
format,
)
diff --git a/crates/brk_computer/src/grouped/builder_lazy.rs b/crates/brk_computer/src/grouped/builder_lazy.rs
index 59b9a09c9..3a6bca800 100644
--- a/crates/brk_computer/src/grouped/builder_lazy.rs
+++ b/crates/brk_computer/src/grouped/builder_lazy.rs
@@ -197,7 +197,7 @@ where
}),
cumulative: options.cumulative.then(|| {
Box::new(LazyVecFrom2::init(
- &suffix("cum"),
+ &suffix("cumulative"),
version + VERSION + Version::ZERO,
source_extra.cumulative.as_ref().unwrap().boxed_clone(),
len_source.clone(),
diff --git a/crates/brk_computer/src/grouped/from_txindex.rs b/crates/brk_computer/src/grouped/from_txindex.rs
index 89a693378..3780036dd 100644
--- a/crates/brk_computer/src/grouped/from_txindex.rs
+++ b/crates/brk_computer/src/grouped/from_txindex.rs
@@ -447,7 +447,7 @@ impl ComputedVecsFromTxindex {
let starting_index = self.height.starting_index(starting_indexes.height);
- let mut close_iter = price.chainindexes_to_close.height.into_iter();
+ let mut close_iter = price.chainindexes_to_price_close.height.into_iter();
(starting_index.unwrap_to_usize()..indexer.vecs.height_to_weight.len())
.map(Height::from)
diff --git a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs
index b4a0f2525..64c354463 100644
--- a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs
+++ b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs
@@ -22,18 +22,18 @@ pub struct ComputedRatioVecsFromDateIndex {
pub ratio: ComputedVecsFromDateIndex,
pub ratio_1w_sma: Option>,
pub ratio_1m_sma: Option>,
- pub ratio_p99: Option>,
- pub ratio_p98: Option>,
- pub ratio_p95: Option>,
- pub ratio_p5: Option>,
- pub ratio_p2: Option>,
- pub ratio_p1: Option>,
- pub ratio_p99_as_price: Option>,
- pub ratio_p98_as_price: Option>,
- pub ratio_p95_as_price: Option>,
- pub ratio_p5_as_price: Option>,
- pub ratio_p2_as_price: Option>,
- pub ratio_p1_as_price: Option>,
+ pub ratio_pct99: Option>,
+ pub ratio_pct98: Option>,
+ pub ratio_pct95: Option>,
+ pub ratio_pct5: Option>,
+ pub ratio_pct2: Option>,
+ pub ratio_pct1: Option>,
+ pub ratio_pct99_in_usd: Option>,
+ pub ratio_pct98_in_usd: Option>,
+ pub ratio_pct95_in_usd: Option>,
+ pub ratio_pct5_in_usd: Option>,
+ pub ratio_pct2_in_usd: Option>,
+ pub ratio_pct1_in_usd: Option>,
pub ratio_sd: Option,
pub ratio_4y_sd: Option,
@@ -141,10 +141,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p99: extended.then(|| {
+ ratio_pct99: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p99"),
+ &format!("{name}_ratio_pct99"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -152,10 +152,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p98: extended.then(|| {
+ ratio_pct98: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p98"),
+ &format!("{name}_ratio_pct98"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -163,10 +163,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p95: extended.then(|| {
+ ratio_pct95: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p95"),
+ &format!("{name}_ratio_pct95"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -174,10 +174,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p5: extended.then(|| {
+ ratio_pct5: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p5"),
+ &format!("{name}_ratio_pct5"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -185,10 +185,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p2: extended.then(|| {
+ ratio_pct2: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p2"),
+ &format!("{name}_ratio_pct2"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -196,10 +196,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p1: extended.then(|| {
+ ratio_pct1: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p1"),
+ &format!("{name}_ratio_pct1"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -207,10 +207,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p99_as_price: extended.then(|| {
+ ratio_pct99_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p99_as_price"),
+ &format!("{name}_ratio_pct99_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -218,10 +218,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p98_as_price: extended.then(|| {
+ ratio_pct98_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p98_as_price"),
+ &format!("{name}_ratio_pct98_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -229,10 +229,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p95_as_price: extended.then(|| {
+ ratio_pct95_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p95_as_price"),
+ &format!("{name}_ratio_pct95_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -240,10 +240,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p5_as_price: extended.then(|| {
+ ratio_pct5_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p5_as_price"),
+ &format!("{name}_ratio_pct5_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -251,10 +251,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p2_as_price: extended.then(|| {
+ ratio_pct2_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p2_as_price"),
+ &format!("{name}_ratio_pct2_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -262,10 +262,10 @@ impl ComputedRatioVecsFromDateIndex {
)
.unwrap()
}),
- ratio_p1_as_price: extended.then(|| {
+ ratio_pct1_in_usd: extended.then(|| {
ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_ratio_p1_as_price"),
+ &format!("{name}_ratio_pct1_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -322,7 +322,7 @@ impl ComputedRatioVecsFromDateIndex {
exit: &Exit,
price_opt: Option<&impl AnyIterableVec>,
) -> Result<()> {
- let closes = price.timeindexes_to_close.dateindex.as_ref().unwrap();
+ let closes = price.timeindexes_to_price_close.dateindex.as_ref().unwrap();
let price = price_opt.unwrap_or_else(|| unsafe {
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
@@ -423,42 +423,42 @@ impl ComputedRatioVecsFromDateIndex {
.iter_at(starting_dateindex)
.try_for_each(|(index, ratio)| -> Result<()> {
if index < min_ratio_date {
- self.ratio_p5
+ self.ratio_pct5
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
- self.ratio_p2
+ self.ratio_pct2
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
- self.ratio_p1
+ self.ratio_pct1
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
- self.ratio_p95
+ self.ratio_pct95
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
- self.ratio_p98
+ self.ratio_pct98
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
- self.ratio_p99
+ self.ratio_pct99
.as_mut()
.unwrap()
.dateindex
@@ -470,42 +470,42 @@ impl ComputedRatioVecsFromDateIndex {
let pos = sorted.binary_search(&ratio).unwrap_or_else(|pos| pos);
sorted.insert(pos, ratio);
- self.ratio_p1
+ self.ratio_pct1
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, get_percentile(&sorted, 0.01), exit)?;
- self.ratio_p2
+ self.ratio_pct2
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, get_percentile(&sorted, 0.02), exit)?;
- self.ratio_p5
+ self.ratio_pct5
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, get_percentile(&sorted, 0.05), exit)?;
- self.ratio_p95
+ self.ratio_pct95
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, get_percentile(&sorted, 0.95), exit)?;
- self.ratio_p98
+ self.ratio_pct98
.as_mut()
.unwrap()
.dateindex
.as_mut()
.unwrap()
.forced_push_at(index, get_percentile(&sorted, 0.98), exit)?;
- self.ratio_p99
+ self.ratio_pct99
.as_mut()
.unwrap()
.dateindex
@@ -521,32 +521,32 @@ impl ComputedRatioVecsFromDateIndex {
.into_iter()
.try_for_each(|v| v.safe_flush(exit))?;
- self.ratio_p1.as_mut().unwrap().compute_rest(
+ self.ratio_pct1.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
)?;
- self.ratio_p2.as_mut().unwrap().compute_rest(
+ self.ratio_pct2.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
)?;
- self.ratio_p5.as_mut().unwrap().compute_rest(
+ self.ratio_pct5.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
)?;
- self.ratio_p95.as_mut().unwrap().compute_rest(
+ self.ratio_pct95.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
)?;
- self.ratio_p98.as_mut().unwrap().compute_rest(
+ self.ratio_pct98.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
)?;
- self.ratio_p99.as_mut().unwrap().compute_rest(
+ self.ratio_pct99.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
@@ -556,14 +556,14 @@ impl ComputedRatioVecsFromDateIndex {
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
});
- self.ratio_p99_as_price.as_mut().unwrap().compute_all(
+ self.ratio_pct99_in_usd.as_mut().unwrap().compute_all(
indexer,
indexes,
starting_indexes,
exit,
|vec, _, _, starting_indexes, exit| {
let mut iter = self
- .ratio_p99
+ .ratio_pct99
.as_ref()
.unwrap()
.dateindex
@@ -583,10 +583,10 @@ impl ComputedRatioVecsFromDateIndex {
},
)?;
- let compute_as_price =
- |as_price: Option<&mut ComputedVecsFromDateIndex>,
+ let compute_in_usd =
+ |in_usd: Option<&mut ComputedVecsFromDateIndex>,
source: Option<&ComputedVecsFromDateIndex>| {
- as_price.unwrap().compute_all(
+ in_usd.unwrap().compute_all(
indexer,
indexes,
starting_indexes,
@@ -607,12 +607,12 @@ impl ComputedRatioVecsFromDateIndex {
)
};
- compute_as_price(self.ratio_p1_as_price.as_mut(), self.ratio_p1.as_ref())?;
- compute_as_price(self.ratio_p2_as_price.as_mut(), self.ratio_p2.as_ref())?;
- compute_as_price(self.ratio_p5_as_price.as_mut(), self.ratio_p5.as_ref())?;
- compute_as_price(self.ratio_p95_as_price.as_mut(), self.ratio_p95.as_ref())?;
- compute_as_price(self.ratio_p98_as_price.as_mut(), self.ratio_p98.as_ref())?;
- compute_as_price(self.ratio_p99_as_price.as_mut(), self.ratio_p99.as_ref())?;
+ 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())?;
self.ratio_sd.as_mut().unwrap().compute_all(
indexer,
@@ -652,22 +652,22 @@ impl ComputedRatioVecsFromDateIndex {
fn mut_ratio_vecs(&mut self) -> Vec<&mut EagerVec> {
[
- self.ratio_p1
+ self.ratio_pct1
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
- self.ratio_p2
+ self.ratio_pct2
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
- self.ratio_p5
+ self.ratio_pct5
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
- self.ratio_p95
+ self.ratio_pct95
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
- self.ratio_p98
+ self.ratio_pct98
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
- self.ratio_p99
+ self.ratio_pct99
.as_mut()
.map_or(vec![], |v| vec![v.dateindex.as_mut().unwrap()]),
]
@@ -686,22 +686,22 @@ impl ComputedRatioVecsFromDateIndex {
self.ratio_1y_sd.as_ref().map_or(vec![], |v| v.vecs()),
self.ratio_2y_sd.as_ref().map_or(vec![], |v| v.vecs()),
self.ratio_4y_sd.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p1.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p2.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p5.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p95.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p98.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p99.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p1_as_price.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p2_as_price.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p5_as_price.as_ref().map_or(vec![], |v| v.vecs()),
- self.ratio_p95_as_price
+ self.ratio_pct1.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct2.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct5.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct95.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct98.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct99.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct1_in_usd.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct2_in_usd.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct5_in_usd.as_ref().map_or(vec![], |v| v.vecs()),
+ self.ratio_pct95_in_usd
.as_ref()
.map_or(vec![], |v| v.vecs()),
- self.ratio_p98_as_price
+ self.ratio_pct98_in_usd
.as_ref()
.map_or(vec![], |v| v.vecs()),
- self.ratio_p99_as_price
+ self.ratio_pct99_in_usd
.as_ref()
.map_or(vec![], |v| v.vecs()),
]
diff --git a/crates/brk_computer/src/grouped/sd_from_dateindex.rs b/crates/brk_computer/src/grouped/sd_from_dateindex.rs
index 1e957d147..3148d4193 100644
--- a/crates/brk_computer/src/grouped/sd_from_dateindex.rs
+++ b/crates/brk_computer/src/grouped/sd_from_dateindex.rs
@@ -16,7 +16,7 @@ pub struct ComputedStandardDeviationVecsFromDateIndex {
pub sma: Option>,
pub sd: ComputedVecsFromDateIndex,
- pub _0sd_as_price: ComputedVecsFromDateIndex,
+ pub _0sd_in_usd: ComputedVecsFromDateIndex,
pub p0_5sd: ComputedVecsFromDateIndex,
pub p1sd: ComputedVecsFromDateIndex,
pub p1_5sd: ComputedVecsFromDateIndex,
@@ -29,18 +29,18 @@ pub struct ComputedStandardDeviationVecsFromDateIndex {
pub m2sd: ComputedVecsFromDateIndex,
pub m2_5sd: ComputedVecsFromDateIndex,
pub m3sd: ComputedVecsFromDateIndex,
- pub p0_5sd_as_price: ComputedVecsFromDateIndex,
- pub p1sd_as_price: ComputedVecsFromDateIndex,
- pub p1_5sd_as_price: ComputedVecsFromDateIndex,
- pub p2sd_as_price: ComputedVecsFromDateIndex,
- pub p2_5sd_as_price: ComputedVecsFromDateIndex,
- pub p3sd_as_price: ComputedVecsFromDateIndex,
- pub m0_5sd_as_price: ComputedVecsFromDateIndex,
- pub m1sd_as_price: ComputedVecsFromDateIndex,
- pub m1_5sd_as_price: ComputedVecsFromDateIndex,
- pub m2sd_as_price: ComputedVecsFromDateIndex,
- pub m2_5sd_as_price: ComputedVecsFromDateIndex,
- pub m3sd_as_price: ComputedVecsFromDateIndex,
+ pub p0_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub p1sd_in_usd: ComputedVecsFromDateIndex,
+ pub p1_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub p2sd_in_usd: ComputedVecsFromDateIndex,
+ pub p2_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub p3sd_in_usd: ComputedVecsFromDateIndex,
+ pub m0_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub m1sd_in_usd: ComputedVecsFromDateIndex,
+ pub m1_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub m2sd_in_usd: ComputedVecsFromDateIndex,
+ pub m2_5sd_in_usd: ComputedVecsFromDateIndex,
+ pub m3sd_in_usd: ComputedVecsFromDateIndex,
pub zscore: ComputedVecsFromDateIndex,
}
@@ -175,105 +175,105 @@ impl ComputedStandardDeviationVecsFromDateIndex {
indexes,
options,
)?,
- _0sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ _0sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_0sd_as_price"),
+ &format!("{name}_0sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p0_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p0_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p0_5sd_as_price"),
+ &format!("{name}_p0_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p1sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p1sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p1sd_as_price"),
+ &format!("{name}_p1sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p1_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p1_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p1_5sd_as_price"),
+ &format!("{name}_p1_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p2sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p2sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p2sd_as_price"),
+ &format!("{name}_p2sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p2_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p2_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p2_5sd_as_price"),
+ &format!("{name}_p2_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- p3sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ p3sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_p3sd_as_price"),
+ &format!("{name}_p3sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m0_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m0_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m0_5sd_as_price"),
+ &format!("{name}_m0_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m1sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m1sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m1sd_as_price"),
+ &format!("{name}_m1sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m1_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m1_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m1_5sd_as_price"),
+ &format!("{name}_m1_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m2sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m2sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m2sd_as_price"),
+ &format!("{name}_m2sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m2_5sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m2_5sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m2_5sd_as_price"),
+ &format!("{name}_m2_5sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
options,
)?,
- m3sd_as_price: ComputedVecsFromDateIndex::forced_import(
+ m3sd_in_usd: ComputedVecsFromDateIndex::forced_import(
db,
- &format!("{name}_m3sd_as_price"),
+ &format!("{name}_m3sd_in_usd"),
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -297,7 +297,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
starting_indexes: &Indexes,
exit: &Exit,
source: &impl CollectableVec,
- source_as_price: Option<&impl AnyIterableVec>,
+ source_in_usd: Option<&impl AnyIterableVec>,
) -> Result<()> {
let min_date = DateIndex::try_from(Date::MIN_RATIO).unwrap();
@@ -326,7 +326,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
exit,
sma_opt,
source,
- source_as_price,
+ source_in_usd,
)
}
@@ -339,7 +339,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
exit: &Exit,
sma_opt: Option<&impl AnyIterableVec>,
source: &impl CollectableVec,
- source_as_price: Option<&impl AnyIterableVec>,
+ source_in_usd: Option<&impl AnyIterableVec>,
) -> Result<()> {
let sma = sma_opt.unwrap_or_else(|| unsafe {
std::mem::transmute(&self.sma.as_ref().unwrap().dateindex)
@@ -571,14 +571,14 @@ impl ComputedStandardDeviationVecsFromDateIndex {
},
)?;
- let Some(price) = source_as_price else {
+ let Some(price) = source_in_usd else {
return Ok(());
};
- let compute_as_price =
- |as_price: &mut ComputedVecsFromDateIndex,
+ let compute_in_usd =
+ |in_usd: &mut ComputedVecsFromDateIndex,
mut iter: BoxedVecIterator| {
- as_price.compute_all(
+ in_usd.compute_all(
indexer,
indexes,
starting_indexes,
@@ -598,53 +598,53 @@ impl ComputedStandardDeviationVecsFromDateIndex {
)
};
- compute_as_price(&mut self._0sd_as_price, sma.iter())?;
- compute_as_price(
- &mut self.p0_5sd_as_price,
+ compute_in_usd(&mut self._0sd_in_usd, sma.iter())?;
+ compute_in_usd(
+ &mut self.p0_5sd_in_usd,
self.p0_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.p1sd_as_price,
+ compute_in_usd(
+ &mut self.p1sd_in_usd,
self.p1sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.p1_5sd_as_price,
+ compute_in_usd(
+ &mut self.p1_5sd_in_usd,
self.p1_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.p2sd_as_price,
+ compute_in_usd(
+ &mut self.p2sd_in_usd,
self.p2sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.p2_5sd_as_price,
+ compute_in_usd(
+ &mut self.p2_5sd_in_usd,
self.p2_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.p3sd_as_price,
+ compute_in_usd(
+ &mut self.p3sd_in_usd,
self.p3sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m0_5sd_as_price,
+ compute_in_usd(
+ &mut self.m0_5sd_in_usd,
self.m0_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m1sd_as_price,
+ compute_in_usd(
+ &mut self.m1sd_in_usd,
self.m1sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m1_5sd_as_price,
+ compute_in_usd(
+ &mut self.m1_5sd_in_usd,
self.m1_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m2sd_as_price,
+ compute_in_usd(
+ &mut self.m2sd_in_usd,
self.m2sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m2_5sd_as_price,
+ compute_in_usd(
+ &mut self.m2_5sd_in_usd,
self.m2_5sd.dateindex.as_ref().unwrap().iter(),
)?;
- compute_as_price(
- &mut self.m3sd_as_price,
+ compute_in_usd(
+ &mut self.m3sd_in_usd,
self.m3sd.dateindex.as_ref().unwrap().iter(),
)?;
@@ -685,19 +685,19 @@ impl ComputedStandardDeviationVecsFromDateIndex {
self.m2sd.vecs(),
self.m2_5sd.vecs(),
self.m3sd.vecs(),
- self._0sd_as_price.vecs(),
- self.p0_5sd_as_price.vecs(),
- self.p1sd_as_price.vecs(),
- self.p1_5sd_as_price.vecs(),
- self.p2sd_as_price.vecs(),
- self.p2_5sd_as_price.vecs(),
- self.p3sd_as_price.vecs(),
- self.m0_5sd_as_price.vecs(),
- self.m1sd_as_price.vecs(),
- self.m1_5sd_as_price.vecs(),
- self.m2sd_as_price.vecs(),
- self.m2_5sd_as_price.vecs(),
- self.m3sd_as_price.vecs(),
+ self._0sd_in_usd.vecs(),
+ self.p0_5sd_in_usd.vecs(),
+ self.p1sd_in_usd.vecs(),
+ self.p1_5sd_in_usd.vecs(),
+ self.p2sd_in_usd.vecs(),
+ self.p2_5sd_in_usd.vecs(),
+ self.p3sd_in_usd.vecs(),
+ self.m0_5sd_in_usd.vecs(),
+ self.m1sd_in_usd.vecs(),
+ self.m1_5sd_in_usd.vecs(),
+ self.m2sd_in_usd.vecs(),
+ self.m2_5sd_in_usd.vecs(),
+ self.m3sd_in_usd.vecs(),
self.zscore.vecs(),
]
.into_iter()
diff --git a/crates/brk_computer/src/grouped/value_from_dateindex.rs b/crates/brk_computer/src/grouped/value_from_dateindex.rs
index 24307ba63..31f342243 100644
--- a/crates/brk_computer/src/grouped/value_from_dateindex.rs
+++ b/crates/brk_computer/src/grouped/value_from_dateindex.rs
@@ -138,10 +138,10 @@ impl ComputedValueVecsFromDateIndex {
}
let dateindex_to_bitcoin = self.bitcoin.dateindex.as_ref().unwrap();
- let dateindex_to_close = price
+ let dateindex_to_price_close = price
.as_ref()
.unwrap()
- .timeindexes_to_close
+ .timeindexes_to_price_close
.dateindex
.as_ref()
.unwrap();
@@ -156,7 +156,7 @@ impl ComputedValueVecsFromDateIndex {
v.compute_from_bitcoin(
starting_indexes.dateindex,
dateindex_to_bitcoin,
- dateindex_to_close,
+ dateindex_to_price_close,
exit,
)
},
diff --git a/crates/brk_computer/src/grouped/value_from_height.rs b/crates/brk_computer/src/grouped/value_from_height.rs
index 63c2135b2..d38a2b88e 100644
--- a/crates/brk_computer/src/grouped/value_from_height.rs
+++ b/crates/brk_computer/src/grouped/value_from_height.rs
@@ -139,7 +139,7 @@ impl ComputedValueVecsFromHeight {
}
let height_to_bitcoin = self.bitcoin.height.as_ref().unwrap();
- let height_to_close = &price.as_ref().unwrap().chainindexes_to_close.height;
+ let height_to_price_close = &price.as_ref().unwrap().chainindexes_to_price_close.height;
if let Some(dollars) = self.dollars.as_mut() {
dollars.compute_all(
@@ -151,7 +151,7 @@ impl ComputedValueVecsFromHeight {
v.compute_from_bitcoin(
starting_indexes.height,
height_to_bitcoin,
- height_to_close,
+ height_to_price_close,
exit,
)
},
diff --git a/crates/brk_computer/src/grouped/value_from_txindex.rs b/crates/brk_computer/src/grouped/value_from_txindex.rs
index 0a3ee5210..ed3a7fa3a 100644
--- a/crates/brk_computer/src/grouped/value_from_txindex.rs
+++ b/crates/brk_computer/src/grouped/value_from_txindex.rs
@@ -78,23 +78,25 @@ impl ComputedValueVecsFromTxindex {
version + VERSION,
bitcoin_txindex.boxed_clone(),
indexes.txindex_to_height.boxed_clone(),
- price.chainindexes_to_close.height.boxed_clone(),
+ price.chainindexes_to_price_close.height.boxed_clone(),
|txindex: TxIndex,
- txindex_to_btc_iter,
+ txindex_to_in_btc_iter,
txindex_to_height_iter,
- height_to_close_iter| {
+ height_to_price_close_iter| {
let txindex = txindex.unwrap_to_usize();
- 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_close_iter
- .next_at(height.unwrap_to_usize())
- .map(|(_, close)| *close.into_owned() * btc)
- })
- })
+ 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)
+ })
+ })
},
)
});
diff --git a/crates/brk_computer/src/grouped/value_height.rs b/crates/brk_computer/src/grouped/value_height.rs
index ff6281d54..3fab71737 100644
--- a/crates/brk_computer/src/grouped/value_height.rs
+++ b/crates/brk_computer/src/grouped/value_height.rs
@@ -102,13 +102,13 @@ impl ComputedHeightValueVecs {
}
let height_to_bitcoin = &self.bitcoin;
- let height_to_close = &price.as_ref().unwrap().chainindexes_to_close.height;
+ let height_to_price_close = &price.as_ref().unwrap().chainindexes_to_price_close.height;
if let Some(dollars) = self.dollars.as_mut() {
dollars.compute_from_bitcoin(
starting_indexes.height,
height_to_bitcoin,
- height_to_close,
+ height_to_price_close,
exit,
)?;
}
diff --git a/crates/brk_computer/src/indexes.rs b/crates/brk_computer/src/indexes.rs
index 671821374..3b77c44c2 100644
--- a/crates/brk_computer/src/indexes.rs
+++ b/crates/brk_computer/src/indexes.rs
@@ -236,7 +236,7 @@ impl Vecs {
|index, _| Some(index),
);
- Ok(Self {
+ let this = Self {
emptyoutputindex_to_emptyoutputindex,
inputindex_to_inputindex,
opreturnindex_to_opreturnindex,
@@ -472,7 +472,16 @@ impl Vecs {
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
diff --git a/crates/brk_computer/src/market.rs b/crates/brk_computer/src/market.rs
index c1f3738f2..64140712e 100644
--- a/crates/brk_computer/src/market.rs
+++ b/crates/brk_computer/src/market.rs
@@ -23,46 +23,46 @@ const VERSION: Version = Version::ZERO;
pub struct Vecs {
db: Database,
- pub height_to_ath: EagerVec,
- pub height_to_drawdown: EagerVec,
- pub indexes_to_ath: ComputedVecsFromDateIndex,
- pub indexes_to_drawdown: ComputedVecsFromDateIndex,
- pub indexes_to_days_since_ath: ComputedVecsFromDateIndex,
- pub indexes_to_max_days_between_aths: ComputedVecsFromDateIndex,
- pub indexes_to_max_years_between_aths: ComputedVecsFromDateIndex,
+ pub height_to_price_ath: EagerVec,
+ pub height_to_price_drawdown: EagerVec,
+ pub indexes_to_price_ath: ComputedVecsFromDateIndex,
+ pub indexes_to_price_drawdown: ComputedVecsFromDateIndex,
+ pub indexes_to_days_since_price_ath: ComputedVecsFromDateIndex,
+ pub indexes_to_max_days_between_price_aths: ComputedVecsFromDateIndex,
+ pub indexes_to_max_years_between_price_aths: ComputedVecsFromDateIndex,
- pub indexes_to_1w_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_8d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_13d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_21d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_1m_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_34d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_55d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_89d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_144d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_200d_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_1y_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_2y_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_200w_sma: ComputedRatioVecsFromDateIndex,
- pub indexes_to_4y_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_1w_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_8d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_13d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_21d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_1m_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_34d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_55d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_89d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_144d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_200d_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_1y_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_2y_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_200w_sma: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_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_price_1w_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_8d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_13d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_21d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_1m_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_34d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_55d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_89d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_144d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_200d_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_1y_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_2y_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_200w_ema: ComputedRatioVecsFromDateIndex,
+ pub indexes_to_price_4y_ema: ComputedRatioVecsFromDateIndex,
- pub indexes_to_200d_sma_x2_4: ComputedVecsFromDateIndex,
- pub indexes_to_200d_sma_x0_8: ComputedVecsFromDateIndex,
+ pub indexes_to_price_200d_sma_x2_4: ComputedVecsFromDateIndex,
+ pub indexes_to_price_200d_sma_x0_8: ComputedVecsFromDateIndex,
pub price_1d_ago: ComputedVecsFromDateIndex,
pub price_1w_ago: ComputedVecsFromDateIndex,
@@ -78,19 +78,19 @@ pub struct Vecs {
pub price_8y_ago: ComputedVecsFromDateIndex,
pub price_10y_ago: ComputedVecsFromDateIndex,
- pub _1d_returns: ComputedVecsFromDateIndex,
- pub _1w_returns: ComputedVecsFromDateIndex,
- pub _1m_returns: ComputedVecsFromDateIndex,
- pub _3m_returns: ComputedVecsFromDateIndex,
- pub _6m_returns: ComputedVecsFromDateIndex,
- pub _1y_returns: ComputedVecsFromDateIndex,
- pub _2y_returns: ComputedVecsFromDateIndex,
- pub _3y_returns: ComputedVecsFromDateIndex,
- pub _4y_returns: ComputedVecsFromDateIndex,
- pub _5y_returns: ComputedVecsFromDateIndex,
- pub _6y_returns: ComputedVecsFromDateIndex,
- pub _8y_returns: ComputedVecsFromDateIndex,
- pub _10y_returns: ComputedVecsFromDateIndex,
+ pub _1d_price_returns: ComputedVecsFromDateIndex,
+ pub _1w_price_returns: ComputedVecsFromDateIndex,
+ pub _1m_price_returns: ComputedVecsFromDateIndex,
+ pub _3m_price_returns: ComputedVecsFromDateIndex,
+ pub _6m_price_returns: ComputedVecsFromDateIndex,
+ pub _1y_price_returns: ComputedVecsFromDateIndex,
+ pub _2y_price_returns: ComputedVecsFromDateIndex,
+ pub _3y_price_returns: ComputedVecsFromDateIndex,
+ pub _4y_price_returns: ComputedVecsFromDateIndex,
+ pub _5y_price_returns: ComputedVecsFromDateIndex,
+ pub _6y_price_returns: ComputedVecsFromDateIndex,
+ pub _8y_price_returns: ComputedVecsFromDateIndex,
+ pub _10y_price_returns: ComputedVecsFromDateIndex,
pub _2y_cagr: ComputedVecsFromDateIndex,
pub _3y_cagr: ComputedVecsFromDateIndex,
pub _4y_cagr: ComputedVecsFromDateIndex,
@@ -185,383 +185,383 @@ impl Vecs {
let db = Database::open(&parent.join("market"))?;
db.set_min_len(PAGE_SIZE * 1_000_000)?;
- Ok(Self {
- height_to_ath: EagerVec::forced_import_compressed(
+ let this = Self {
+ height_to_price_ath: EagerVec::forced_import_compressed(
&db,
- "ath",
+ "price_ath",
version + VERSION + Version::ZERO,
)?,
- height_to_drawdown: EagerVec::forced_import_compressed(
+ height_to_price_drawdown: EagerVec::forced_import_compressed(
&db,
- "drawdown",
+ "price_drawdown",
version + VERSION + Version::ZERO,
)?,
- indexes_to_ath: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_price_ath: ComputedVecsFromDateIndex::forced_import(
&db,
- "ath",
+ "price_ath",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_drawdown: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_price_drawdown: ComputedVecsFromDateIndex::forced_import(
&db,
- "drawdown",
+ "price_drawdown",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_days_since_ath: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_days_since_price_ath: ComputedVecsFromDateIndex::forced_import(
&db,
- "days_since_ath",
+ "days_since_price_ath",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_max_days_between_aths: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_max_days_between_price_aths: ComputedVecsFromDateIndex::forced_import(
&db,
- "max_days_between_aths",
+ "max_days_between_price_aths",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_max_years_between_aths: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_max_years_between_price_aths: ComputedVecsFromDateIndex::forced_import(
&db,
- "max_years_between_aths",
+ "max_years_between_price_aths",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_1w_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1w_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1w_sma",
+ "price_1w_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_8d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_8d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "8d_sma",
+ "price_8d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_13d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_13d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "13d_sma",
+ "price_13d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_21d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_21d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "21d_sma",
+ "price_21d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_1m_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1m_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1m_sma",
+ "price_1m_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_34d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_34d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "34d_sma",
+ "price_34d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_55d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_55d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "55d_sma",
+ "price_55d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_89d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_89d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "89d_sma",
+ "price_89d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_144d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_144d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "144d_sma",
+ "price_144d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_200d_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_200d_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "200d_sma",
+ "price_200d_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_1y_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1y_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1y_sma",
+ "price_1y_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_2y_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_2y_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "2y_sma",
+ "price_2y_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_200w_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_200w_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "200w_sma",
+ "price_200w_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_4y_sma: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_4y_sma: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "4y_sma",
+ "price_4y_sma",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_1w_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1w_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1w_ema",
+ "price_1w_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_8d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_8d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "8d_ema",
+ "price_8d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_13d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_13d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "13d_ema",
+ "price_13d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_21d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_21d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "21d_ema",
+ "price_21d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_1m_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1m_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1m_ema",
+ "price_1m_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_34d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_34d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "34d_ema",
+ "price_34d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_55d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_55d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "55d_ema",
+ "price_55d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_89d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_89d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "89d_ema",
+ "price_89d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_144d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_144d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "144d_ema",
+ "price_144d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_200d_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_200d_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "200d_ema",
+ "price_200d_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_1y_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_1y_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "1y_ema",
+ "price_1y_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_2y_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_2y_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "2y_ema",
+ "price_2y_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_200w_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_200w_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "200w_ema",
+ "price_200w_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- indexes_to_4y_ema: ComputedRatioVecsFromDateIndex::forced_import(
+ indexes_to_price_4y_ema: ComputedRatioVecsFromDateIndex::forced_import(
&db,
- "4y_ema",
+ "price_4y_ema",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
true,
)?,
- _1d_returns: ComputedVecsFromDateIndex::forced_import(
+ _1d_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "1d_returns",
+ "1d_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _1w_returns: ComputedVecsFromDateIndex::forced_import(
+ _1w_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "1w_returns",
+ "1w_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _1m_returns: ComputedVecsFromDateIndex::forced_import(
+ _1m_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "1m_returns",
+ "1m_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _3m_returns: ComputedVecsFromDateIndex::forced_import(
+ _3m_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "3m_returns",
+ "3m_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _6m_returns: ComputedVecsFromDateIndex::forced_import(
+ _6m_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "6m_returns",
+ "6m_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _1y_returns: ComputedVecsFromDateIndex::forced_import(
+ _1y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "1y_returns",
+ "1y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _2y_returns: ComputedVecsFromDateIndex::forced_import(
+ _2y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "2y_returns",
+ "2y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _3y_returns: ComputedVecsFromDateIndex::forced_import(
+ _3y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "3y_returns",
+ "3y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _4y_returns: ComputedVecsFromDateIndex::forced_import(
+ _4y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "4y_returns",
+ "4y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _5y_returns: ComputedVecsFromDateIndex::forced_import(
+ _5y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "5y_returns",
+ "5y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _6y_returns: ComputedVecsFromDateIndex::forced_import(
+ _6y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "6y_returns",
+ "6y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _8y_returns: ComputedVecsFromDateIndex::forced_import(
+ _8y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "8y_returns",
+ "8y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- _10y_returns: ComputedVecsFromDateIndex::forced_import(
+ _10y_price_returns: ComputedVecsFromDateIndex::forced_import(
&db,
- "10y_returns",
+ "10y_price_returns",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -1340,17 +1340,17 @@ impl Vecs {
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_200d_sma_x2_4: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_price_200d_sma_x2_4: ComputedVecsFromDateIndex::forced_import(
&db,
- "200d_sma_x2_4",
+ "price_200d_sma_x2_4",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- indexes_to_200d_sma_x0_8: ComputedVecsFromDateIndex::forced_import(
+ indexes_to_price_200d_sma_x0_8: ComputedVecsFromDateIndex::forced_import(
&db,
- "200d_sma_x0_8",
+ "price_200d_sma_x0_8",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
@@ -1358,7 +1358,16 @@ impl Vecs {
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
@@ -1382,19 +1391,19 @@ impl Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
- self.height_to_ath.compute_max(
+ self.height_to_price_ath.compute_max(
starting_indexes.height,
- &price.chainindexes_to_high.height,
+ &price.chainindexes_to_price_high.height,
exit,
)?;
- self.height_to_drawdown.compute_drawdown(
+ self.height_to_price_drawdown.compute_drawdown(
starting_indexes.height,
- &price.chainindexes_to_close.height,
- &self.height_to_ath,
+ &price.chainindexes_to_price_close.height,
+ &self.height_to_price_ath,
exit,
)?;
- self.indexes_to_ath.compute_all(
+ self.indexes_to_price_ath.compute_all(
indexer,
indexes,
starting_indexes,
@@ -1402,14 +1411,14 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_max(
starting_indexes.dateindex,
- price.timeindexes_to_high.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_high.dateindex.as_ref().unwrap(),
exit,
)?;
Ok(())
},
)?;
- self.indexes_to_drawdown.compute_all(
+ self.indexes_to_price_drawdown.compute_all(
indexer,
indexes,
starting_indexes,
@@ -1417,22 +1426,22 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_drawdown(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
- self.indexes_to_ath.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
+ self.indexes_to_price_ath.dateindex.as_ref().unwrap(),
exit,
)?;
Ok(())
},
)?;
- self.indexes_to_days_since_ath.compute_all(
+ self.indexes_to_days_since_price_ath.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
let mut high_iter = price
- .timeindexes_to_high
+ .timeindexes_to_price_high
.dateindex
.as_ref()
.unwrap()
@@ -1440,7 +1449,7 @@ impl Vecs {
let mut prev = None;
v.compute_transform(
starting_indexes.dateindex,
- self.indexes_to_ath.dateindex.as_ref().unwrap(),
+ self.indexes_to_price_ath.dateindex.as_ref().unwrap(),
|(i, ath, slf)| {
if prev.is_none() {
let i = i.unwrap_to_usize();
@@ -1464,7 +1473,7 @@ impl Vecs {
},
)?;
- self.indexes_to_max_days_between_aths.compute_all(
+ self.indexes_to_max_days_between_price_aths.compute_all(
indexer,
indexes,
starting_indexes,
@@ -1473,7 +1482,10 @@ impl Vecs {
let mut prev = None;
v.compute_transform(
starting_indexes.dateindex,
- self.indexes_to_days_since_ath.dateindex.as_ref().unwrap(),
+ self.indexes_to_days_since_price_ath
+ .dateindex
+ .as_ref()
+ .unwrap(),
|(i, days, slf)| {
if prev.is_none() {
let i = i.unwrap_to_usize();
@@ -1493,7 +1505,7 @@ impl Vecs {
},
)?;
- self.indexes_to_max_years_between_aths.compute_all(
+ self.indexes_to_max_years_between_price_aths.compute_all(
indexer,
indexes,
starting_indexes,
@@ -1501,7 +1513,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.indexes_to_max_days_between_aths
+ self.indexes_to_max_days_between_price_aths
.dateindex
.as_ref()
.unwrap(),
@@ -1513,52 +1525,72 @@ impl Vecs {
)?;
[
- (1, &mut self.price_1d_ago, &mut self._1d_returns, None),
- (7, &mut self.price_1w_ago, &mut self._1w_returns, None),
- (30, &mut self.price_1m_ago, &mut self._1m_returns, None),
- (3 * 30, &mut self.price_3m_ago, &mut self._3m_returns, None),
- (6 * 30, &mut self.price_6m_ago, &mut self._6m_returns, None),
- (365, &mut self.price_1y_ago, &mut self._1y_returns, None),
+ (1, &mut self.price_1d_ago, &mut self._1d_price_returns, None),
+ (7, &mut self.price_1w_ago, &mut self._1w_price_returns, None),
+ (
+ 30,
+ &mut self.price_1m_ago,
+ &mut self._1m_price_returns,
+ None,
+ ),
+ (
+ 3 * 30,
+ &mut self.price_3m_ago,
+ &mut self._3m_price_returns,
+ None,
+ ),
+ (
+ 6 * 30,
+ &mut self.price_6m_ago,
+ &mut self._6m_price_returns,
+ None,
+ ),
+ (
+ 365,
+ &mut self.price_1y_ago,
+ &mut self._1y_price_returns,
+ None,
+ ),
(
2 * 365,
&mut self.price_2y_ago,
- &mut self._2y_returns,
+ &mut self._2y_price_returns,
Some(&mut self._2y_cagr),
),
(
3 * 365,
&mut self.price_3y_ago,
- &mut self._3y_returns,
+ &mut self._3y_price_returns,
Some(&mut self._3y_cagr),
),
(
4 * 365,
&mut self.price_4y_ago,
- &mut self._4y_returns,
+ &mut self._4y_price_returns,
Some(&mut self._4y_cagr),
),
(
5 * 365,
&mut self.price_5y_ago,
- &mut self._5y_returns,
+ &mut self._5y_price_returns,
Some(&mut self._5y_cagr),
),
(
6 * 365,
&mut self.price_6y_ago,
- &mut self._6y_returns,
+ &mut self._6y_price_returns,
Some(&mut self._6y_cagr),
),
(
8 * 365,
&mut self.price_8y_ago,
- &mut self._8y_returns,
+ &mut self._8y_price_returns,
Some(&mut self._8y_cagr),
),
(
10 * 365,
&mut self.price_10y_ago,
- &mut self._10y_returns,
+ &mut self._10y_price_returns,
Some(&mut self._10y_cagr),
),
]
@@ -1572,7 +1604,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_previous_value(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
days,
exit,
)?;
@@ -1588,7 +1620,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage_change(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
days,
exit,
)?;
@@ -1714,7 +1746,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_dca_stack_via_len(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
days,
exit,
)?;
@@ -1746,7 +1778,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage_difference(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
dca_avg_price.dateindex.as_ref().unwrap(),
exit,
)?;
@@ -1856,7 +1888,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_dca_stack_via_from(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
dateindex,
exit,
)?;
@@ -1888,7 +1920,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage_difference(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
avg_price.dateindex.as_ref().unwrap(),
exit,
)?;
@@ -1901,62 +1933,74 @@ impl Vecs {
thread::scope(|s| -> Result<()> {
[
- (&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,
+ &mut self.indexes_to_price_1w_sma,
+ &mut self.indexes_to_price_1w_ema,
+ 7,
+ ),
+ (
+ &mut self.indexes_to_price_8d_sma,
+ &mut self.indexes_to_price_8d_ema,
+ 8,
+ ),
+ (
+ &mut self.indexes_to_price_13d_sma,
+ &mut self.indexes_to_price_13d_ema,
13,
),
(
- &mut self.indexes_to_21d_sma,
- &mut self.indexes_to_21d_ema,
+ &mut self.indexes_to_price_21d_sma,
+ &mut self.indexes_to_price_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,
+ &mut self.indexes_to_price_1m_sma,
+ &mut self.indexes_to_price_1m_ema,
+ 30,
+ ),
+ (
+ &mut self.indexes_to_price_34d_sma,
+ &mut self.indexes_to_price_34d_ema,
34,
),
(
- &mut self.indexes_to_55d_sma,
- &mut self.indexes_to_55d_ema,
+ &mut self.indexes_to_price_55d_sma,
+ &mut self.indexes_to_price_55d_ema,
55,
),
(
- &mut self.indexes_to_89d_sma,
- &mut self.indexes_to_89d_ema,
+ &mut self.indexes_to_price_89d_sma,
+ &mut self.indexes_to_price_89d_ema,
89,
),
(
- &mut self.indexes_to_144d_sma,
- &mut self.indexes_to_144d_ema,
+ &mut self.indexes_to_price_144d_sma,
+ &mut self.indexes_to_price_144d_ema,
144,
),
(
- &mut self.indexes_to_200d_sma,
- &mut self.indexes_to_200d_ema,
+ &mut self.indexes_to_price_200d_sma,
+ &mut self.indexes_to_price_200d_ema,
200,
),
(
- &mut self.indexes_to_1y_sma,
- &mut self.indexes_to_1y_ema,
+ &mut self.indexes_to_price_1y_sma,
+ &mut self.indexes_to_price_1y_ema,
365,
),
(
- &mut self.indexes_to_2y_sma,
- &mut self.indexes_to_2y_ema,
+ &mut self.indexes_to_price_2y_sma,
+ &mut self.indexes_to_price_2y_ema,
2 * 365,
),
(
- &mut self.indexes_to_200w_sma,
- &mut self.indexes_to_200w_ema,
+ &mut self.indexes_to_price_200w_sma,
+ &mut self.indexes_to_price_200w_ema,
200 * 7,
),
(
- &mut self.indexes_to_4y_sma,
- &mut self.indexes_to_4y_ema,
+ &mut self.indexes_to_price_4y_sma,
+ &mut self.indexes_to_price_4y_ema,
4 * 365,
),
]
@@ -1972,7 +2016,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_sma(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
days,
exit,
)?;
@@ -1989,7 +2033,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_ema(
starting_indexes.dateindex,
- price.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ price.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
days,
exit,
)?;
@@ -2001,7 +2045,7 @@ impl Vecs {
Ok(())
})?;
- self.indexes_to_200d_sma_x0_8.compute_all(
+ self.indexes_to_price_200d_sma_x0_8.compute_all(
indexer,
indexes,
starting_indexes,
@@ -2009,7 +2053,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.indexes_to_200d_sma
+ self.indexes_to_price_200d_sma
.price
.as_ref()
.unwrap()
@@ -2023,7 +2067,7 @@ impl Vecs {
},
)?;
- self.indexes_to_200d_sma_x2_4.compute_all(
+ self.indexes_to_price_200d_sma_x2_4.compute_all(
indexer,
indexes,
starting_indexes,
@@ -2031,7 +2075,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.indexes_to_200d_sma
+ self.indexes_to_price_200d_sma
.price
.as_ref()
.unwrap()
@@ -2050,41 +2094,41 @@ impl Vecs {
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
[
- self.indexes_to_ath.vecs(),
- self.indexes_to_drawdown.vecs(),
- self.indexes_to_days_since_ath.vecs(),
- self.indexes_to_max_days_between_aths.vecs(),
- self.indexes_to_max_years_between_aths.vecs(),
- self.indexes_to_1w_sma.vecs(),
- self.indexes_to_8d_sma.vecs(),
- self.indexes_to_13d_sma.vecs(),
- self.indexes_to_21d_sma.vecs(),
- self.indexes_to_1m_sma.vecs(),
- self.indexes_to_34d_sma.vecs(),
- self.indexes_to_55d_sma.vecs(),
- self.indexes_to_89d_sma.vecs(),
- self.indexes_to_144d_sma.vecs(),
- self.indexes_to_200d_sma.vecs(),
- self.indexes_to_1y_sma.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.indexes_to_price_ath.vecs(),
+ self.indexes_to_price_drawdown.vecs(),
+ self.indexes_to_days_since_price_ath.vecs(),
+ self.indexes_to_max_days_between_price_aths.vecs(),
+ self.indexes_to_max_years_between_price_aths.vecs(),
+ self.indexes_to_price_1w_sma.vecs(),
+ self.indexes_to_price_8d_sma.vecs(),
+ self.indexes_to_price_13d_sma.vecs(),
+ self.indexes_to_price_21d_sma.vecs(),
+ self.indexes_to_price_1m_sma.vecs(),
+ self.indexes_to_price_34d_sma.vecs(),
+ self.indexes_to_price_55d_sma.vecs(),
+ self.indexes_to_price_89d_sma.vecs(),
+ self.indexes_to_price_144d_sma.vecs(),
+ self.indexes_to_price_200d_sma.vecs(),
+ self.indexes_to_price_1y_sma.vecs(),
+ self.indexes_to_price_2y_sma.vecs(),
+ self.indexes_to_price_200w_sma.vecs(),
+ self.indexes_to_price_4y_sma.vecs(),
+ self.indexes_to_price_1w_ema.vecs(),
+ self.indexes_to_price_8d_ema.vecs(),
+ self.indexes_to_price_13d_ema.vecs(),
+ self.indexes_to_price_21d_ema.vecs(),
+ self.indexes_to_price_1m_ema.vecs(),
+ self.indexes_to_price_34d_ema.vecs(),
+ self.indexes_to_price_55d_ema.vecs(),
+ self.indexes_to_price_89d_ema.vecs(),
+ self.indexes_to_price_144d_ema.vecs(),
+ self.indexes_to_price_200d_ema.vecs(),
+ self.indexes_to_price_1y_ema.vecs(),
+ self.indexes_to_price_2y_ema.vecs(),
+ self.indexes_to_price_200w_ema.vecs(),
+ self.indexes_to_price_4y_ema.vecs(),
+ self.indexes_to_price_200d_sma_x0_8.vecs(),
+ self.indexes_to_price_200d_sma_x2_4.vecs(),
self.price_1d_ago.vecs(),
self.price_1w_ago.vecs(),
self.price_1m_ago.vecs(),
@@ -2098,19 +2142,19 @@ impl Vecs {
self.price_6y_ago.vecs(),
self.price_8y_ago.vecs(),
self.price_10y_ago.vecs(),
- self._1d_returns.vecs(),
- self._1w_returns.vecs(),
- self._1m_returns.vecs(),
- self._3m_returns.vecs(),
- self._6m_returns.vecs(),
- self._1y_returns.vecs(),
- self._2y_returns.vecs(),
- self._3y_returns.vecs(),
- self._4y_returns.vecs(),
- self._5y_returns.vecs(),
- self._6y_returns.vecs(),
- self._8y_returns.vecs(),
- self._10y_returns.vecs(),
+ self._1d_price_returns.vecs(),
+ self._1w_price_returns.vecs(),
+ self._1m_price_returns.vecs(),
+ self._3m_price_returns.vecs(),
+ self._6m_price_returns.vecs(),
+ self._1y_price_returns.vecs(),
+ self._2y_price_returns.vecs(),
+ self._3y_price_returns.vecs(),
+ self._4y_price_returns.vecs(),
+ self._5y_price_returns.vecs(),
+ self._6y_price_returns.vecs(),
+ self._8y_price_returns.vecs(),
+ self._10y_price_returns.vecs(),
self._2y_cagr.vecs(),
self._3y_cagr.vecs(),
self._4y_cagr.vecs(),
@@ -2194,7 +2238,7 @@ impl Vecs {
self.dca_class_2017_returns.vecs(),
self.dca_class_2016_returns.vecs(),
self.dca_class_2015_returns.vecs(),
- vec![&self.height_to_ath, &self.height_to_drawdown],
+ vec![&self.height_to_price_ath, &self.height_to_price_drawdown],
]
.into_iter()
.flatten()
diff --git a/crates/brk_computer/src/price.rs b/crates/brk_computer/src/price.rs
index ce471c49a..54eef63b8 100644
--- a/crates/brk_computer/src/price.rs
+++ b/crates/brk_computer/src/price.rs
@@ -23,50 +23,50 @@ use super::{
pub struct Vecs {
db: Database,
- pub dateindex_to_close_in_cents: EagerVec>,
- pub dateindex_to_high_in_cents: EagerVec>,
- pub dateindex_to_low_in_cents: EagerVec>,
- pub dateindex_to_ohlc: RawVec,
- pub dateindex_to_ohlc_in_sats: RawVec,
- pub dateindex_to_open_in_cents: EagerVec>,
- pub height_to_close_in_cents: EagerVec>,
- pub height_to_high_in_cents: EagerVec>,
- pub height_to_low_in_cents: EagerVec>,
- pub height_to_ohlc: RawVec,
- pub height_to_ohlc_in_sats: RawVec,
- pub height_to_open_in_cents: EagerVec>,
- pub timeindexes_to_close: ComputedVecsFromDateIndex>,
- pub timeindexes_to_high: ComputedVecsFromDateIndex>,
- pub timeindexes_to_low: ComputedVecsFromDateIndex>,
- pub timeindexes_to_open: ComputedVecsFromDateIndex>,
- pub timeindexes_to_open_in_sats: ComputedVecsFromDateIndex>,
- pub timeindexes_to_high_in_sats: ComputedVecsFromDateIndex>,
- pub timeindexes_to_low_in_sats: ComputedVecsFromDateIndex>,
- pub timeindexes_to_close_in_sats: ComputedVecsFromDateIndex>,
- pub chainindexes_to_close: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_high: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_low: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_open: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_open_in_sats: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict>,
- pub chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict>,
- pub weekindex_to_ohlc: RawVec,
- pub weekindex_to_ohlc_in_sats: RawVec,
- pub difficultyepoch_to_ohlc: RawVec,
- pub difficultyepoch_to_ohlc_in_sats: RawVec,
- pub monthindex_to_ohlc: RawVec,
- pub monthindex_to_ohlc_in_sats: RawVec,
- pub quarterindex_to_ohlc: RawVec,
- pub quarterindex_to_ohlc_in_sats: RawVec,
- pub semesterindex_to_ohlc: RawVec,
- pub semesterindex_to_ohlc_in_sats: RawVec,
- pub yearindex_to_ohlc: RawVec,
- pub yearindex_to_ohlc_in_sats: RawVec,
- // pub halvingepoch_to_ohlc: StorableVec,
- // pub halvingepoch_to_ohlc_in_sats: StorableVec,
- pub decadeindex_to_ohlc: RawVec,
- pub decadeindex_to_ohlc_in_sats: RawVec,
+ pub dateindex_to_price_close_in_cents: EagerVec>,
+ pub dateindex_to_price_high_in_cents: EagerVec>,
+ pub dateindex_to_price_low_in_cents: EagerVec>,
+ pub dateindex_to_price_ohlc: RawVec,
+ pub dateindex_to_price_ohlc_in_sats: RawVec,
+ pub dateindex_to_price_open_in_cents: EagerVec>,
+ pub height_to_price_close_in_cents: EagerVec>,
+ pub height_to_price_high_in_cents: EagerVec>,
+ pub height_to_price_low_in_cents: EagerVec>,
+ pub height_to_price_ohlc: RawVec,
+ pub height_to_price_ohlc_in_sats: RawVec,
+ pub height_to_price_open_in_cents: EagerVec>,
+ pub timeindexes_to_price_close: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_high: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_low: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_open: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_open_in_sats: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_high_in_sats: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_low_in_sats: ComputedVecsFromDateIndex>,
+ pub timeindexes_to_price_close_in_sats: ComputedVecsFromDateIndex>,
+ pub chainindexes_to_price_close: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_high: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_low: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_open: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_open_in_sats: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_high_in_sats: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_low_in_sats: ComputedVecsFromHeightStrict>,
+ pub chainindexes_to_price_close_in_sats: ComputedVecsFromHeightStrict>,
+ pub weekindex_to_price_ohlc: RawVec,
+ pub weekindex_to_price_ohlc_in_sats: RawVec,
+ pub difficultyepoch_to_price_ohlc: RawVec,
+ pub difficultyepoch_to_price_ohlc_in_sats: RawVec,
+ pub monthindex_to_price_ohlc: RawVec,
+ pub monthindex_to_price_ohlc_in_sats: RawVec,
+ pub quarterindex_to_price_ohlc: RawVec,
+ pub quarterindex_to_price_ohlc_in_sats: RawVec,
+ pub semesterindex_to_price_ohlc: RawVec,
+ pub semesterindex_to_price_ohlc_in_sats: RawVec,
+ pub yearindex_to_price_ohlc: RawVec,
+ pub yearindex_to_price_ohlc_in_sats: RawVec,
+ // pub halvingepoch_to_price_ohlc: StorableVec,
+ // pub halvingepoch_to_price_ohlc_in_sats: StorableVec,
+ pub decadeindex_to_price_ohlc: RawVec,
+ pub decadeindex_to_price_ohlc_in_sats: RawVec,
}
const VERSION: Version = Version::ZERO;
@@ -77,250 +77,263 @@ impl Vecs {
let db = Database::open(&parent.join("price"))?;
db.set_min_len(PAGE_SIZE * 1_000_000)?;
- Ok(Self {
- dateindex_to_ohlc: RawVec::forced_import(
+ let this = Self {
+ dateindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- dateindex_to_ohlc_in_sats: RawVec::forced_import(
+ dateindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- dateindex_to_close_in_cents: EagerVec::forced_import_compressed(
+ dateindex_to_price_close_in_cents: EagerVec::forced_import_compressed(
&db,
- "close_in_cents",
+ "price_close_in_cents",
version + VERSION + Version::ZERO,
)?,
- dateindex_to_high_in_cents: EagerVec::forced_import_compressed(
+ dateindex_to_price_high_in_cents: EagerVec::forced_import_compressed(
&db,
- "high_in_cents",
+ "price_high_in_cents",
version + VERSION + Version::ZERO,
)?,
- dateindex_to_low_in_cents: EagerVec::forced_import_compressed(
+ dateindex_to_price_low_in_cents: EagerVec::forced_import_compressed(
&db,
- "low_in_cents",
+ "price_low_in_cents",
version + VERSION + Version::ZERO,
)?,
- dateindex_to_open_in_cents: EagerVec::forced_import_compressed(
+ dateindex_to_price_open_in_cents: EagerVec::forced_import_compressed(
&db,
- "open_in_cents",
+ "price_open_in_cents",
version + VERSION + Version::ZERO,
)?,
- height_to_ohlc: RawVec::forced_import(&db, "ohlc", version + VERSION + Version::ZERO)?,
- height_to_ohlc_in_sats: RawVec::forced_import(
+ height_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc",
+ version + VERSION + Version::ZERO,
+ )?,
+ height_to_price_ohlc_in_sats: RawVec::forced_import(
+ &db,
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- height_to_close_in_cents: EagerVec::forced_import_compressed(
+ height_to_price_close_in_cents: EagerVec::forced_import_compressed(
&db,
- "close_in_cents",
+ "price_close_in_cents",
version + VERSION + Version::ZERO,
)?,
- height_to_high_in_cents: EagerVec::forced_import_compressed(
+ height_to_price_high_in_cents: EagerVec::forced_import_compressed(
&db,
- "high_in_cents",
+ "price_high_in_cents",
version + VERSION + Version::ZERO,
)?,
- height_to_low_in_cents: EagerVec::forced_import_compressed(
+ height_to_price_low_in_cents: EagerVec::forced_import_compressed(
&db,
- "low_in_cents",
+ "price_low_in_cents",
version + VERSION + Version::ZERO,
)?,
- height_to_open_in_cents: EagerVec::forced_import_compressed(
+ height_to_price_open_in_cents: EagerVec::forced_import_compressed(
&db,
- "open_in_cents",
+ "price_open_in_cents",
version + VERSION + Version::ZERO,
)?,
- timeindexes_to_open: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_open: ComputedVecsFromDateIndex::forced_import(
&db,
- "open",
+ "price_open",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_first(),
)?,
- timeindexes_to_high: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_high: ComputedVecsFromDateIndex::forced_import(
&db,
- "high",
+ "price_high",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_max(),
)?,
- timeindexes_to_low: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_low: ComputedVecsFromDateIndex::forced_import(
&db,
- "low",
+ "price_low",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_min(),
)?,
- timeindexes_to_close: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_close: ComputedVecsFromDateIndex::forced_import(
&db,
- "close",
+ "price_close",
Source::Compute,
version + VERSION + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- timeindexes_to_open_in_sats: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_open_in_sats: ComputedVecsFromDateIndex::forced_import(
&db,
- "open_in_sats",
+ "price_open_in_sats",
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
indexes,
VecBuilderOptions::default().add_first(),
)?,
- timeindexes_to_high_in_sats: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_high_in_sats: ComputedVecsFromDateIndex::forced_import(
&db,
- "high_in_sats",
+ "price_high_in_sats",
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
indexes,
VecBuilderOptions::default().add_max(),
)?,
- timeindexes_to_low_in_sats: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_low_in_sats: ComputedVecsFromDateIndex::forced_import(
&db,
- "low_in_sats",
+ "price_low_in_sats",
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
indexes,
VecBuilderOptions::default().add_min(),
)?,
- timeindexes_to_close_in_sats: ComputedVecsFromDateIndex::forced_import(
+ timeindexes_to_price_close_in_sats: ComputedVecsFromDateIndex::forced_import(
&db,
- "close_in_sats",
+ "price_close_in_sats",
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
indexes,
VecBuilderOptions::default().add_last(),
)?,
- chainindexes_to_open: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_open: ComputedVecsFromHeightStrict::forced_import(
&db,
- "open",
+ "price_open",
version + VERSION + Version::ZERO,
VecBuilderOptions::default().add_first(),
)?,
- chainindexes_to_high: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_high: ComputedVecsFromHeightStrict::forced_import(
&db,
- "high",
+ "price_high",
version + VERSION + Version::ZERO,
VecBuilderOptions::default().add_max(),
)?,
- chainindexes_to_low: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_low: ComputedVecsFromHeightStrict::forced_import(
&db,
- "low",
+ "price_low",
version + VERSION + Version::ZERO,
VecBuilderOptions::default().add_min(),
)?,
- chainindexes_to_close: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_close: ComputedVecsFromHeightStrict::forced_import(
&db,
- "close",
+ "price_close",
version + VERSION + Version::ZERO,
VecBuilderOptions::default().add_last(),
)?,
- chainindexes_to_open_in_sats: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_open_in_sats: ComputedVecsFromHeightStrict::forced_import(
&db,
- "open_in_sats",
+ "price_open_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
VecBuilderOptions::default().add_first(),
)?,
- chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_high_in_sats: ComputedVecsFromHeightStrict::forced_import(
&db,
- "high_in_sats",
+ "price_high_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
VecBuilderOptions::default().add_max(),
)?,
- chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_low_in_sats: ComputedVecsFromHeightStrict::forced_import(
&db,
- "low_in_sats",
+ "price_low_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
VecBuilderOptions::default().add_min(),
)?,
- chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict::forced_import(
+ chainindexes_to_price_close_in_sats: ComputedVecsFromHeightStrict::forced_import(
&db,
- "close_in_sats",
+ "price_close_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
VecBuilderOptions::default().add_last(),
)?,
- weekindex_to_ohlc: RawVec::forced_import(
+ weekindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- weekindex_to_ohlc_in_sats: RawVec::forced_import(
+ weekindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- difficultyepoch_to_ohlc: RawVec::forced_import(
+ difficultyepoch_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- difficultyepoch_to_ohlc_in_sats: RawVec::forced_import(
+ difficultyepoch_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- monthindex_to_ohlc: RawVec::forced_import(
+ monthindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- monthindex_to_ohlc_in_sats: RawVec::forced_import(
+ monthindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- quarterindex_to_ohlc: RawVec::forced_import(
+ quarterindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- quarterindex_to_ohlc_in_sats: RawVec::forced_import(
+ quarterindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- semesterindex_to_ohlc: RawVec::forced_import(
+ semesterindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- semesterindex_to_ohlc_in_sats: RawVec::forced_import(
+ semesterindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- yearindex_to_ohlc: RawVec::forced_import(
+ yearindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- yearindex_to_ohlc_in_sats: RawVec::forced_import(
+ yearindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
- // halvingepoch_to_ohlc: StorableVec::forced_import(db,
- // "halvingepoch_to_ohlc"), version + VERSION + Version::ZERO, format)?,
- decadeindex_to_ohlc: RawVec::forced_import(
+ // halvingepoch_to_price_ohlc: StorableVec::forced_import(db,
+ // "halvingepoch_to_price_ohlc"), version + VERSION + Version::ZERO, format)?,
+ decadeindex_to_price_ohlc: RawVec::forced_import(
&db,
- "ohlc",
+ "price_ohlc",
version + VERSION + Version::ZERO,
)?,
- decadeindex_to_ohlc_in_sats: RawVec::forced_import(
+ decadeindex_to_price_ohlc_in_sats: RawVec::forced_import(
&db,
- "ohlc_in_sats",
+ "price_ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
)?,
db,
- })
+ };
+
+ this.db.retain_regions(
+ this.vecs()
+ .into_iter()
+ .flat_map(|v| v.region_names())
+ .collect(),
+ )?;
+
+ Ok(this)
}
pub fn compute(
@@ -344,92 +357,95 @@ impl Vecs {
fetched: &fetched::Vecs,
exit: &Exit,
) -> Result<()> {
- self.height_to_open_in_cents.compute_transform(
+ self.height_to_price_open_in_cents.compute_transform(
starting_indexes.height,
- &fetched.height_to_ohlc_in_cents,
+ &fetched.height_to_price_ohlc_in_cents,
|(di, ohlc, ..)| (di, ohlc.open),
exit,
)?;
- self.height_to_high_in_cents.compute_transform(
+ self.height_to_price_high_in_cents.compute_transform(
starting_indexes.height,
- &fetched.height_to_ohlc_in_cents,
+ &fetched.height_to_price_ohlc_in_cents,
|(di, ohlc, ..)| (di, ohlc.high),
exit,
)?;
- self.height_to_low_in_cents.compute_transform(
+ self.height_to_price_low_in_cents.compute_transform(
starting_indexes.height,
- &fetched.height_to_ohlc_in_cents,
+ &fetched.height_to_price_ohlc_in_cents,
|(di, ohlc, ..)| (di, ohlc.low),
exit,
)?;
- self.height_to_close_in_cents.compute_transform(
+ self.height_to_price_close_in_cents.compute_transform(
starting_indexes.height,
- &fetched.height_to_ohlc_in_cents,
+ &fetched.height_to_price_ohlc_in_cents,
|(di, ohlc, ..)| (di, ohlc.close),
exit,
)?;
let index = starting_indexes
.height
- .min(Height::from(self.height_to_ohlc.len()));
+ .min(Height::from(self.height_to_price_ohlc.len()));
fetched
- .height_to_ohlc_in_cents
+ .height_to_price_ohlc_in_cents
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
- self.height_to_ohlc
- .forced_push_at(i, OHLCDollars::from(v.into_owned()), exit)?;
- Ok(())
- })?;
- self.height_to_ohlc.safe_flush(exit)?;
-
- self.dateindex_to_open_in_cents.compute_transform(
- starting_indexes.dateindex,
- &fetched.dateindex_to_ohlc_in_cents,
- |(di, ohlc, ..)| (di, ohlc.open),
- exit,
- )?;
-
- self.dateindex_to_high_in_cents.compute_transform(
- starting_indexes.dateindex,
- &fetched.dateindex_to_ohlc_in_cents,
- |(di, ohlc, ..)| (di, ohlc.high),
- exit,
- )?;
-
- self.dateindex_to_low_in_cents.compute_transform(
- starting_indexes.dateindex,
- &fetched.dateindex_to_ohlc_in_cents,
- |(di, ohlc, ..)| (di, ohlc.low),
- exit,
- )?;
-
- self.dateindex_to_close_in_cents.compute_transform(
- starting_indexes.dateindex,
- &fetched.dateindex_to_ohlc_in_cents,
- |(di, ohlc, ..)| (di, ohlc.close),
- exit,
- )?;
-
- let index = starting_indexes
- .dateindex
- .min(DateIndex::from(self.dateindex_to_ohlc.len()));
- fetched
- .dateindex_to_ohlc_in_cents
- .iter_at(index)
- .try_for_each(|(i, v)| -> Result<()> {
- self.dateindex_to_ohlc.forced_push_at(
+ self.height_to_price_ohlc.forced_push_at(
i,
OHLCDollars::from(v.into_owned()),
exit,
)?;
Ok(())
})?;
- self.dateindex_to_ohlc.safe_flush(exit)?;
+ self.height_to_price_ohlc.safe_flush(exit)?;
- self.timeindexes_to_close.compute_all(
+ self.dateindex_to_price_open_in_cents.compute_transform(
+ starting_indexes.dateindex,
+ &fetched.dateindex_to_price_ohlc_in_cents,
+ |(di, ohlc, ..)| (di, ohlc.open),
+ exit,
+ )?;
+
+ self.dateindex_to_price_high_in_cents.compute_transform(
+ starting_indexes.dateindex,
+ &fetched.dateindex_to_price_ohlc_in_cents,
+ |(di, ohlc, ..)| (di, ohlc.high),
+ exit,
+ )?;
+
+ self.dateindex_to_price_low_in_cents.compute_transform(
+ starting_indexes.dateindex,
+ &fetched.dateindex_to_price_ohlc_in_cents,
+ |(di, ohlc, ..)| (di, ohlc.low),
+ exit,
+ )?;
+
+ self.dateindex_to_price_close_in_cents.compute_transform(
+ starting_indexes.dateindex,
+ &fetched.dateindex_to_price_ohlc_in_cents,
+ |(di, ohlc, ..)| (di, ohlc.close),
+ exit,
+ )?;
+
+ let index = starting_indexes
+ .dateindex
+ .min(DateIndex::from(self.dateindex_to_price_ohlc.len()));
+ fetched
+ .dateindex_to_price_ohlc_in_cents
+ .iter_at(index)
+ .try_for_each(|(i, v)| -> Result<()> {
+ self.dateindex_to_price_ohlc.forced_push_at(
+ i,
+ OHLCDollars::from(v.into_owned()),
+ exit,
+ )?;
+ Ok(())
+ })?;
+ self.dateindex_to_price_ohlc.safe_flush(exit)?;
+
+ self.timeindexes_to_price_close.compute_all(
indexer,
indexes,
starting_indexes,
@@ -437,7 +453,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- &self.dateindex_to_ohlc,
+ &self.dateindex_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.close),
exit,
)?;
@@ -445,7 +461,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_high.compute_all(
+ self.timeindexes_to_price_high.compute_all(
indexer,
indexes,
starting_indexes,
@@ -453,7 +469,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- &self.dateindex_to_ohlc,
+ &self.dateindex_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.high),
exit,
)?;
@@ -461,7 +477,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_low.compute_all(
+ self.timeindexes_to_price_low.compute_all(
indexer,
indexes,
starting_indexes,
@@ -469,7 +485,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- &self.dateindex_to_ohlc,
+ &self.dateindex_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.low),
exit,
)?;
@@ -477,7 +493,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_open.compute_all(
+ self.timeindexes_to_price_open.compute_all(
indexer,
indexes,
starting_indexes,
@@ -485,7 +501,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- &self.dateindex_to_ohlc,
+ &self.dateindex_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.open),
exit,
)?;
@@ -493,7 +509,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_close.compute(
+ self.chainindexes_to_price_close.compute(
indexer,
indexes,
starting_indexes,
@@ -501,7 +517,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.height_to_ohlc,
+ &self.height_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.close),
exit,
)?;
@@ -509,7 +525,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_high.compute(
+ self.chainindexes_to_price_high.compute(
indexer,
indexes,
starting_indexes,
@@ -517,7 +533,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.height_to_ohlc,
+ &self.height_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.high),
exit,
)?;
@@ -525,7 +541,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_low.compute(
+ self.chainindexes_to_price_low.compute(
indexer,
indexes,
starting_indexes,
@@ -533,7 +549,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.height_to_ohlc,
+ &self.height_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.low),
exit,
)?;
@@ -541,7 +557,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_open.compute(
+ self.chainindexes_to_price_open.compute(
indexer,
indexes,
starting_indexes,
@@ -549,7 +565,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.height_to_ohlc,
+ &self.height_to_price_ohlc,
|(di, ohlc, ..)| (di, ohlc.open),
exit,
)?;
@@ -557,13 +573,17 @@ impl Vecs {
},
)?;
- let mut weekindex_first_iter = self.timeindexes_to_open.weekindex.unwrap_first().iter();
- let mut weekindex_max_iter = self.timeindexes_to_high.weekindex.unwrap_max().iter();
- let mut weekindex_min_iter = self.timeindexes_to_low.weekindex.unwrap_min().iter();
+ let mut weekindex_first_iter = self
+ .timeindexes_to_price_open
+ .weekindex
+ .unwrap_first()
+ .iter();
+ let mut weekindex_max_iter = self.timeindexes_to_price_high.weekindex.unwrap_max().iter();
+ let mut weekindex_min_iter = self.timeindexes_to_price_low.weekindex.unwrap_min().iter();
let index = starting_indexes
.weekindex
- .min(WeekIndex::from(self.weekindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(WeekIndex::from(self.weekindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.weekindex
.unwrap_last()
.iter_at(index)
@@ -572,7 +592,7 @@ impl Vecs {
let open = weekindex_first_iter.unwrap_get_inner(i);
let high = weekindex_max_iter.unwrap_get_inner(i);
let low = weekindex_min_iter.unwrap_get_inner(i);
- self.weekindex_to_ohlc.forced_push_at(
+ self.weekindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -584,24 +604,27 @@ impl Vecs {
)?;
Ok(())
})?;
- self.weekindex_to_ohlc.safe_flush(exit)?;
+ self.weekindex_to_price_ohlc.safe_flush(exit)?;
let mut difficultyepoch_first_iter = self
- .chainindexes_to_open
+ .chainindexes_to_price_open
.difficultyepoch
.unwrap_first()
.iter();
let mut difficultyepoch_max_iter = self
- .chainindexes_to_high
+ .chainindexes_to_price_high
.difficultyepoch
.unwrap_max()
.iter();
- let mut difficultyepoch_min_iter =
- self.chainindexes_to_low.difficultyepoch.unwrap_min().iter();
- let index = starting_indexes
+ let mut difficultyepoch_min_iter = self
+ .chainindexes_to_price_low
.difficultyepoch
- .min(DifficultyEpoch::from(self.difficultyepoch_to_ohlc.len()));
- self.chainindexes_to_close
+ .unwrap_min()
+ .iter();
+ let index = starting_indexes.difficultyepoch.min(DifficultyEpoch::from(
+ self.difficultyepoch_to_price_ohlc.len(),
+ ));
+ self.chainindexes_to_price_close
.difficultyepoch
.unwrap_last()
.iter_at(index)
@@ -610,7 +633,7 @@ impl Vecs {
let open = difficultyepoch_first_iter.unwrap_get_inner(i);
let high = difficultyepoch_max_iter.unwrap_get_inner(i);
let low = difficultyepoch_min_iter.unwrap_get_inner(i);
- self.difficultyepoch_to_ohlc.forced_push_at(
+ self.difficultyepoch_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -622,15 +645,23 @@ impl Vecs {
)?;
Ok(())
})?;
- self.difficultyepoch_to_ohlc.safe_flush(exit)?;
+ self.difficultyepoch_to_price_ohlc.safe_flush(exit)?;
- let mut monthindex_first_iter = self.timeindexes_to_open.monthindex.unwrap_first().iter();
- let mut monthindex_max_iter = self.timeindexes_to_high.monthindex.unwrap_max().iter();
- let mut monthindex_min_iter = self.timeindexes_to_low.monthindex.unwrap_min().iter();
+ let mut monthindex_first_iter = self
+ .timeindexes_to_price_open
+ .monthindex
+ .unwrap_first()
+ .iter();
+ let mut monthindex_max_iter = self
+ .timeindexes_to_price_high
+ .monthindex
+ .unwrap_max()
+ .iter();
+ let mut monthindex_min_iter = self.timeindexes_to_price_low.monthindex.unwrap_min().iter();
let index = starting_indexes
.monthindex
- .min(MonthIndex::from(self.monthindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(MonthIndex::from(self.monthindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.monthindex
.unwrap_last()
.iter_at(index)
@@ -639,7 +670,7 @@ impl Vecs {
let open = monthindex_first_iter.unwrap_get_inner(i);
let high = monthindex_max_iter.unwrap_get_inner(i);
let low = monthindex_min_iter.unwrap_get_inner(i);
- self.monthindex_to_ohlc.forced_push_at(
+ self.monthindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -651,16 +682,27 @@ impl Vecs {
)?;
Ok(())
})?;
- self.monthindex_to_ohlc.safe_flush(exit)?;
+ self.monthindex_to_price_ohlc.safe_flush(exit)?;
- let mut quarterindex_first_iter =
- self.timeindexes_to_open.quarterindex.unwrap_first().iter();
- let mut quarterindex_max_iter = self.timeindexes_to_high.quarterindex.unwrap_max().iter();
- let mut quarterindex_min_iter = self.timeindexes_to_low.quarterindex.unwrap_min().iter();
+ let mut quarterindex_first_iter = self
+ .timeindexes_to_price_open
+ .quarterindex
+ .unwrap_first()
+ .iter();
+ let mut quarterindex_max_iter = self
+ .timeindexes_to_price_high
+ .quarterindex
+ .unwrap_max()
+ .iter();
+ let mut quarterindex_min_iter = self
+ .timeindexes_to_price_low
+ .quarterindex
+ .unwrap_min()
+ .iter();
let index = starting_indexes
.quarterindex
- .min(QuarterIndex::from(self.quarterindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(QuarterIndex::from(self.quarterindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.quarterindex
.unwrap_last()
.iter_at(index)
@@ -669,7 +711,7 @@ impl Vecs {
let open = quarterindex_first_iter.unwrap_get_inner(i);
let high = quarterindex_max_iter.unwrap_get_inner(i);
let low = quarterindex_min_iter.unwrap_get_inner(i);
- self.quarterindex_to_ohlc.forced_push_at(
+ self.quarterindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -681,16 +723,27 @@ impl Vecs {
)?;
Ok(())
})?;
- self.quarterindex_to_ohlc.safe_flush(exit)?;
+ self.quarterindex_to_price_ohlc.safe_flush(exit)?;
- let mut semesterindex_first_iter =
- self.timeindexes_to_open.semesterindex.unwrap_first().iter();
- let mut semesterindex_max_iter = self.timeindexes_to_high.semesterindex.unwrap_max().iter();
- let mut semesterindex_min_iter = self.timeindexes_to_low.semesterindex.unwrap_min().iter();
+ let mut semesterindex_first_iter = self
+ .timeindexes_to_price_open
+ .semesterindex
+ .unwrap_first()
+ .iter();
+ let mut semesterindex_max_iter = self
+ .timeindexes_to_price_high
+ .semesterindex
+ .unwrap_max()
+ .iter();
+ let mut semesterindex_min_iter = self
+ .timeindexes_to_price_low
+ .semesterindex
+ .unwrap_min()
+ .iter();
let index = starting_indexes
.semesterindex
- .min(SemesterIndex::from(self.semesterindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(SemesterIndex::from(self.semesterindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.semesterindex
.unwrap_last()
.iter_at(index)
@@ -699,7 +752,7 @@ impl Vecs {
let open = semesterindex_first_iter.unwrap_get_inner(i);
let high = semesterindex_max_iter.unwrap_get_inner(i);
let low = semesterindex_min_iter.unwrap_get_inner(i);
- self.semesterindex_to_ohlc.forced_push_at(
+ self.semesterindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -711,15 +764,19 @@ impl Vecs {
)?;
Ok(())
})?;
- self.semesterindex_to_ohlc.safe_flush(exit)?;
+ self.semesterindex_to_price_ohlc.safe_flush(exit)?;
- let mut yearindex_first_iter = self.timeindexes_to_open.yearindex.unwrap_first().iter();
- let mut yearindex_max_iter = self.timeindexes_to_high.yearindex.unwrap_max().iter();
- let mut yearindex_min_iter = self.timeindexes_to_low.yearindex.unwrap_min().iter();
+ let mut yearindex_first_iter = self
+ .timeindexes_to_price_open
+ .yearindex
+ .unwrap_first()
+ .iter();
+ let mut yearindex_max_iter = self.timeindexes_to_price_high.yearindex.unwrap_max().iter();
+ let mut yearindex_min_iter = self.timeindexes_to_price_low.yearindex.unwrap_min().iter();
let index = starting_indexes
.yearindex
- .min(YearIndex::from(self.yearindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(YearIndex::from(self.yearindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.yearindex
.unwrap_last()
.iter_at(index)
@@ -728,7 +785,7 @@ impl Vecs {
let open = yearindex_first_iter.unwrap_get_inner(i);
let high = yearindex_max_iter.unwrap_get_inner(i);
let low = yearindex_min_iter.unwrap_get_inner(i);
- self.yearindex_to_ohlc.forced_push_at(
+ self.yearindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -740,18 +797,30 @@ impl Vecs {
)?;
Ok(())
})?;
- self.yearindex_to_ohlc.safe_flush(exit)?;
+ self.yearindex_to_price_ohlc.safe_flush(exit)?;
- // self.halvingepoch_to_ohlc
+ // self.halvingepoch_to_price_ohlc
// .compute_transform(starting_indexes.halvingepoch, other, t, exit)?;
- let mut decadeindex_first_iter = self.timeindexes_to_open.decadeindex.unwrap_first().iter();
- let mut decadeindex_max_iter = self.timeindexes_to_high.decadeindex.unwrap_max().iter();
- let mut decadeindex_min_iter = self.timeindexes_to_low.decadeindex.unwrap_min().iter();
+ let mut decadeindex_first_iter = self
+ .timeindexes_to_price_open
+ .decadeindex
+ .unwrap_first()
+ .iter();
+ let mut decadeindex_max_iter = self
+ .timeindexes_to_price_high
+ .decadeindex
+ .unwrap_max()
+ .iter();
+ let mut decadeindex_min_iter = self
+ .timeindexes_to_price_low
+ .decadeindex
+ .unwrap_min()
+ .iter();
let index = starting_indexes
.decadeindex
- .min(DecadeIndex::from(self.decadeindex_to_ohlc.len()));
- self.timeindexes_to_close
+ .min(DecadeIndex::from(self.decadeindex_to_price_ohlc.len()));
+ self.timeindexes_to_price_close
.decadeindex
.unwrap_last()
.iter_at(index)
@@ -760,7 +829,7 @@ impl Vecs {
let open = decadeindex_first_iter.unwrap_get_inner(i);
let high = decadeindex_max_iter.unwrap_get_inner(i);
let low = decadeindex_min_iter.unwrap_get_inner(i);
- self.decadeindex_to_ohlc.forced_push_at(
+ self.decadeindex_to_price_ohlc.forced_push_at(
i,
OHLCDollars {
open,
@@ -772,9 +841,9 @@ impl Vecs {
)?;
Ok(())
})?;
- self.decadeindex_to_ohlc.safe_flush(exit)?;
+ self.decadeindex_to_price_ohlc.safe_flush(exit)?;
- self.chainindexes_to_open_in_sats.compute(
+ self.chainindexes_to_price_open_in_sats.compute(
indexer,
indexes,
starting_indexes,
@@ -782,7 +851,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.chainindexes_to_open.height,
+ &self.chainindexes_to_price_open.height,
|(i, open, ..)| (i, Open::new(Sats::ONE_BTC / *open)),
exit,
)?;
@@ -790,7 +859,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_high_in_sats.compute(
+ self.chainindexes_to_price_high_in_sats.compute(
indexer,
indexes,
starting_indexes,
@@ -798,7 +867,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.chainindexes_to_low.height,
+ &self.chainindexes_to_price_low.height,
|(i, low, ..)| (i, High::new(Sats::ONE_BTC / *low)),
exit,
)?;
@@ -806,7 +875,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_low_in_sats.compute(
+ self.chainindexes_to_price_low_in_sats.compute(
indexer,
indexes,
starting_indexes,
@@ -814,7 +883,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.chainindexes_to_high.height,
+ &self.chainindexes_to_price_high.height,
|(i, high, ..)| (i, Low::new(Sats::ONE_BTC / *high)),
exit,
)?;
@@ -822,7 +891,7 @@ impl Vecs {
},
)?;
- self.chainindexes_to_close_in_sats.compute(
+ self.chainindexes_to_price_close_in_sats.compute(
indexer,
indexes,
starting_indexes,
@@ -830,7 +899,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.height,
- &self.chainindexes_to_close.height,
+ &self.chainindexes_to_price_close.height,
|(i, close, ..)| (i, Close::new(Sats::ONE_BTC / *close)),
exit,
)?;
@@ -838,7 +907,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_open_in_sats.compute_all(
+ self.timeindexes_to_price_open_in_sats.compute_all(
indexer,
indexes,
starting_indexes,
@@ -846,7 +915,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.timeindexes_to_open.dateindex.as_ref().unwrap(),
+ self.timeindexes_to_price_open.dateindex.as_ref().unwrap(),
|(i, open, ..)| (i, Open::new(Sats::ONE_BTC / *open)),
exit,
)?;
@@ -854,7 +923,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_high_in_sats.compute_all(
+ self.timeindexes_to_price_high_in_sats.compute_all(
indexer,
indexes,
starting_indexes,
@@ -862,7 +931,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.timeindexes_to_low.dateindex.as_ref().unwrap(),
+ self.timeindexes_to_price_low.dateindex.as_ref().unwrap(),
|(i, low, ..)| (i, High::new(Sats::ONE_BTC / *low)),
exit,
)?;
@@ -870,7 +939,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_low_in_sats.compute_all(
+ self.timeindexes_to_price_low_in_sats.compute_all(
indexer,
indexes,
starting_indexes,
@@ -878,7 +947,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.timeindexes_to_high.dateindex.as_ref().unwrap(),
+ self.timeindexes_to_price_high.dateindex.as_ref().unwrap(),
|(i, high, ..)| (i, Low::new(Sats::ONE_BTC / *high)),
exit,
)?;
@@ -886,7 +955,7 @@ impl Vecs {
},
)?;
- self.timeindexes_to_close_in_sats.compute_all(
+ self.timeindexes_to_price_close_in_sats.compute_all(
indexer,
indexes,
starting_indexes,
@@ -894,7 +963,7 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_transform(
starting_indexes.dateindex,
- self.timeindexes_to_close.dateindex.as_ref().unwrap(),
+ self.timeindexes_to_price_close.dateindex.as_ref().unwrap(),
|(i, close, ..)| (i, Close::new(Sats::ONE_BTC / *close)),
exit,
)?;
@@ -902,18 +971,18 @@ impl Vecs {
},
)?;
- let mut height_first_iter = self.chainindexes_to_open_in_sats.height.iter();
- let mut height_max_iter = self.chainindexes_to_high_in_sats.height.iter();
- let mut height_min_iter = self.chainindexes_to_low_in_sats.height.iter();
+ let mut height_first_iter = self.chainindexes_to_price_open_in_sats.height.iter();
+ let mut height_max_iter = self.chainindexes_to_price_high_in_sats.height.iter();
+ let mut height_min_iter = self.chainindexes_to_price_low_in_sats.height.iter();
let index = starting_indexes
.height
- .min(Height::from(self.height_to_ohlc_in_sats.len()));
- self.chainindexes_to_close_in_sats
+ .min(Height::from(self.height_to_price_ohlc_in_sats.len()));
+ self.chainindexes_to_price_close_in_sats
.height
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.height_to_ohlc_in_sats.forced_push_at(
+ self.height_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: height_first_iter.unwrap_get_inner(i),
@@ -925,37 +994,37 @@ impl Vecs {
)?;
Ok(())
})?;
- self.height_to_ohlc_in_sats.safe_flush(exit)?;
+ self.height_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut dateindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.dateindex
.as_ref()
.unwrap()
.iter();
let mut dateindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.dateindex
.as_ref()
.unwrap()
.iter();
let mut dateindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.dateindex
.as_ref()
.unwrap()
.iter();
let index = starting_indexes
.dateindex
- .min(DateIndex::from(self.dateindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ .min(DateIndex::from(self.dateindex_to_price_ohlc_in_sats.len()));
+ self.timeindexes_to_price_close_in_sats
.dateindex
.as_ref()
.unwrap()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.dateindex_to_ohlc_in_sats.forced_push_at(
+ self.dateindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: dateindex_first_iter.unwrap_get_inner(i),
@@ -967,33 +1036,33 @@ impl Vecs {
)?;
Ok(())
})?;
- self.dateindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.dateindex_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut weekindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.weekindex
.unwrap_first()
.iter();
let mut weekindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.weekindex
.unwrap_max()
.iter();
let mut weekindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.weekindex
.unwrap_min()
.iter();
let index = starting_indexes
.weekindex
- .min(WeekIndex::from(self.weekindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ .min(WeekIndex::from(self.weekindex_to_price_ohlc_in_sats.len()));
+ self.timeindexes_to_price_close_in_sats
.weekindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.weekindex_to_ohlc_in_sats.forced_push_at(
+ self.weekindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: weekindex_first_iter.unwrap_get_inner(i),
@@ -1005,33 +1074,33 @@ impl Vecs {
)?;
Ok(())
})?;
- self.weekindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.weekindex_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut difficultyepoch_first_iter = self
- .chainindexes_to_open_in_sats
+ .chainindexes_to_price_open_in_sats
.difficultyepoch
.unwrap_first()
.iter();
let mut difficultyepoch_max_iter = self
- .chainindexes_to_high_in_sats
+ .chainindexes_to_price_high_in_sats
.difficultyepoch
.unwrap_max()
.iter();
let mut difficultyepoch_min_iter = self
- .chainindexes_to_low_in_sats
+ .chainindexes_to_price_low_in_sats
.difficultyepoch
.unwrap_min()
.iter();
let index = starting_indexes.difficultyepoch.min(DifficultyEpoch::from(
- self.difficultyepoch_to_ohlc_in_sats.len(),
+ self.difficultyepoch_to_price_ohlc_in_sats.len(),
));
- self.chainindexes_to_close_in_sats
+ self.chainindexes_to_price_close_in_sats
.difficultyepoch
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.difficultyepoch_to_ohlc_in_sats.forced_push_at(
+ self.difficultyepoch_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: difficultyepoch_first_iter.unwrap_get_inner(i),
@@ -1043,33 +1112,34 @@ impl Vecs {
)?;
Ok(())
})?;
- self.difficultyepoch_to_ohlc_in_sats.safe_flush(exit)?;
+ self.difficultyepoch_to_price_ohlc_in_sats
+ .safe_flush(exit)?;
let mut monthindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.monthindex
.unwrap_first()
.iter();
let mut monthindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.monthindex
.unwrap_max()
.iter();
let mut monthindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.monthindex
.unwrap_min()
.iter();
- let index = starting_indexes
- .monthindex
- .min(MonthIndex::from(self.monthindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ let index = starting_indexes.monthindex.min(MonthIndex::from(
+ self.monthindex_to_price_ohlc_in_sats.len(),
+ ));
+ self.timeindexes_to_price_close_in_sats
.monthindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.monthindex_to_ohlc_in_sats.forced_push_at(
+ self.monthindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: monthindex_first_iter.unwrap_get_inner(i),
@@ -1081,33 +1151,33 @@ impl Vecs {
)?;
Ok(())
})?;
- self.monthindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.monthindex_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut quarterindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.quarterindex
.unwrap_first()
.iter();
let mut quarterindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.quarterindex
.unwrap_max()
.iter();
let mut quarterindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.quarterindex
.unwrap_min()
.iter();
- let index = starting_indexes
- .quarterindex
- .min(QuarterIndex::from(self.quarterindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ let index = starting_indexes.quarterindex.min(QuarterIndex::from(
+ self.quarterindex_to_price_ohlc_in_sats.len(),
+ ));
+ self.timeindexes_to_price_close_in_sats
.quarterindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.quarterindex_to_ohlc_in_sats.forced_push_at(
+ self.quarterindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: quarterindex_first_iter.unwrap_get_inner(i),
@@ -1119,33 +1189,33 @@ impl Vecs {
)?;
Ok(())
})?;
- self.quarterindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.quarterindex_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut semesterindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.semesterindex
.unwrap_first()
.iter();
let mut semesterindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.semesterindex
.unwrap_max()
.iter();
let mut semesterindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.semesterindex
.unwrap_min()
.iter();
let index = starting_indexes.semesterindex.min(SemesterIndex::from(
- self.semesterindex_to_ohlc_in_sats.len(),
+ self.semesterindex_to_price_ohlc_in_sats.len(),
));
- self.timeindexes_to_close_in_sats
+ self.timeindexes_to_price_close_in_sats
.semesterindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.semesterindex_to_ohlc_in_sats.forced_push_at(
+ self.semesterindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: semesterindex_first_iter.unwrap_get_inner(i),
@@ -1157,33 +1227,33 @@ impl Vecs {
)?;
Ok(())
})?;
- self.semesterindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.semesterindex_to_price_ohlc_in_sats.safe_flush(exit)?;
let mut yearindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.yearindex
.unwrap_first()
.iter();
let mut yearindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.yearindex
.unwrap_max()
.iter();
let mut yearindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.yearindex
.unwrap_min()
.iter();
let index = starting_indexes
.yearindex
- .min(YearIndex::from(self.yearindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ .min(YearIndex::from(self.yearindex_to_price_ohlc_in_sats.len()));
+ self.timeindexes_to_price_close_in_sats
.yearindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.yearindex_to_ohlc_in_sats.forced_push_at(
+ self.yearindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: yearindex_first_iter.unwrap_get_inner(i),
@@ -1195,36 +1265,36 @@ impl Vecs {
)?;
Ok(())
})?;
- self.yearindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.yearindex_to_price_ohlc_in_sats.safe_flush(exit)?;
- // self.halvingepoch_to_ohlc
+ // self.halvingepoch_to_price_ohlc
// _in_sats.compute_transform(starting_indexes.halvingepoch, other, t, exit)?;
let mut decadeindex_first_iter = self
- .timeindexes_to_open_in_sats
+ .timeindexes_to_price_open_in_sats
.decadeindex
.unwrap_first()
.iter();
let mut decadeindex_max_iter = self
- .timeindexes_to_high_in_sats
+ .timeindexes_to_price_high_in_sats
.decadeindex
.unwrap_max()
.iter();
let mut decadeindex_min_iter = self
- .timeindexes_to_low_in_sats
+ .timeindexes_to_price_low_in_sats
.decadeindex
.unwrap_min()
.iter();
- let index = starting_indexes
- .decadeindex
- .min(DecadeIndex::from(self.decadeindex_to_ohlc_in_sats.len()));
- self.timeindexes_to_close_in_sats
+ let index = starting_indexes.decadeindex.min(DecadeIndex::from(
+ self.decadeindex_to_price_ohlc_in_sats.len(),
+ ));
+ self.timeindexes_to_price_close_in_sats
.decadeindex
.unwrap_last()
.iter_at(index)
.try_for_each(|(i, v)| -> Result<()> {
let close = v.into_owned();
- self.decadeindex_to_ohlc_in_sats.forced_push_at(
+ self.decadeindex_to_price_ohlc_in_sats.forced_push_at(
i,
OHLCSats {
open: decadeindex_first_iter.unwrap_get_inner(i),
@@ -1236,7 +1306,7 @@ impl Vecs {
)?;
Ok(())
})?;
- self.decadeindex_to_ohlc_in_sats.safe_flush(exit)?;
+ self.decadeindex_to_price_ohlc_in_sats.safe_flush(exit)?;
Ok(())
}
@@ -1244,51 +1314,51 @@ impl Vecs {
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
vec![
vec![
- &self.dateindex_to_close_in_cents as &dyn AnyCollectableVec,
- &self.dateindex_to_high_in_cents,
- &self.dateindex_to_low_in_cents,
- &self.dateindex_to_ohlc,
- &self.dateindex_to_open_in_cents,
- &self.height_to_close_in_cents,
- &self.height_to_high_in_cents,
- &self.height_to_low_in_cents,
- &self.height_to_ohlc,
- &self.height_to_open_in_cents,
- &self.weekindex_to_ohlc,
- &self.difficultyepoch_to_ohlc,
- &self.monthindex_to_ohlc,
- &self.quarterindex_to_ohlc,
- &self.semesterindex_to_ohlc,
- &self.yearindex_to_ohlc,
- // &self.halvingepoch_to_ohlc,
- &self.decadeindex_to_ohlc,
- &self.height_to_ohlc_in_sats,
- &self.dateindex_to_ohlc_in_sats,
- &self.weekindex_to_ohlc_in_sats,
- &self.difficultyepoch_to_ohlc_in_sats,
- &self.monthindex_to_ohlc_in_sats,
- &self.quarterindex_to_ohlc_in_sats,
- &self.semesterindex_to_ohlc_in_sats,
- &self.yearindex_to_ohlc_in_sats,
- // &self.halvingepoch_to_ohlc_in_sats,
- &self.decadeindex_to_ohlc_in_sats,
+ &self.dateindex_to_price_close_in_cents as &dyn AnyCollectableVec,
+ &self.dateindex_to_price_high_in_cents,
+ &self.dateindex_to_price_low_in_cents,
+ &self.dateindex_to_price_ohlc,
+ &self.dateindex_to_price_open_in_cents,
+ &self.height_to_price_close_in_cents,
+ &self.height_to_price_high_in_cents,
+ &self.height_to_price_low_in_cents,
+ &self.height_to_price_ohlc,
+ &self.height_to_price_open_in_cents,
+ &self.weekindex_to_price_ohlc,
+ &self.difficultyepoch_to_price_ohlc,
+ &self.monthindex_to_price_ohlc,
+ &self.quarterindex_to_price_ohlc,
+ &self.semesterindex_to_price_ohlc,
+ &self.yearindex_to_price_ohlc,
+ // &self.halvingepoch_to_price_ohlc,
+ &self.decadeindex_to_price_ohlc,
+ &self.height_to_price_ohlc_in_sats,
+ &self.dateindex_to_price_ohlc_in_sats,
+ &self.weekindex_to_price_ohlc_in_sats,
+ &self.difficultyepoch_to_price_ohlc_in_sats,
+ &self.monthindex_to_price_ohlc_in_sats,
+ &self.quarterindex_to_price_ohlc_in_sats,
+ &self.semesterindex_to_price_ohlc_in_sats,
+ &self.yearindex_to_price_ohlc_in_sats,
+ // &self.halvingepoch_to_price_ohlc_in_sats,
+ &self.decadeindex_to_price_ohlc_in_sats,
],
- self.timeindexes_to_close.vecs(),
- self.timeindexes_to_high.vecs(),
- self.timeindexes_to_low.vecs(),
- self.timeindexes_to_open.vecs(),
- self.chainindexes_to_close.vecs(),
- self.chainindexes_to_high.vecs(),
- self.chainindexes_to_low.vecs(),
- self.chainindexes_to_open.vecs(),
- self.timeindexes_to_close_in_sats.vecs(),
- self.timeindexes_to_high_in_sats.vecs(),
- self.timeindexes_to_low_in_sats.vecs(),
- self.timeindexes_to_open_in_sats.vecs(),
- self.chainindexes_to_close_in_sats.vecs(),
- self.chainindexes_to_high_in_sats.vecs(),
- self.chainindexes_to_low_in_sats.vecs(),
- self.chainindexes_to_open_in_sats.vecs(),
+ self.timeindexes_to_price_close.vecs(),
+ self.timeindexes_to_price_high.vecs(),
+ self.timeindexes_to_price_low.vecs(),
+ self.timeindexes_to_price_open.vecs(),
+ self.chainindexes_to_price_close.vecs(),
+ self.chainindexes_to_price_high.vecs(),
+ self.chainindexes_to_price_low.vecs(),
+ self.chainindexes_to_price_open.vecs(),
+ self.timeindexes_to_price_close_in_sats.vecs(),
+ self.timeindexes_to_price_high_in_sats.vecs(),
+ self.timeindexes_to_price_low_in_sats.vecs(),
+ self.timeindexes_to_price_open_in_sats.vecs(),
+ self.chainindexes_to_price_close_in_sats.vecs(),
+ self.chainindexes_to_price_high_in_sats.vecs(),
+ self.chainindexes_to_price_low_in_sats.vecs(),
+ self.chainindexes_to_price_open_in_sats.vecs(),
]
.into_iter()
.flatten()
diff --git a/crates/brk_computer/src/stateful/address_cohort.rs b/crates/brk_computer/src/stateful/address_cohort.rs
index 26a85a107..d5b75dcf9 100644
--- a/crates/brk_computer/src/stateful/address_cohort.rs
+++ b/crates/brk_computer/src/stateful/address_cohort.rs
@@ -29,8 +29,8 @@ pub struct Vecs {
pub inner: common::Vecs,
- pub height_to_address_count: EagerVec,
- pub indexes_to_address_count: ComputedVecsFromHeight,
+ pub height_to_addr_count: EagerVec,
+ pub indexes_to_addr_count: ComputedVecsFromHeight,
}
impl Vecs {
@@ -43,7 +43,7 @@ impl Vecs {
indexes: &indexes::Vecs,
price: Option<&price::Vecs>,
states_path: Option<&Path>,
- compute_relative_to_all: bool,
+ compute_rel_to_all: bool,
) -> Result {
let compute_dollars = price.is_some();
@@ -58,15 +58,15 @@ impl Vecs {
compute_dollars,
)
}),
- height_to_address_count: EagerVec::forced_import(
+ height_to_addr_count: EagerVec::forced_import(
db,
- &suffix("address_count"),
+ &suffix("addr_count"),
version + VERSION + Version::ZERO,
format,
)?,
- indexes_to_address_count: ComputedVecsFromHeight::forced_import(
+ indexes_to_addr_count: ComputedVecsFromHeight::forced_import(
db,
- &suffix("address_count"),
+ &suffix("addr_count"),
Source::None,
version + VERSION + Version::ZERO,
indexes,
@@ -80,7 +80,7 @@ impl Vecs {
indexes,
price,
false,
- compute_relative_to_all,
+ compute_rel_to_all,
false,
)?,
})
@@ -90,7 +90,7 @@ impl Vecs {
impl DynCohortVecs for Vecs {
fn min_height_vecs_len(&self) -> usize {
[
- self.height_to_address_count.len(),
+ self.height_to_addr_count.len(),
self.inner.min_height_vecs_len(),
]
.into_iter()
@@ -110,8 +110,8 @@ impl DynCohortVecs for Vecs {
self.starting_height = Some(starting_height);
if let Some(prev_height) = starting_height.decremented() {
- self.state.as_mut().unwrap().address_count = *self
- .height_to_address_count
+ self.state.as_mut().unwrap().addr_count = *self
+ .height_to_addr_count
.into_iter()
.unwrap_get_inner(prev_height);
}
@@ -120,9 +120,9 @@ impl DynCohortVecs for Vecs {
}
fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> {
- self.height_to_address_count
+ self.height_to_addr_count
.validate_computed_version_or_reset(
- base_version + self.height_to_address_count.inner_version(),
+ base_version + self.height_to_addr_count.inner_version(),
)?;
self.inner.validate_computed_versions(base_version)
@@ -133,9 +133,9 @@ impl DynCohortVecs for Vecs {
return Ok(());
}
- self.height_to_address_count.forced_push_at(
+ self.height_to_addr_count.forced_push_at(
height,
- self.state.as_ref().unwrap().address_count.into(),
+ self.state.as_ref().unwrap().addr_count.into(),
exit,
)?;
@@ -162,7 +162,7 @@ impl DynCohortVecs for Vecs {
}
fn safe_flush_stateful_vecs(&mut self, height: Height, exit: &Exit) -> Result<()> {
- self.height_to_address_count.safe_flush(exit)?;
+ self.height_to_addr_count.safe_flush(exit)?;
self.inner
.safe_flush_stateful_vecs(height, exit, &mut self.state.as_mut().unwrap().inner)
@@ -177,11 +177,11 @@ impl DynCohortVecs for Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
- self.indexes_to_address_count.compute_rest(
+ self.indexes_to_addr_count.compute_rest(
indexes,
starting_indexes,
exit,
- Some(&self.height_to_address_count),
+ Some(&self.height_to_addr_count),
)?;
self.inner
@@ -191,8 +191,8 @@ impl DynCohortVecs for Vecs {
fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
[
self.inner.vecs(),
- self.indexes_to_address_count.vecs(),
- vec![&self.height_to_address_count],
+ self.indexes_to_addr_count.vecs(),
+ vec![&self.height_to_addr_count],
]
.concat()
}
@@ -205,11 +205,11 @@ impl CohortVecs for Vecs {
others: &[&Self],
exit: &Exit,
) -> Result<()> {
- self.height_to_address_count.compute_sum_of_others(
+ self.height_to_addr_count.compute_sum_of_others(
starting_indexes.height,
others
.iter()
- .map(|v| &v.height_to_address_count)
+ .map(|v| &v.height_to_addr_count)
.collect::>()
.as_slice(),
exit,
diff --git a/crates/brk_computer/src/stateful/common.rs b/crates/brk_computer/src/stateful/common.rs
index e365fbe82..1140c41a9 100644
--- a/crates/brk_computer/src/stateful/common.rs
+++ b/crates/brk_computer/src/stateful/common.rs
@@ -27,7 +27,7 @@ pub struct Vecs {
pub height_to_supply: EagerVec,
pub height_to_utxo_count: EagerVec,
// Single
- pub dateindex_to_supply_even: Option>,
+ pub dateindex_to_supply_breakeven: Option>,
pub dateindex_to_supply_in_loss: Option>,
pub dateindex_to_supply_in_profit: Option>,
pub dateindex_to_unrealized_loss: Option>,
@@ -38,7 +38,7 @@ pub struct Vecs {
pub height_to_min_price_paid: Option>,
pub height_to_realized_loss: Option>,
pub height_to_realized_profit: Option>,
- pub height_to_supply_even: Option>,
+ pub height_to_supply_breakeven: Option>,
pub height_to_supply_in_loss: Option>,
pub height_to_supply_in_profit: Option>,
pub height_to_unrealized_loss: Option>,
@@ -50,22 +50,20 @@ pub struct Vecs {
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight,
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight,
- pub dateindex_to_spent_output_profit_ratio: Option>,
- pub dateindex_to_spent_output_profit_ratio_7d_ema: Option>,
- pub dateindex_to_spent_output_profit_ratio_30d_ema: Option>,
- pub dateindex_to_adjusted_spent_output_profit_ratio: Option