Skip to main content

apple_quant_algorithmic/backend/
orders.rs

1use thiserror::Error;
2use tokio::sync::mpsc;
3
4use crate::{
5	instrument::InstrumentSpec,
6	order::{OrderStateUpdate, RemoteOrder},
7	order_manager::CancelRemoteOrderError,
8	timestamp::Timestamp,
9	volume::DirectionlessVolume,
10};
11
12use super::MarketDataStream;
13
14mod id;
15pub use id::*;
16
17#[derive(Debug, Error)]
18pub enum OrdersBackendSubmitRemoteOrderError {}
19
20pub trait OrdersBackend<IS: InstrumentSpec + Send>: MarketDataStream<IS> {
21	fn new() -> impl Future<
22		Output = (
23			mpsc::Receiver<OrderStateUpdate<IS>>,
24			Self,
25		),
26	>;
27
28	fn submit_order(
29		&mut self,
30		local_order_id: &LocalOrderId,
31		client_submission_timestamp: &Timestamp,
32		remote_order: RemoteOrder<IS>,
33	) -> impl Future<Output = Result<(), OrdersBackendSubmitRemoteOrderError>>;
34
35	fn modify_order_volume(
36		&mut self,
37		remote_order_id: &RemoteOrderId,
38		volume: &DirectionlessVolume<IS>,
39	) -> impl Future<Output = ()>;
40
41	fn initiate_cancel_order(
42		&mut self,
43		remote_order_id: &RemoteOrderId,
44	) -> impl Future<Output = Result<(), CancelRemoteOrderError>>;
45
46	fn initiate_cancel_all(&mut self) -> impl Future<Output = ()>;
47
48	fn initiate_cancel_flatten_all(&mut self) -> impl Future<Output = ()>;
49}