use bot_core::{AccountState, Fill};
use rust_decimal::Decimal;
use crate::account_syncer::SyncError;
use crate::performance_metrics::PerformanceMetricsSnapshot;
#[derive(Debug, Clone)]
pub struct TradeSyncResult {
pub success: bool,
pub pnl: Option<f64>,
}
#[async_trait::async_trait]
pub trait TradeSync: Send + Sync {
fn add_fill(&mut self, fill: Fill);
fn should_sync(&self) -> bool;
fn pending_count(&self) -> usize;
fn last_pnl(&self) -> Option<f64>;
fn set_metrics_snapshot(&mut self, _snapshot: Option<PerformanceMetricsSnapshot>) {}
async fn sync(
&mut self,
current_price: Option<Decimal>,
stop_bot: bool,
stop_reason: &str,
) -> Result<TradeSyncResult, SyncError>;
async fn shutdown_sync(
&mut self,
current_price: Option<Decimal>,
stop_reason: &str,
) -> Result<TradeSyncResult, SyncError>;
}
#[derive(Debug, Clone)]
pub struct AccountSyncResult {
pub success: bool,
pub pnl: Option<f64>,
}
#[async_trait::async_trait]
pub trait AccountSync: Send + Sync {
fn should_sync(&self) -> bool;
fn last_pnl(&self) -> Option<f64>;
fn set_metrics_snapshot(&mut self, _snapshot: Option<PerformanceMetricsSnapshot>) {}
async fn sync(
&mut self,
account_state: &AccountState,
stop_bot: bool,
stop_reason: &str,
) -> Result<AccountSyncResult, SyncError>;
async fn shutdown_sync(
&mut self,
account_state: &AccountState,
stop_reason: &str,
) -> Result<AccountSyncResult, SyncError>;
}