pub struct Position { /* private fields */ }
Expand description
Describes the position information of the account
Implementations
sourceimpl Position
impl Position
sourcepub fn new_init(leverage: f64) -> Self
pub fn new_init(leverage: f64) -> Self
Create a new, initially neutral, position with a given leverage
Panics
In debug mode, if leverage is smaller than 1.0
sourcepub fn new(size: f64, entry_price: f64, leverage: f64, unrealized_pnl: f64) -> Self
pub fn new(size: f64, entry_price: f64, leverage: f64, unrealized_pnl: f64) -> Self
Create a new position with all fields custom. NOTE: not usually called, but for advanced use cases
Panics
In debug mode, if inputs don’t make sense
sourcepub fn size(&self) -> f64
pub fn size(&self) -> f64
Return the position size denoted in BASE currency if using linear futures, denoted in QUOTE currency if using inverse futures
sourcepub fn entry_price(&self) -> f64
pub fn entry_price(&self) -> f64
Return the entry price of the position
sourcepub fn unrealized_pnl(&self) -> f64
pub fn unrealized_pnl(&self) -> f64
Return the positions unrealized profit and loss denoted in QUOTE when using linear futures, denoted in BASE when using inverse futures
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Position
impl<'de> Deserialize<'de> for Position
sourcefn 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
impl Copy for Position
Auto Trait Implementations
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more