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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/// A price value.
///
/// Semantic alias for [`f64`]. Documents intent in function signatures
/// without introducing newtype construction overhead.
pub type Price = f64;
/// Bar open timestamp or sequence number.
///
/// Used for bar boundary detection. Must be non-decreasing
/// between consecutive calls to [`Indicator::compute`].
///
/// Recommended: microseconds since Unix epoch, monotonically increasing.
/// This is **required** for the VWAP indicator, which uses timestamps
/// to detect session boundaries.
pub type Timestamp = u64;
/// OHLCV bar data used as input to all indicators.
///
/// Implement this on your own kline/candle type to avoid per-tick
/// conversion. Indicators accept `&impl Ohlcv` and extract the
/// configured [`PriceSource`] internally.
///
/// # Bar boundaries
///
/// Indicators detect new bars by comparing [`open_time`](Ohlcv::open_time)
/// values: same timestamp updates (repaints) the current bar, a new timestamp
/// advances the window.
///
/// # Example
///
/// ```
/// use quantedge_ta::{Ohlcv, Price, Timestamp};
///
/// struct MyKline {
/// o: f64, h: f64, l: f64, c: f64,
/// ts: u64,
/// }
///
/// impl Ohlcv for MyKline {
/// fn open(&self) -> Price { self.o }
/// fn high(&self) -> Price { self.h }
/// fn low(&self) -> Price { self.l }
/// fn close(&self) -> Price { self.c }
/// fn open_time(&self) -> Timestamp { self.ts }
/// }
/// ```