Struct debot_position_manager::TradePosition
source · pub struct TradePosition { /* private fields */ }Implementations§
source§impl TradePosition
impl TradePosition
pub fn new( id: u32, order_id: &str, ordered_price: f64, order_effective_duration: i64, token_name: &str, fund_name: &str, position_type: PositionType, predicted_price: f64, atr: Option<f64> ) -> Self
pub fn on_opened( &mut self, average_open_price: f64, amount: f64, amount_in_anchor_token: f64, fee: f64, take_profit_price: f64, cut_loss_price: f64 ) -> Result<(), ()>
pub fn request_close(&mut self, order_id: &str, reason: &str) -> Result<(), ()>
pub fn on_closed( &mut self, close_price: Option<f64>, fee: f64, do_liquidate: bool, liquidated_reason: Option<String> )
pub fn cancel(&mut self) -> bool
pub fn on_updated( &mut self, current_price: f64, average_open_price: f64, position_type: PositionType, take_profit_price: f64, cut_loss_price: f64, amount: f64, amount_in_anchor_token: f64, fee: f64 )
pub fn should_cancel_order(&self) -> bool
pub fn should_close(&self, close_price: f64) -> Option<ReasonForClose>
pub fn is_expired(&self, max_holding_duration: i64) -> Option<ReasonForClose>
pub fn total_pnl(&self, current_price: Option<f64>) -> Option<f64>
pub fn id(&self) -> Option<u32>
pub fn average_open_price(&self) -> f64
pub fn order_id(&self) -> &str
pub fn ordered_price(&self) -> f64
pub fn predicted_price(&self) -> f64
pub fn state(&self) -> State
pub fn token_name(&self) -> &str
pub fn fund_name(&self) -> &str
pub fn amount(&self) -> f64
pub fn position_type(&self) -> PositionType
pub fn cut_loss_price(&self) -> f64
pub fn amount_in_anchor_token(&self) -> f64
pub fn print_info(&self, current_price: f64)
Trait Implementations§
source§impl Clone for TradePosition
impl Clone for TradePosition
source§fn clone(&self) -> TradePosition
fn clone(&self) -> TradePosition
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for TradePosition
impl Debug for TradePosition
source§impl Default for TradePosition
impl Default for TradePosition
source§fn default() -> TradePosition
fn default() -> TradePosition
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for TradePosition
impl<'de> Deserialize<'de> for TradePosition
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 RefUnwindSafe for TradePosition
impl Send for TradePosition
impl Sync for TradePosition
impl Unpin for TradePosition
impl UnwindSafe for TradePosition
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