Skip to main content

TradeSync

Trait TradeSync 

Source
pub trait TradeSync: Send + Sync {
    // Required methods
    fn add_fill(&mut self, fill: Fill);
    fn should_sync(&self) -> bool;
    fn pending_count(&self) -> usize;
    fn last_pnl(&self) -> Option<f64>;
    fn sync<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        current_price: Option<Decimal>,
        stop_bot: bool,
        stop_reason: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<TradeSyncResult, SyncError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn shutdown_sync<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        current_price: Option<Decimal>,
        stop_reason: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<TradeSyncResult, SyncError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn set_metrics_snapshot(
        &mut self,
        _snapshot: Option<PerformanceMetricsSnapshot>,
    ) { ... }
}
Expand description

Trait for trade-based syncing (Grid, MM strategies)

Syncers implementing this trait accept fills and sync them to upstream.

Required Methods§

Source

fn add_fill(&mut self, fill: Fill)

Add a fill to the pending queue

Source

fn should_sync(&self) -> bool

Check if it’s time to sync based on interval

Source

fn pending_count(&self) -> usize

Get count of pending fills

Source

fn last_pnl(&self) -> Option<f64>

Get last known PnL

Source

fn sync<'life0, 'life1, 'async_trait>( &'life0 mut self, current_price: Option<Decimal>, stop_bot: bool, stop_reason: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<TradeSyncResult, SyncError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sync pending fills to upstream

Source

fn shutdown_sync<'life0, 'life1, 'async_trait>( &'life0 mut self, current_price: Option<Decimal>, stop_reason: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<TradeSyncResult, SyncError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform final sync on shutdown

Provided Methods§

Source

fn set_metrics_snapshot( &mut self, _snapshot: Option<PerformanceMetricsSnapshot>, )

Set the latest performance metrics snapshot to include in sync metadata.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§