pub struct Trade {Show 13 fields
pub id: Option<String>,
pub order: Option<String>,
pub symbol: Symbol,
pub trade_type: Option<OrderType>,
pub side: OrderSide,
pub taker_or_maker: Option<TakerOrMaker>,
pub price: Price,
pub amount: Amount,
pub cost: Option<Cost>,
pub fee: Option<Fee>,
pub timestamp: Timestamp,
pub datetime: Option<String>,
pub info: HashMap<String, Value>,
}Expand description
Trade data structure
Fields§
§id: Option<String>Trade ID
order: Option<String>Order ID that this trade belongs to
symbol: SymbolExchange symbol
trade_type: Option<OrderType>Trade type (limit, market, etc.)
side: OrderSideTrade side (buy or sell)
taker_or_maker: Option<TakerOrMaker>Whether this is a maker or taker trade
price: PriceTrade price
amount: AmountTrade amount
cost: Option<Cost>Trade cost (price * amount)
fee: Option<Fee>Trade fee
timestamp: TimestampTimestamp in milliseconds
datetime: Option<String>ISO8601 datetime string
info: HashMap<String, Value>Raw exchange info
Implementations§
Source§impl Trade
impl Trade
Sourcepub fn new(
symbol: Symbol,
side: OrderSide,
price: Price,
amount: Amount,
timestamp: Timestamp,
) -> Self
pub fn new( symbol: Symbol, side: OrderSide, price: Price, amount: Amount, timestamp: Timestamp, ) -> Self
Creates a new trade with required fields.
§Arguments
symbol- Trading pair symbolside- Trade side (buy or sell)price- Trade execution priceamount- Trade amounttimestamp- Trade timestamp in milliseconds
Sourcepub fn calculate_cost(&mut self)
pub fn calculate_cost(&mut self)
Calculates and sets cost if not already set.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Trade
impl<'de> Deserialize<'de> for Trade
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Trade
impl RefUnwindSafe for Trade
impl Send for Trade
impl Sync for Trade
impl Unpin for Trade
impl UnwindSafe for Trade
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more