pub struct Trade {Show 13 fields
pub id: Option<String>,
pub order: Option<String>,
pub symbol: String,
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: i64,
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: StringExchange 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: i64Timestamp 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: String,
side: OrderSide,
price: Price,
amount: Amount,
timestamp: i64,
) -> Trade
pub fn new( symbol: String, side: OrderSide, price: Price, amount: Amount, timestamp: i64, ) -> Trade
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<Trade, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Trade, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Trade
impl Serialize for Trade
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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