diff --git a/app/src/scripts/presets/market/averages/index.ts b/app/src/scripts/presets/market/averages/index.ts index d75a88e7e..19dd6d166 100644 --- a/app/src/scripts/presets/market/averages/index.ts +++ b/app/src/scripts/presets/market/averages/index.ts @@ -1,9 +1,7 @@ import { averages } from "/src/scripts/datasets/date"; import { colors } from "/src/scripts/utils/colors"; -export function createPresets(): PartialPresetFolder { - const scale: ResourceScale = "date"; - +export function createPresets(scale: ResourceScale): PartialPresetFolder { return { name: "Averages", tree: [ @@ -55,7 +53,7 @@ function createPresetFolder({ { title: `SMA`, color, - datasetPath: `/date-to-price-${key}-sma`, + datasetPath: `/${scale}-to-price-${key}-sma`, }, ], }, @@ -64,19 +62,24 @@ function createPresetFolder({ name: "Ratio", description: "", icon: IconTablerMathXDivideY, - title: `${name} Moving Average Ratio`, + title: `Market Price To ${name} Moving Average Ratio`, top: [ { title: `SMA`, color, - datasetPath: `/date-to-price-${key}-sma`, + datasetPath: `/${scale}-to-price-${key}-sma`, }, ], bottom: [ { title: `Ratio`, color, - datasetPath: `/date-to-market-price-to-price-${key}-sma-ratio`, + datasetPath: `/${scale}-to-market-price-to-price-${key}-sma-ratio`, + }, + { + title: `Even`, + color: colors.white, + datasetPath: `/${scale}-to-1`, }, ], }, diff --git a/app/src/scripts/presets/market/index.ts b/app/src/scripts/presets/market/index.ts index 667c1d93b..1211c274c 100644 --- a/app/src/scripts/presets/market/index.ts +++ b/app/src/scripts/presets/market/index.ts @@ -28,9 +28,9 @@ export function createPresets(scale: ResourceScale) { }, ], }, + createAveragesPresets(scale), ...(scale === "date" ? ([ - createAveragesPresets(), createReturnsPresets(), createIndicatorsPresets(), ] satisfies PartialPresetTree) diff --git a/parser/src/datasets/constant.rs b/parser/src/datasets/constant.rs index 3f1dae68c..03459f0ba 100644 --- a/parser/src/datasets/constant.rs +++ b/parser/src/datasets/constant.rs @@ -9,6 +9,8 @@ pub struct ConstantDataset { min_initial_states: MinInitialStates, // Computed + pub _0: BiMap, + pub _1: BiMap, pub _50: BiMap, pub _100: BiMap, } @@ -20,6 +22,8 @@ impl ConstantDataset { let mut s = Self { min_initial_states: MinInitialStates::default(), + _0: BiMap::new_bin(1, &f("0")), + _1: BiMap::new_bin(1, &f("1")), _50: BiMap::new_bin(1, &f("50")), _100: BiMap::new_bin(1, &f("100")), }; @@ -31,8 +35,9 @@ impl ConstantDataset { } pub fn compute(&mut self, &ComputeData { heights, dates }: &ComputeData) { + self._0.multi_insert_const(heights, dates, 0); + self._1.multi_insert_const(heights, dates, 1); self._50.multi_insert_const(heights, dates, 50); - self._100.multi_insert_const(heights, dates, 100); } } @@ -43,10 +48,10 @@ impl AnyDataset for ConstantDataset { } fn to_computed_bi_map_vec(&self) -> Vec<&(dyn AnyBiMap + Send + Sync)> { - vec![&self._50, &self._100] + vec![&self._0, &self._1, &self._50, &self._100] } fn to_computed_mut_bi_map_vec(&mut self) -> Vec<&mut dyn AnyBiMap> { - vec![&mut self._50, &mut self._100] + vec![&mut self._0, &mut self._1, &mut self._50, &mut self._100] } }