Skip to main content

apple_quant_algorithmic/
timestamp.rs

1mod bin;
2mod current_session_start;
3mod engine;
4mod point;
5mod point_trade;
6mod provider;
7mod range;
8mod range_trade;
9mod tick;
10mod utc_ns;
11
12use thiserror::Error;
13pub use bin::*;
14pub use current_session_start::*;
15pub use engine::*;
16pub use point::*;
17pub use point_trade::*;
18pub use provider::*;
19pub use range::*;
20pub use range_trade::*;
21pub use tick::*;
22pub use utc_ns::*;
23
24#[derive(Debug, Error)]
25pub enum TimestampError {
26	#[error("Range is not satisfied. Min: `{min:?}` max: `{max:?}`.")]
27	RangeNotSatisfied {
28		min: Option<TradeTimestamp>,
29		max: Option<TradeTimestamp>,
30	},
31}
32
33#[cfg(not(feature = "timestamp-u64"))]
34pub type TimestampType = i128;
35
36#[cfg(feature = "timestamp-u64")]
37pub type TimestampType = u64;
38
39pub trait Timestamped {
40	fn timestamp(
41		&self,
42	) -> Timestamp;
43}
44
45pub trait TradeTimestamped {
46	fn trade_timestamp(
47		&self,
48	) -> TradeTimestamp;
49}
50
51pub trait TimestampRangeIncluded {
52	fn timestamp_range_inclusive(
53		&self,
54	) -> TimestampRangeInclusive;
55}
56
57pub trait TimestampRangeExcluded {
58	fn timestamp_range_exclusive(
59		&self,
60	) -> TimestampRangeExclusive;
61}
62
63pub trait TradeTimestampRangeIncluded {
64	fn trade_timestamp_range_inclusive(
65		&self,
66	) -> TradeTimestampRangeInclusive;
67}
68
69pub trait TradeTimestampRangeExcluded {
70	fn trade_timestamp_range_exclusive(
71		&self,
72	) -> TradeTimestampRangeExclusive;
73}