use std::fmt;
use super::{order_lifespan::OrderTimeInForce, order_side::OrderSide, order_type::OrderType};
use time::OffsetDateTime;
#[allow(clippy::module_name_repetitions)]
pub type OrderID = u64;
#[derive(Debug, Clone, Copy)]
pub struct Order {
pub id: OrderID,
pub symbol_id: u32,
pub order_type: OrderType,
pub order_side: OrderSide,
pub price: f64,
pub stop_price: f64,
pub quantity: u64,
pub executed_quantity: u64,
pub leaves_quantity: u64,
pub time_in_force: OrderTimeInForce,
pub timestamp: OffsetDateTime,
}
impl fmt::Display for Order {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Order(id={}, symbol_id={}, order_type={}, order_side={}, price={}, stop_price={}, quantity={}, executed_quantity={}, leaves_quantity={}, time_in_force={}, timestamp={})",
self.id,
self.symbol_id,
self.order_type,
self.order_side,
self.price,
self.stop_price,
self.quantity,
self.executed_quantity,
self.leaves_quantity,
self.time_in_force,
self.timestamp
)
}
}
impl Order {
pub fn validate(&self) {
todo!()
}
#[must_use]
pub fn id(&self) -> u64 {
self.id
}
#[must_use]
pub fn symbol_id(&self) -> u32 {
self.symbol_id
}
#[must_use]
pub fn order_type(&self) -> &OrderType {
&self.order_type
}
#[must_use]
pub fn order_side(&self) -> &OrderSide {
&self.order_side
}
#[must_use]
pub fn price(&self) -> f64 {
self.price
}
#[must_use]
pub fn stop_price(&self) -> f64 {
self.stop_price
}
#[must_use]
pub fn quantity(&self) -> u64 {
self.quantity
}
#[must_use]
pub fn executed_quantity(&self) -> u64 {
self.executed_quantity
}
#[must_use]
pub fn leaves_quantity(&self) -> u64 {
self.leaves_quantity
}
#[must_use]
pub fn time_in_force(&self) -> &OrderTimeInForce {
&self.time_in_force
}
#[must_use]
pub fn timestamp(&self) -> OffsetDateTime {
self.timestamp
}
}