apple-quant-algorithmic 0.1.0

Apple Quant's algorithmic trading api
Documentation
use thiserror::Error;
use tokio::sync::mpsc;

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

use super::MarketDataStream;

mod id;
pub use id::*;

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

pub trait OrdersBackend<IS: InstrumentSpec + Send>: MarketDataStream<IS> {
	fn new() -> impl Future<
		Output = (
			mpsc::Receiver<OrderStateUpdate<IS>>,
			Self,
		),
	>;

	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 = ()>;
}