apple-quant-algorithmic 0.3.0

Apple Quant's algorithmic library.
use crate::{
	instrument::InstrumentSpec, order::PartialOrderFill, price::AbsolutePrice,
	volume::DirectionlessVolume,
};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ImbalancedFill<IS: InstrumentSpec> {
	pub(crate) price: AbsolutePrice<IS>,
	pub(crate) volume: DirectionlessVolume<IS>,
}

impl<IS: InstrumentSpec> ImbalancedFill<IS> {
	pub fn new(
		price: AbsolutePrice<IS>,
		volume: DirectionlessVolume<IS>,
	) -> Self {
		Self { price, volume }
	}

	pub fn from_partial_order_fill(
		partial_order_fill: &PartialOrderFill<IS>,
	) -> Self {
		let PartialOrderFill {
			price,
			directional_intent_volume,
			timestamp: _,
		} = partial_order_fill;

		Self {
			price: *price,
			volume: directional_intent_volume.directionless_volume,
		}
	}

	pub fn price(
		&self,
	) -> &AbsolutePrice<IS> {
		&self.price
	}

	pub fn volume(
		&self,
	) -> &DirectionlessVolume<IS> {
		&self.volume
	}
}