Skip to main content

apple_quant_algorithmic/order/
tracker.rs

1use crate::{backend::LocalOrderId, instrument::InstrumentSpec};
2
3use super::OrderGoal;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6pub struct ClientOrderTracker(LocalOrderId);
7
8impl ClientOrderTracker {
9	pub(crate) fn new(local_order_id: LocalOrderId) -> Self {
10		Self(local_order_id)
11	}
12
13	pub fn as_local_order_id(&self) -> &LocalOrderId {
14		&self.0
15	}
16
17	pub fn into_local_order_id(self) -> LocalOrderId {
18		self.0
19	}
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
23pub struct RemoteOrderTracker<IS: InstrumentSpec>(OrderGoal<IS>);
24
25impl<IS: InstrumentSpec> RemoteOrderTracker<IS> {
26	pub(crate) fn new(order_goal: OrderGoal<IS>) -> Self {
27		Self(order_goal)
28	}
29
30	pub fn as_order_goal(&self) -> &OrderGoal<IS> {
31		&self.0
32	}
33
34	pub fn into_order_goal(self) -> OrderGoal<IS> {
35		self.0
36	}
37
38	pub fn as_local_order_id(&self) -> &LocalOrderId {
39		self.0
40			.as_local_order_id()
41			.unwrap()
42	}
43
44	pub fn into_local_order_id(self) -> LocalOrderId {
45		*self
46			.0
47			.as_local_order_id()
48			.unwrap()
49	}
50}