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