Skip to main content

apple_quant_algorithmic/timestamp/
tick.rs

1use std::ops::Deref;
2
3use super::{Timestamp, Timestamped};
4
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct TickTimestamp(Timestamp);
7
8impl TickTimestamp {
9	pub(crate) fn now() -> Self {
10		let timestamp = Timestamp::now();
11		Self(timestamp)
12	}
13
14	pub(crate) fn from_timestamp(
15		timestamp: Timestamp,
16	) -> Self {
17		Self(timestamp)
18	}
19
20	pub fn as_timestamp(
21		&self,
22	) -> &Timestamp {
23		&self.0
24	}
25
26	pub fn into_timestamp(
27		self,
28	) -> Timestamp {
29		self.0
30	}
31}
32
33impl Timestamped for TickTimestamp {
34	fn timestamp(
35		&self,
36	) -> Timestamp {
37		self.0
38	}
39}
40
41impl Deref for TickTimestamp {
42	type Target = Timestamp;
43
44	fn deref(
45		&self,
46	) -> &Self::Target {
47		&self.0
48	}
49}