pub struct ClosePositionRequest {
pub deal_id: Option<String>,
pub direction: Direction,
pub epic: Option<String>,
pub expiry: Option<String>,
pub level: Option<f64>,
pub order_type: OrderType,
pub quote_id: Option<String>,
pub size: f64,
pub time_in_force: TimeInForce,
}Expand description
Model for closing an existing position
Fields§
§deal_id: Option<String>Unique identifier for the position to close
direction: DirectionDirection of the closing order (opposite to the position)
epic: Option<String>Instrument EPIC identifier
expiry: Option<String>Expiry date for the order
level: Option<f64>Price level for limit close orders
order_type: OrderTypeType of order to use for closing
quote_id: Option<String>Quote identifier for the order, used for certain order types that require a specific quote
size: f64Size/quantity to close
time_in_force: TimeInForceOrder duration for the closing order
Implementations§
Source§impl ClosePositionRequest
impl ClosePositionRequest
Sourcepub fn market(deal_id: String, direction: Direction, size: f64) -> Self
pub fn market(deal_id: String, direction: Direction, size: f64) -> Self
Creates a request to close a position at market price
Sourcepub fn limit(
deal_id: String,
direction: Direction,
size: f64,
level: f64,
) -> Self
pub fn limit( deal_id: String, direction: Direction, size: f64, level: f64, ) -> Self
Creates a request to close a position at a specific price level
This is useful for instruments that don’t support market orders
Sourcepub fn close_option_to_market_by_id(
deal_id: String,
direction: Direction,
size: f64,
) -> Self
pub fn close_option_to_market_by_id( deal_id: String, direction: Direction, size: f64, ) -> Self
Creates a request to close an option position by deal ID using a limit order with predefined price levels
This is specifically designed for options trading where market orders are not supported and a limit order with a predefined price level is required based on the direction.
§Arguments
deal_id- The ID of the deal to closedirection- The direction of the closing order (opposite of the position direction)size- The size of the position to close
Sourcepub fn close_option_to_market_by_epic(
epic: String,
expiry: String,
direction: Direction,
size: f64,
) -> Self
pub fn close_option_to_market_by_epic( epic: String, expiry: String, direction: Direction, size: f64, ) -> Self
Creates a request to close an option position by epic identifier using a limit order with predefined price levels
This is specifically designed for options trading where market orders are not supported and a limit order with a predefined price level is required based on the direction. This method is used when the deal ID is not available but the epic and expiry are known.
§Arguments
epic- The epic identifier of the instrumentexpiry- The expiry date of the optiondirection- The direction of the closing order (opposite of the position direction)size- The size of the position to close
Trait Implementations§
Source§impl Clone for ClosePositionRequest
impl Clone for ClosePositionRequest
Source§fn clone(&self) -> ClosePositionRequest
fn clone(&self) -> ClosePositionRequest
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClosePositionRequest
impl Debug for ClosePositionRequest
Source§impl<'de> Deserialize<'de> for ClosePositionRequest
impl<'de> Deserialize<'de> for ClosePositionRequest
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>,
Source§impl Display for ClosePositionRequest
impl Display for ClosePositionRequest
Auto Trait Implementations§
impl Freeze for ClosePositionRequest
impl RefUnwindSafe for ClosePositionRequest
impl Send for ClosePositionRequest
impl Sync for ClosePositionRequest
impl Unpin for ClosePositionRequest
impl UnwindSafe for ClosePositionRequest
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.