Skip to main content

apple_quant_algorithmic/timestamp/
point_trade.rs

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