apple-quant-algorithmic 0.4.0

Apple Quant's algorithmic library.
Documentation
mod id;
mod update;

use thiserror::Error;

use crate::order_manager::OrdersCapacitySpec;

use crate::{
	instrument::InstrumentSpec, order::RemoteOrder,
	order_manager::CancelRemoteOrderError, timestamp::Timestamp,
	volume::DirectionlessVolume,
};

use super::MarketDataDecoderProvider;

pub use id::*;
pub use update::*;

#[derive(Debug, Error)]
pub enum OrdersBackendSubmitRemoteOrderError {}

pub trait OrdersBackend<IS: InstrumentSpec> {
	fn new<
		OrdersCS: OrdersCapacitySpec,
		MDDP: MarketDataDecoderProvider<IS>,
	>(
		market_data_decoder: Option<MDDP::MarketDataDecoder>,
	) -> impl Future<Output = (
		thingbuf::mpsc::Receiver<OrdersBackendUpdate<IS>, OrdersBackendUpdateRecycle>,
		Self,
	)>
	where
		Self: Sized;

	fn submit_order(
		&mut self,
		local_order_id: &LocalOrderId,
		client_submission_timestamp: &Timestamp,
		remote_order: RemoteOrder<IS>,
	) -> impl Future<Output = Result<(), OrdersBackendSubmitRemoteOrderError>>;

	fn modify_order_volume(
		&mut self,
		remote_order_id: &RemoteOrderId,
		volume: &DirectionlessVolume<IS>,
	) -> impl Future<Output = ()>;

	fn initiate_cancel_order(
		&mut self,
		remote_order_id: &RemoteOrderId,
	) -> impl Future<Output = Result<(), CancelRemoteOrderError>>;

	fn initiate_cancel_all(
		&mut self,
	) -> impl Future<Output = ()>;

	fn initiate_cancel_flatten_all(
		&mut self,
	) -> impl Future<Output = ()>;
}