Skip to main content

apple_quant_algorithmic/
timestamp.rs

1use thiserror::Error;
2
3mod bin;
4mod engine;
5mod latest_session_start;
6mod point;
7mod point_trade;
8mod provider;
9mod range;
10mod range_trade;
11
12pub use bin::*;
13pub use engine::*;
14pub use latest_session_start::*;
15pub use point::*;
16pub use point_trade::*;
17pub use provider::*;
18pub use range::*;
19pub use range_trade::*;
20
21#[derive(Debug, Error)]
22pub enum TimestampError {
23	// #[error("BinTimestamp already in use: {0:?}.")]
24	// BinTimestampInUse(RuntimeBinTimestamp),
25
26	// #[error(
27	// 	"Unable to append {trade:?} with {trade_timestamp:?} older then the youngest {youngest_trade_timestamp:?}."
28	// )]
29	// TradeToOld {
30	// 	trade: RuntimeTrade,
31	// 	trade_timestamp: TradeTimestamp,
32	// 	youngest_trade_timestamp: TradeTimestamp,
33	// },
34
35	// #[error(
36	// 	"Unable to append {bar:?} with {bin_timestamp:?} older then the youngest {youngest_bin_timestamp:?}."
37	// )]
38	// BarToOld {
39	// 	bar: RuntimeOHLC,
40	// 	bin_timestamp: RuntimeBinTimestamp,
41	// 	youngest_bin_timestamp: RuntimeBinTimestamp,
42	// },
43	#[error("Range is not satisfied. MIN: {min:?} MAX: {max:?}.")]
44	RangeNotSatisfied {
45		min: Option<TradeTimestamp>,
46		max: Option<TradeTimestamp>,
47	},
48}
49
50pub trait Timestamped {
51	fn timestamp(&self) -> &Timestamp;
52}
53
54pub trait TradeTimestamped {
55	fn trade_timestamp(&self) -> &TradeTimestamp;
56}
57
58pub trait TimestampedRange {
59	fn timestamp_range(&self) -> &TimestampRange;
60}
61
62pub trait TradeTimestampedRange {
63	fn trade_timestamp_range(&self) -> &TradeTimestampRange;
64}