apple_quant_algorithmic/volume/
directional_exposure.rs1use crate::instrument::InstrumentSpec;
2
3use super::ZeroableDirectionalIntentVolume;
4
5#[derive(Debug)]
6pub struct DirectionalExposure<IS: InstrumentSpec> {
7 effective: ZeroableDirectionalIntentVolume<IS>,
9
10 armed: ZeroableDirectionalIntentVolume<IS>,
12}
13
14impl<IS: InstrumentSpec> DirectionalExposure<IS> {
15 pub fn effective(&self) -> &ZeroableDirectionalIntentVolume<IS> {
16 &self.effective
17 }
18
19 pub fn armed(&self) -> &ZeroableDirectionalIntentVolume<IS> {
20 &self.armed
21 }
22
23 pub fn combined(&self) -> ZeroableDirectionalIntentVolume<IS> {
24 self.effective + self.armed
25 }
26
27 pub(crate) fn change_armed_directional_exposure(
28 &mut self,
29 delta_directional_exposure: &ZeroableDirectionalIntentVolume<IS>,
30 ) {
31 self.armed += *delta_directional_exposure;
32 }
33
34 pub(crate) fn change_effective_directional_exposure(
35 &mut self,
36 delta_directional_exposure: &ZeroableDirectionalIntentVolume<IS>,
37 ) {
38 self.effective += *delta_directional_exposure;
39 }
40}
41
42impl<IS: InstrumentSpec> Default for DirectionalExposure<IS> {
43 fn default() -> Self {
44 Self {
45 armed: ZeroableDirectionalIntentVolume::ZERO,
46 effective: ZeroableDirectionalIntentVolume::ZERO,
47 }
48 }
49}