apple_quant_algorithmic/backend/
orders.rs1mod id;
2mod update;
3
4use thiserror::Error;
5
6use crate::order_manager::OrdersCapacitySpec;
7
8use crate::{
9 instrument::InstrumentSpec, order::RemoteOrder,
10 order_manager::CancelRemoteOrderError, timestamp::Timestamp,
11 volume::DirectionlessVolume,
12};
13
14use super::MarketDataDecoderProvider;
15
16pub use id::*;
17pub use update::*;
18
19#[derive(Debug, Error)]
20pub enum OrdersBackendSubmitRemoteOrderError {}
21
22pub trait OrdersBackend<IS: InstrumentSpec> {
23 fn new<
24 OrdersCS: OrdersCapacitySpec,
25 MDDP: MarketDataDecoderProvider<IS>,
26 >(
27 market_data_decoder: Option<MDDP::MarketDataDecoder>,
28 ) -> impl Future<Output = (
29 thingbuf::mpsc::Receiver<OrdersBackendUpdate<IS>, OrdersBackendUpdateRecycle>,
30 Self,
31 )>
32 where
33 Self: Sized;
34
35 fn submit_order(
36 &mut self,
37 local_order_id: &LocalOrderId,
38 client_submission_timestamp: &Timestamp,
39 remote_order: RemoteOrder<IS>,
40 ) -> impl Future<Output = Result<(), OrdersBackendSubmitRemoteOrderError>>;
41
42 fn modify_order_volume(
43 &mut self,
44 remote_order_id: &RemoteOrderId,
45 volume: &DirectionlessVolume<IS>,
46 ) -> impl Future<Output = ()>;
47
48 fn initiate_cancel_order(
49 &mut self,
50 remote_order_id: &RemoteOrderId,
51 ) -> impl Future<Output = Result<(), CancelRemoteOrderError>>;
52
53 fn initiate_cancel_all(
54 &mut self,
55 ) -> impl Future<Output = ()>;
56
57 fn initiate_cancel_flatten_all(
58 &mut self,
59 ) -> impl Future<Output = ()>;
60}