barter_execution/model/
trade.rsuse super::order::OrderId;
use barter_integration::model::{
instrument::{symbol::Symbol, Instrument},
Side,
};
use serde::{Deserialize, Serialize};
#[derive(Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)]
pub struct Trade {
pub id: TradeId,
pub order_id: OrderId,
pub instrument: Instrument,
pub side: Side,
pub price: f64,
pub quantity: f64,
pub fees: SymbolFees,
}
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)]
pub struct TradeId(pub String);
impl<S> From<S> for TradeId
where
S: Into<String>,
{
fn from(id: S) -> Self {
Self(id.into())
}
}
#[derive(Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)]
pub struct SymbolFees {
pub symbol: Symbol,
pub fees: f64,
}
impl SymbolFees {
pub fn new<S>(symbol: S, fees: f64) -> Self
where
S: Into<Symbol>,
{
Self {
symbol: symbol.into(),
fees,
}
}
}