pub struct CreateWorkingOrderRequest {Show 15 fields
pub epic: String,
pub direction: Direction,
pub size: f64,
pub level: f64,
pub order_type: OrderType,
pub time_in_force: TimeInForce,
pub guaranteed_stop: Option<bool>,
pub stop_level: Option<f64>,
pub stop_distance: Option<f64>,
pub limit_level: Option<f64>,
pub limit_distance: Option<f64>,
pub good_till_date: Option<String>,
pub deal_reference: Option<String>,
pub currency_code: String,
pub expiry: String,
}Expand description
Model for creating a new working order
Fields§
§epic: StringInstrument EPIC identifier
direction: DirectionOrder direction (buy or sell)
size: f64Order size/quantity
level: f64Price level for the order
order_type: OrderTypeType of working order (LIMIT or STOP)
time_in_force: TimeInForceOrder duration (how long the order remains valid)
guaranteed_stop: Option<bool>Whether to use a guaranteed stop
stop_level: Option<f64>Price level for stop loss
stop_distance: Option<f64>Distance for stop loss
limit_level: Option<f64>Price level for take profit
limit_distance: Option<f64>Distance for take profit
good_till_date: Option<String>Expiry date for GTD orders
deal_reference: Option<String>Client-generated reference for the deal
currency_code: StringCurrency code for the order (e.g., “USD”, “EUR”)
expiry: StringExpiry date for the order
Implementations§
Source§impl CreateWorkingOrderRequest
impl CreateWorkingOrderRequest
Sourcepub fn limit(
epic: String,
direction: Direction,
size: f64,
level: f64,
currency_code: String,
expiry: String,
) -> Self
pub fn limit( epic: String, direction: Direction, size: f64, level: f64, currency_code: String, expiry: String, ) -> Self
Creates a new limit working order
Sourcepub fn stop(
epic: String,
direction: Direction,
size: f64,
level: f64,
currency_code: String,
expiry: String,
) -> Self
pub fn stop( epic: String, direction: Direction, size: f64, level: f64, currency_code: String, expiry: String, ) -> Self
Creates a new stop working order
Sourcepub fn with_stop_loss(self, stop_level: f64) -> Self
pub fn with_stop_loss(self, stop_level: f64) -> Self
Adds a stop loss to the working order
Sourcepub fn with_take_profit(self, limit_level: f64) -> Self
pub fn with_take_profit(self, limit_level: f64) -> Self
Adds a take profit to the working order
Sourcepub fn with_reference(self, reference: String) -> Self
pub fn with_reference(self, reference: String) -> Self
Adds a reference to the working order
Sourcepub fn expires_at(self, date: String) -> Self
pub fn expires_at(self, date: String) -> Self
Sets the expiration date for an order and updates the time-in-force policy.
This method updates the time_in_force property to GoodTillDate and assigns
the provided expiration date to the good_till_date property. It allows chaining
as it consumes the current instance and returns it after modification.
§Arguments
date- AStringrepresenting the expiration date for the order.
§Returns
Self- The updated instance of the type, allowing method chaining.
In the example above, the expiration date for the order is set to
“2023-12-31T23:59:59Z” and the time_in_force policy is set to GoodTillDate.
Sourcepub fn expires_tomorrow(self) -> Self
pub fn expires_tomorrow(self) -> Self
Sets the order to expire by the end of the next day (tomorrow).
This method modifies the time_in_force field to GoodTillDate and calculates
the expiration date as tomorrow’s date and time. The calculated date is then
formatted as a string in the format YYYY/MM/DD HH:MM:SS and assigned to
the good_till_date field.
§Returns
Returns the updated instance of the struct with the expiration date set to tomorrow.
In this example, the expires_tomorrow method sets the order to expire at the
same time on the next calendar day.
Note: The function uses the UTC timezone for calculating the date and time.
Sourcepub fn expires_in(self, duration: Duration) -> Self
pub fn expires_in(self, duration: Duration) -> Self
Sets the expiration time for an order and configures it to expire at a specific date and time.
This method modifies the time_in_force for the order to GoodTillDate
and calculates the expiration time by adding the provided duration to
the current UTC time. The calculated expiration time is formatted as
“YYYY/MM/DD HH:MM:SS” and stored in the good_till_date field.
§Parameters
duration: ADurationinstance that represents the amount of time after the current UTC time when the order should expire.
§Returns
Returns Self with updated time_in_force and good_till_date.
Note: This method assumes that the runtime uses the chrono crate for
time handling and formatting.
Trait Implementations§
Source§impl Clone for CreateWorkingOrderRequest
impl Clone for CreateWorkingOrderRequest
Source§fn clone(&self) -> CreateWorkingOrderRequest
fn clone(&self) -> CreateWorkingOrderRequest
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CreateWorkingOrderRequest
impl Debug for CreateWorkingOrderRequest
Source§impl Default for CreateWorkingOrderRequest
impl Default for CreateWorkingOrderRequest
Source§fn default() -> CreateWorkingOrderRequest
fn default() -> CreateWorkingOrderRequest
Source§impl<'de> Deserialize<'de> for CreateWorkingOrderRequest
impl<'de> Deserialize<'de> for CreateWorkingOrderRequest
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 CreateWorkingOrderRequest
impl Display for CreateWorkingOrderRequest
Source§impl From<WorkingOrder> for CreateWorkingOrderRequest
impl From<WorkingOrder> for CreateWorkingOrderRequest
Source§fn from(value: WorkingOrder) -> Self
fn from(value: WorkingOrder) -> Self
Auto Trait Implementations§
impl Freeze for CreateWorkingOrderRequest
impl RefUnwindSafe for CreateWorkingOrderRequest
impl Send for CreateWorkingOrderRequest
impl Sync for CreateWorkingOrderRequest
impl Unpin for CreateWorkingOrderRequest
impl UnwindSafe for CreateWorkingOrderRequest
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.