use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Deserialize,
Serialize,
Ord,
PartialOrd,
Hash,
)]
pub enum Order {
Buy,
Sell,
}
impl fmt::Display for Order {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let order_type = match self {
Self::Buy => "buy",
Self::Sell => "sell",
};
write!(f, "{}", order_type)
}
}
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Deserialize,
Serialize,
Ord,
PartialOrd,
Hash,
)]
pub enum OrderType {
Market,
Limit,
SettlePosition,
StopLoss,
StopLossLimit,
TakeProfit,
TakeProfitLimit,
}
impl fmt::Display for OrderType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let order_type = match self {
Self::Market => "market",
Self::Limit => "limit",
Self::SettlePosition => "settle-position",
Self::StopLoss => "stop-loss",
Self::TakeProfit => "take-profit",
Self::StopLossLimit => "stop-loss-limit",
Self::TakeProfitLimit => "take-profit-limit",
};
write!(f, "{}", order_type)
}
}