use rust_decimal::Decimal;
use crate::{
instrument::InstrumentSpec,
price::AbsolutePrice,
timestamp::{TradeTimestampRange, TradeTimestampedRange},
};
#[derive(Debug)]
pub struct RuntimeOHLC {
pub open: Decimal,
pub high: Decimal,
pub low: Decimal,
pub close: Decimal,
}
#[derive(Debug)]
pub struct OHLC<const NS_LEN: u64, IS: InstrumentSpec> {
pub open: AbsolutePrice<IS>,
pub high: AbsolutePrice<IS>,
pub low: AbsolutePrice<IS>,
pub close: AbsolutePrice<IS>,
}
impl<const NS_LEN: u64, IS: InstrumentSpec> OHLC<NS_LEN, IS> {
pub fn as_runtime(&self) -> RuntimeOHLC {
RuntimeOHLC {
open: self.open.as_decimal(),
high: self.high.as_decimal(),
low: self.low.as_decimal(),
close: self.close.as_decimal(),
}
}
}
#[derive(Debug)]
pub struct OHLCTradeTimestampRange<const NS_LEN: u64, IS: InstrumentSpec> {
pub ohlc: OHLC<NS_LEN, IS>,
pub trade_timestamp_range: TradeTimestampRange,
}
impl<const NS_LEN: u64, IS: InstrumentSpec> TradeTimestampedRange
for OHLCTradeTimestampRange<NS_LEN, IS>
{
fn trade_timestamp_range(&self) -> &TradeTimestampRange {
&self.trade_timestamp_range
}
}