use rust_decimal::Decimal;
use crate::{
timestamp::{TradeTimestampRangeIncluded, TradeTimestampRangeInclusive},
instrument::InstrumentSpec, price::AbsolutePrice,
};
#[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: TradeTimestampRangeInclusive,
}
impl<
const NS_LEN: u64,
IS: InstrumentSpec,
> TradeTimestampRangeIncluded for OHLCTradeTimestampRange<NS_LEN, IS> {
fn trade_timestamp_range_inclusive(
&self,
) -> TradeTimestampRangeInclusive {
self.trade_timestamp_range
}
}