pub struct MockTradeSyncer { /* private fields */ }Expand description
Mock trade syncer for fill-based strategies.
Implementations§
Source§impl MockTradeSyncer
impl MockTradeSyncer
Sourcepub async fn set_should_fail(&self, should_fail: bool)
pub async fn set_should_fail(&self, should_fail: bool)
Configure whether sync calls should fail.
Sourcepub async fn set_simulated_pnl(&self, pnl: f64)
pub async fn set_simulated_pnl(&self, pnl: f64)
Set the PnL returned by successful sync calls.
Sourcepub async fn sync_calls(&self) -> Vec<TradeSyncCall>
pub async fn sync_calls(&self) -> Vec<TradeSyncCall>
Return all recorded trade sync calls.
Sourcepub async fn total_fills_synced(&self) -> usize
pub async fn total_fills_synced(&self) -> usize
Count fills across all recorded trade sync calls.
Sourcepub async fn assert_all_fills_synced(&self, expected_fills: &[Fill])
pub async fn assert_all_fills_synced(&self, expected_fills: &[Fill])
Assert that the expected number of fills was synced.
Trait Implementations§
Source§impl Default for MockTradeSyncer
impl Default for MockTradeSyncer
Source§impl TradeSync for MockTradeSyncer
impl TradeSync for MockTradeSyncer
Source§fn should_sync(&self) -> bool
fn should_sync(&self) -> bool
Check if it’s time to sync based on interval
Source§fn pending_count(&self) -> usize
fn pending_count(&self) -> usize
Get count of pending fills
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,
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,
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
Source§fn 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.
Auto Trait Implementations§
impl !RefUnwindSafe for MockTradeSyncer
impl !UnwindSafe for MockTradeSyncer
impl Freeze for MockTradeSyncer
impl Send for MockTradeSyncer
impl Sync for MockTradeSyncer
impl Unpin for MockTradeSyncer
impl UnsafeUnpin for MockTradeSyncer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more