Skip to main content

apple_quant_algorithmic/volume/directional_exposure/
imbalanced_fill.rs

1use crate::{
2	instrument::InstrumentSpec, order::PartialOrderFill, price::AbsolutePrice,
3	volume::DirectionlessVolume,
4};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub struct ImbalancedFill<IS: InstrumentSpec> {
8	pub(crate) price: AbsolutePrice<IS>,
9	pub(crate) volume: DirectionlessVolume<IS>,
10}
11
12impl<IS: InstrumentSpec> ImbalancedFill<IS> {
13	pub fn new(
14		price: AbsolutePrice<IS>,
15		volume: DirectionlessVolume<IS>,
16	) -> Self {
17		Self { price, volume }
18	}
19
20	pub fn from_partial_order_fill(
21		partial_order_fill: &PartialOrderFill<IS>,
22	) -> Self {
23		let PartialOrderFill {
24			price,
25			directional_intent_volume,
26			timestamp: _,
27		} = partial_order_fill;
28
29		Self {
30			price: *price,
31			volume: directional_intent_volume.directionless_volume,
32		}
33	}
34
35	pub fn price(
36		&self,
37	) -> &AbsolutePrice<IS> {
38		&self.price
39	}
40
41	pub fn volume(
42		&self,
43	) -> &DirectionlessVolume<IS> {
44		&self.volume
45	}
46}