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§
Sourcefn should_sync(&self) -> bool
fn should_sync(&self) -> bool
Check if it’s time to sync based on interval
Sourcefn pending_count(&self) -> usize
fn pending_count(&self) -> usize
Get count of pending fills
Sourcefn 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 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
Sourcefn 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,
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§
Sourcefn set_metrics_snapshot(
&mut self,
_snapshot: Option<PerformanceMetricsSnapshot>,
)
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".