Skip to main content

PortExecutionService

Struct PortExecutionService 

Source
pub struct PortExecutionService<'a, V: VenuePort, P: ExecutionEventPort> { /* private fields */ }
Expand description

完全基于 Application Ports 的单腿执行器。

这是回测、Paper、CCXT 及未来券商适配器共用的最小副作用边界:订单先 注册到 OrderStore,再调用 VenuePort,最后把标准执行事实写入 ExecutionEventPort。它不依赖 LiveEventPipeline 或 Venue,便于在 不同运行时、进程和语言绑定中复用同一套未知结果保护。

Implementations§

Source§

impl<'a, V: VenuePort, P: ExecutionEventPort> PortExecutionService<'a, V, P>

Source

pub fn new( venue: &'a mut V, events: &'a mut P, worker_id: &'a str, now: u64, source_seq: &'a mut u64, ) -> Self

Source

pub fn with_spread_group_store( self, store: &'a dyn SpreadOrderGroupStore, ) -> Self

绑定多腿订单组快照存储:只有注入组存储的提交路径才可能提交带 spread_group_id 的腿,其余路径对这类命令一律 fail-closed(见 spread_group_barrier)。屏障判定住在网关而不是 CLI,是为了让任何 绕过 CLI 的调用方(回测、语言绑定、未来执行器)也无法跳过它。

Source

pub fn with_order_group_store(self, store: &'a mut dyn OrderGroupStore) -> Self

Source

pub fn with_instrument_spec(self, spec: TradingInstrumentSpec) -> Self

Source

pub fn submit_command( &mut self, command: &ControlCommand, ) -> Result<PortExecutionResult, String>

统一的控制命令提交入口。命令解析、订单校验、风险(如调用方继续使用 submit_with_risk)和 Venue 副作用均在同一个端口化服务中完成。

Source

pub fn submit_command_with_risk<R: RiskPort>( &mut self, command: &ControlCommand, risk: &R, ) -> Result<PortExecutionResult, String>

Source

pub fn submit(&mut self, order: Order) -> Result<PortExecutionResult, String>

Source

pub fn submit_with_risk<R: RiskPort>( &mut self, order: Order, risk: &R, ) -> Result<PortExecutionResult, String>

风控前置的统一提交入口。RiskPort 拒绝发生在订单登记、Venue 副作用和 EventLog 事实追加之前;因此拒单不会留下“已提交但未执行”的伪订单。两条通道 不混用(V13 §9.12 #172):端口给出拒绝才播报「拒绝订单」并带违规清单,端口 给不出裁决才播报「执行失败」。

Source

pub fn submit_order_group<R: RiskPort>( &mut self, intent: OrderGroupIntent, risk: &R, ) -> Result<PortExecutionResult, String>

Submit an OCO/Bracket exactly once through the shared execution boundary. Each leg intent is registered before the single native group RPC; any ambiguous outcome fences the group for reconciliation and is never retried.

Source

pub fn validate_order(&self, order: &Order) -> Result<(), String>

Fail closed on frozen market-spec identity, lot size, minimum quantity, and price tick before risk registration or any venue side effect.

Source

pub fn submit_with_risk_and_correlation<R: RiskPort>( &mut self, order: Order, risk: &R, correlation_id: impl Into<String>, ) -> Result<PortExecutionResult, String>

Submit with a stable caller correlation id. Algorithm children use parent_id/child_index so an event-log replay can identify the same child after restart without inventing a second execution path.

Source

pub fn order(&self, client_order_id: u64) -> Option<Order>

Read the authoritative OMS snapshot for a client order id.

Source

pub fn cancel( &mut self, client_order_id: u64, ) -> Result<PortExecutionResult, String>

Source

pub fn cancel_command( &mut self, command: &ControlCommand, ) -> Result<PortExecutionResult, String>

Apply an audited CancelOrder command only after binding its declared routing scope to the authoritative OMS order. The venue never receives an account or instrument supplied only by the caller.

Source

pub fn amend_command( &mut self, command: &ControlCommand, ) -> Result<PortExecutionResult, String>

Apply a durable control-plane amendment. The adapter is preflighted before the pending fact is written; after that fact exists a retry is forbidden until a reconciler proves the exchange result.

Auto Trait Implementations§

§

impl<'a, V, P> !RefUnwindSafe for PortExecutionService<'a, V, P>

§

impl<'a, V, P> !Send for PortExecutionService<'a, V, P>

§

impl<'a, V, P> !Sync for PortExecutionService<'a, V, P>

§

impl<'a, V, P> !UnwindSafe for PortExecutionService<'a, V, P>

§

impl<'a, V, P> Forget for PortExecutionService<'a, V, P>

§

impl<'a, V, P> Freeze for PortExecutionService<'a, V, P>

§

impl<'a, V, P> Move for PortExecutionService<'a, V, P>

§

impl<'a, V, P> Unpin for PortExecutionService<'a, V, P>

§

impl<'a, V, P> UnsafeUnpin for PortExecutionService<'a, V, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.