use indexmap::IndexMap;
use nautilus_model::{
enums::OrderSide,
identifiers::VenueOrderId,
reports::{FillReport, OrderStatusReport},
};
use rust_decimal::Decimal;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FillSnapshot {
pub ts_event: u64,
pub side: OrderSide,
pub qty: Decimal,
pub px: Decimal,
pub venue_order_id: VenueOrderId,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct VenuePositionSnapshot {
pub side: OrderSide, pub qty: Decimal,
pub avg_px: Decimal,
}
#[derive(Debug, Clone, PartialEq)]
pub enum FillAdjustmentResult {
NoAdjustment,
AddSyntheticOpening {
synthetic_fill: FillSnapshot,
existing_fills: Vec<FillSnapshot>,
},
ReplaceCurrentLifecycle {
synthetic_fill: FillSnapshot,
first_venue_order_id: VenueOrderId,
},
FilterToCurrentLifecycle {
last_zero_crossing_ts: u64,
current_lifecycle_fills: Vec<FillSnapshot>,
},
}
impl FillSnapshot {
#[must_use]
pub fn new(
ts_event: u64,
side: OrderSide,
qty: Decimal,
px: Decimal,
venue_order_id: VenueOrderId,
) -> Self {
Self {
ts_event,
side,
qty,
px,
venue_order_id,
}
}
#[must_use]
pub fn direction(&self) -> i8 {
match self.side {
OrderSide::Buy => 1,
OrderSide::Sell => -1,
_ => 0,
}
}
}
#[derive(Debug, Clone)]
pub struct ReconciliationResult {
pub orders: IndexMap<VenueOrderId, OrderStatusReport>,
pub fills: IndexMap<VenueOrderId, Vec<FillReport>>,
}