longport_candlesticks/
candlestick.rs1use time::OffsetDateTime;
2
3use crate::TradeSessionType;
4
5#[derive(Debug)]
6pub struct CandlestickComponents<PriceType, VolumeType, TurnoverType, TradeSessionType> {
7 pub time: OffsetDateTime,
8 pub open: PriceType,
9 pub high: PriceType,
10 pub low: PriceType,
11 pub close: PriceType,
12 pub volume: VolumeType,
13 pub turnover: TurnoverType,
14 pub trade_session: TradeSessionType,
15 pub open_updated: bool,
16}
17
18pub trait CandlestickType {
19 type PriceType;
20 type VolumeType;
21 type TurnoverType;
22 type TradeSessionType: TradeSessionType;
23
24 fn new(
25 components: CandlestickComponents<
26 Self::PriceType,
27 Self::VolumeType,
28 Self::TurnoverType,
29 Self::TradeSessionType,
30 >,
31 ) -> Self;
32
33 fn time(&self) -> OffsetDateTime;
34 fn set_time(&mut self, time: OffsetDateTime);
35
36 fn open(&self) -> Self::PriceType;
37 fn set_open(&mut self, open: Self::PriceType);
38
39 fn high(&self) -> Self::PriceType;
40 fn set_high(&mut self, high: Self::PriceType);
41
42 fn low(&self) -> Self::PriceType;
43 fn set_low(&mut self, low: Self::PriceType);
44
45 fn close(&self) -> Self::PriceType;
46 fn set_close(&mut self, close: Self::PriceType);
47
48 fn volume(&self) -> Self::VolumeType;
49 fn set_volume(&mut self, volume: Self::VolumeType);
50
51 fn turnover(&self) -> Self::TurnoverType;
52 fn set_turnover(&mut self, turnover: Self::TurnoverType);
53
54 fn trade_session(&self) -> Self::TradeSessionType;
55
56 fn set_open_updated(&mut self, open_updated: bool);
57 fn open_updated(&self) -> bool;
58}