pub struct Trade { /* private fields */ }Expand description
A completed trade execution.
Implementations§
Source§impl Trade
impl Trade
Sourcepub fn new(
symbol: impl Into<String>,
exchange: impl Into<String>,
direction: OrderDirection,
quantity_lots: u32,
price: Money,
) -> Self
pub fn new( symbol: impl Into<String>, exchange: impl Into<String>, direction: OrderDirection, quantity_lots: u32, price: Money, ) -> Self
Creates a new trade.
Sourcepub fn buy(
symbol: impl Into<String>,
exchange: impl Into<String>,
quantity_lots: u32,
price: Money,
) -> Self
pub fn buy( symbol: impl Into<String>, exchange: impl Into<String>, quantity_lots: u32, price: Money, ) -> Self
Creates a buy trade.
Sourcepub fn sell(
symbol: impl Into<String>,
exchange: impl Into<String>,
quantity_lots: u32,
price: Money,
) -> Self
pub fn sell( symbol: impl Into<String>, exchange: impl Into<String>, quantity_lots: u32, price: Money, ) -> Self
Creates a sell trade.
Sourcepub fn with_order_id(self, order_id: impl Into<String>) -> Self
pub fn with_order_id(self, order_id: impl Into<String>) -> Self
Sets the order ID.
Sourcepub fn with_commission(self, commission: Money) -> Self
pub fn with_commission(self, commission: Money) -> Self
Sets the commission.
Sourcepub fn with_executed_at(self, executed_at: DateTime<Utc>) -> Self
pub fn with_executed_at(self, executed_at: DateTime<Utc>) -> Self
Sets the execution time.
Sourcepub fn direction(&self) -> OrderDirection
pub fn direction(&self) -> OrderDirection
Returns the trade direction.
Sourcepub fn quantity_lots(&self) -> u32
pub fn quantity_lots(&self) -> u32
Returns the quantity in lots.
Sourcepub fn commission(&self) -> Option<&Money>
pub fn commission(&self) -> Option<&Money>
Returns the commission if any.
Sourcepub fn executed_at(&self) -> DateTime<Utc>
pub fn executed_at(&self) -> DateTime<Utc>
Returns the execution time.
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 Forget for Trade
impl Freeze for Trade
impl Move for Trade
impl RefUnwindSafe for Trade
impl Send for Trade
impl Sync for Trade
impl Unpin for Trade
impl UnsafeUnpin 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