apple_quant_algorithmic/aggregation/
ohlc.rs1use rust_decimal::Decimal;
2
3use crate::{
4 instrument::InstrumentSpec,
5 price::AbsolutePrice,
6 timestamp::{TradeTimestampRange, TradeTimestampedRange},
7};
8
9#[derive(Debug)]
11pub struct RuntimeOHLC {
12 pub open: Decimal,
13 pub high: Decimal,
14 pub low: Decimal,
15 pub close: Decimal,
16}
17
18#[derive(Debug)]
20pub struct OHLC<const NS_LEN: u64, IS: InstrumentSpec> {
21 pub open: AbsolutePrice<IS>,
22 pub high: AbsolutePrice<IS>,
23 pub low: AbsolutePrice<IS>,
24 pub close: AbsolutePrice<IS>,
25}
26
27impl<const NS_LEN: u64, IS: InstrumentSpec> OHLC<NS_LEN, IS> {
28 pub fn as_runtime(&self) -> RuntimeOHLC {
29 RuntimeOHLC {
30 open: self.open.as_decimal(),
31 high: self.high.as_decimal(),
32 low: self.low.as_decimal(),
33 close: self.close.as_decimal(),
34 }
35 }
36}
37
38#[derive(Debug)]
40pub struct OHLCTradeTimestampRange<const NS_LEN: u64, IS: InstrumentSpec> {
41 pub ohlc: OHLC<NS_LEN, IS>,
42 pub trade_timestamp_range: TradeTimestampRange,
43}
44
45impl<const NS_LEN: u64, IS: InstrumentSpec> TradeTimestampedRange
46 for OHLCTradeTimestampRange<NS_LEN, IS>
47{
48 fn trade_timestamp_range(&self) -> &TradeTimestampRange {
49 &self.trade_timestamp_range
50 }
51}