pub struct TradeSyncer { /* private fields */ }Expand description
Trade syncer - handles syncing fills to upstream API
Implementations§
Source§impl TradeSyncer
impl TradeSyncer
Sourcepub fn new(config: TradeSyncerConfig) -> Result<Self, SyncError>
pub fn new(config: TradeSyncerConfig) -> Result<Self, SyncError>
Create a new trade syncer with the given configuration
Sourcepub fn add_fill(&mut self, fill: Fill)
pub fn add_fill(&mut self, fill: Fill)
Add a fill to the pending queue (will be synced on next sync call)
Sourcepub fn should_sync(&self) -> bool
pub fn should_sync(&self) -> bool
Check if it’s time to sync (based on interval)
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get the number of pending fills
Sourcepub fn set_metrics_snapshot(
&mut self,
snapshot: Option<PerformanceMetricsSnapshot>,
)
pub fn set_metrics_snapshot( &mut self, snapshot: Option<PerformanceMetricsSnapshot>, )
Set the latest performance metrics snapshot for sync metadata.
Sourcepub async fn sync(
&mut self,
current_price: Option<Decimal>,
stop_bot: bool,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn sync( &mut self, current_price: Option<Decimal>, stop_bot: bool, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Sync pending fills to upstream API
Returns the PnL from the upstream API on success
Sourcepub async fn shutdown_sync(
&mut self,
current_price: Option<Decimal>,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn shutdown_sync( &mut self, current_price: Option<Decimal>, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Perform final sync on shutdown (with stop_bot=true)
Trait Implementations§
Source§impl TradeSync for TradeSyncer
impl TradeSync for TradeSyncer
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 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.
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
Auto Trait Implementations§
impl !RefUnwindSafe for TradeSyncer
impl !UnwindSafe for TradeSyncer
impl Freeze for TradeSyncer
impl Send for TradeSyncer
impl Sync for TradeSyncer
impl Unpin for TradeSyncer
impl UnsafeUnpin for TradeSyncer
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