Skip to main content

apple_quant_algorithmic/volume/
fast.rs

1use bevy::prelude::{Deref, DerefMut};
2
3#[repr(u32)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Interpretation {
6	Whole,
7	Decimal { multiplier: u32 },
8}
9
10#[derive(Deref, DerefMut, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub struct FastVolume(i64);
12
13impl FastVolume {
14	pub fn as_whole_i64(self) -> i64 {
15		self.0
16	}
17
18	pub fn as_interpreted_f64(
19		self,
20		interpretation: Interpretation,
21	) -> f64 {
22		match interpretation {
23			Interpretation::Whole => self.0 as f64,
24			Interpretation::Decimal { multiplier } => self.0 as f64 * multiplier as f64,
25		}
26	}
27}