diff --git a/.gitignore b/.gitignore index ad84eaf99..6c8b845bd 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,6 @@ docker/kibo # Types paths.d.ts -vecid-to-indexes.d.ts # Outputs _outputs diff --git a/crates/brk_computer/src/storage/vecs/stats/generic.rs b/crates/brk_computer/src/storage/vecs/stats/generic.rs index 21cc0c7c0..c3c9ba548 100644 --- a/crates/brk_computer/src/storage/vecs/stats/generic.rs +++ b/crates/brk_computer/src/storage/vecs/stats/generic.rs @@ -39,8 +39,23 @@ where let name = path.file_name().unwrap().to_str().unwrap().to_string(); let key = I::to_string().split("::").last().unwrap().to_lowercase(); - let prefix = |s: &str| path.with_file_name(format!("{key}_to_{s}_{name}")); - let suffix = |s: &str| path.with_file_name(format!("{key}_to_{name}_{s}")); + let only_one_active = options.is_only_one_active(); + + let prefix = |s: &str| { + if only_one_active { + path.with_file_name(format!("{key}_to_{name}")) + } else { + path.with_file_name(format!("{key}_to_{s}_{name}")) + } + }; + + let suffix = |s: &str| { + if only_one_active { + path.with_file_name(format!("{key}_to_{name}")) + } else { + path.with_file_name(format!("{key}_to_{name}_{s}")) + } + }; let s = Self { first: options.first.then(|| { @@ -563,4 +578,24 @@ impl StorableVecGeneatorOptions { self._10p = false; self } + + pub fn is_only_one_active(&self) -> bool { + [ + self.average, + self.sum, + self.max, + self._90p, + self._75p, + self.median, + self._25p, + self._10p, + self.min, + self.first, + self.last, + ] + .iter() + .filter(|b| **b) + .count() + == 1 + } } diff --git a/crates/brk_fetcher/src/fetchers/binance.rs b/crates/brk_fetcher/src/fetchers/binance.rs index af866109f..b76be66d1 100644 --- a/crates/brk_fetcher/src/fetchers/binance.rs +++ b/crates/brk_fetcher/src/fetchers/binance.rs @@ -82,7 +82,7 @@ impl Binance { } pub fn get_from_1d(&mut self, date: &Date) -> color_eyre::Result { - if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 < date { + if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 <= date { self._1d.replace(Self::fetch_1d()?); } diff --git a/crates/brk_fetcher/src/fetchers/kibo.rs b/crates/brk_fetcher/src/fetchers/kibo.rs index 17fa669ca..9408b0143 100644 --- a/crates/brk_fetcher/src/fetchers/kibo.rs +++ b/crates/brk_fetcher/src/fetchers/kibo.rs @@ -81,7 +81,7 @@ impl Kibo { .last_key_value() .unwrap() .0 - < date + <= date { self.year_to_date_to_ohlc .insert(year, Self::fetch_date_prices(year)?); diff --git a/crates/brk_fetcher/src/fetchers/kraken.rs b/crates/brk_fetcher/src/fetchers/kraken.rs index ded973cb1..b1e2eef1c 100644 --- a/crates/brk_fetcher/src/fetchers/kraken.rs +++ b/crates/brk_fetcher/src/fetchers/kraken.rs @@ -43,7 +43,7 @@ impl Kraken { } pub fn get_from_1d(&mut self, date: &Date) -> color_eyre::Result { - if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 < date { + if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 <= date { self._1d.replace(Kraken::fetch_1d()?); } self._1d diff --git a/crates/brk_server/src/api/query/dts.rs b/crates/brk_server/src/api/query/dts.rs index a9a42dd4b..31dfac6fd 100644 --- a/crates/brk_server/src/api/query/dts.rs +++ b/crates/brk_server/src/api/query/dts.rs @@ -31,7 +31,12 @@ impl DTS for Query<'static> { let indexes = Index::all(); - let mut contents = indexes + let mut contents = "// +// File auto-generated, any modification will be overwritten +//\n\n" + .to_string(); + + contents += &indexes .iter() .enumerate() .map(|(i_of_i, i)| { diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index b9905e32a..9b5eb7bdc 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -61,7 +61,7 @@ * @typedef {Object} PartialChartOptionSpecific * @property {"chart"} [kind] * @property {Unit} [unit] - * @property {string} [title] + * @property {string} title * @property {AnyFetchedSeriesBlueprint[]} [top] * @property {AnyFetchedSeriesBlueprint[]} [bottom] * @typedef {PartialOption & PartialChartOptionSpecific} PartialChartOption @@ -668,7 +668,20 @@ function createPartialOptions(colors) { name: "Blocks", tree: [ { - name: "Block Interval", + name: "Count", + title: "Block Count", + bottom: [ + { key: "block-count", title: "Count", color: colors.bitcoin }, + { + key: "total-block-count", + title: "Total", + color: colors.bitcoin, + }, + ], + }, + { + name: "Interval", + title: "Block Interval", bottom: [ { key: "block-interval", @@ -1066,6 +1079,8 @@ export function initOptions({ anyPartial.unit = "Seconds"; } else if (key.startsWith("sats-")) { anyPartial.unit = "Satoshis"; + } else if (key.includes("count")) { + anyPartial.unit = "Count"; } else { console.log(anyPartial); throw Error("Unit not set"); diff --git a/websites/kibo.money/scripts/simulation.js b/websites/kibo.money/scripts/simulation.js index 289c496cf..fdd075376 100644 --- a/websites/kibo.money/scripts/simulation.js +++ b/websites/kibo.money/scripts/simulation.js @@ -945,7 +945,7 @@ export function init({ p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`; signals.createEffect( - () => 0.2368, + () => 0.073, (lowestAnnual4YReturn) => { const serLowestAnnual4YReturn = c( "cyan", diff --git a/websites/kibo.money/scripts/vecid-to-indexes.js b/websites/kibo.money/scripts/vecid-to-indexes.js index 63abbc3db..68afdbdfd 100644 --- a/websites/kibo.money/scripts/vecid-to-indexes.js +++ b/websites/kibo.money/scripts/vecid-to-indexes.js @@ -1,3 +1,7 @@ +// +// File auto-generated, any modification will be overwritten +// + /** @typedef {0} Height */ /** @typedef {1} Dateindex */ /** @typedef {2} Weekindex */ @@ -72,7 +76,6 @@ export function createVecIdToIndexes() { "first-height": [Dateindex, Difficultyepoch, Halvingepoch], "first-monthindex": [Quarterindex, Yearindex], "first-multisigindex": [Height], - "first-open": [Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "first-opreturnindex": [Height], "first-p2pk33index": [Height], "first-p2pk65index": [Height], @@ -91,9 +94,8 @@ export function createVecIdToIndexes() { "fixed-timestamp": [Height], halvingepoch: [Height, Halvingepoch], height: [Addressindex, Height, Txindex], - high: [Dateindex, Height], + high: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "high-in-cents": [Dateindex, Height], - "high-max": [Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "inputs-count": [Txindex], "is-coinbase": [Txindex], "is-explicitly-rbf": [Txindex], @@ -105,13 +107,12 @@ export function createVecIdToIndexes() { "last-txoutindex": [Txindex], "last-yearindex": [Decadeindex], locktime: [Txindex], - low: [Dateindex, Height], + low: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "low-in-cents": [Dateindex, Height], - "low-min": [Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], monthindex: [Dateindex, Monthindex], ohlc: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "ohlc-in-cents": [Dateindex, Height], - open: [Dateindex, Height], + open: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "open-in-cents": [Dateindex, Height], "outputs-count": [Txindex], p2pk33addressbytes: [P2PK33index],