Struct ConditionalExpiry
pub struct ConditionalExpiry {
pub timestamp: u128,
pub trigger: bool,
}Expand description
Defines expiration behavior for conditional orders.
This struct specifies when a conditional order should expire and what action to take upon expiration. It provides fine-grained control over conditional order lifecycles, allowing orders to either trigger or cancel at a specific time.
§Fields
timestamp: Unix timestamp (milliseconds since epoch) when expiration occurstrigger: Determines action on expiry (true = trigger order, false = cancel order)
§Field Aliases
timestampcan be aliased as"expiry_timestamp"or"e"triggercan be aliased as"expiry_trigger"or"et"
§Behavior
§Trigger on Expiry (trigger: true)
When the timestamp is reached, the conditional order will be immediately triggered regardless of whether the price condition has been met. This is useful for:
- Time-based order execution
- Deadline-driven trading strategies
- Automatic order activation at specific times
§Cancel on Expiry (trigger: false)
When the timestamp is reached, the conditional order will be canceled and removed from the order book. This is useful for:
- Limiting order lifetime to prevent stale executions
- Time-based risk management
- Automatic cleanup of unused conditional orders
§Examples
§Create expiry that triggers the order
use types::api::submit_order::ConditionalExpiry;
// Trigger order at Unix timestamp 1747313713 (regardless of price condition)
let trigger_expiry = ConditionalExpiry {
timestamp: 1747313713,
trigger: true,
};
// Or using convenience constructor
let trigger_expiry = ConditionalExpiry::trigger_at(1747313713);§Create expiry that cancels the order
use types::api::submit_order::ConditionalExpiry;
// Cancel order at Unix timestamp 1747313713 if not yet triggered
let cancel_expiry = ConditionalExpiry {
timestamp: 1747313713,
trigger: false,
};
// Or using convenience constructor
let cancel_expiry = ConditionalExpiry::cancel_at(1747313713);§Using the builder pattern
use types::api::submit_order::ConditionalExpiry;
let expiry = ConditionalExpiry::builder()
.timestamp(1747313713)
.trigger_on_expiry()
.build()
.expect("Failed to build expiry");§JSON Examples
Trigger on expiry (full field names):
{
"expiry_timestamp": 1747313713,
"expiry_trigger": true
}Cancel on expiry (using aliases):
{
"e": 1747313713,
"et": false
}Fields§
§timestamp: u128Unix timestamp (milliseconds since epoch) when the expiration should occur.
When this timestamp is reached, the conditional order will either be
triggered or canceled based on the trigger field value.
§Format
- Must be a valid Unix timestamp in milliseconds
- Should be in the future relative to order submission time
- Precision is at the millisecond level
§Validation
- Must be a positive integer
- Should be greater than current time when order is submitted
- System may reject timestamps too far in the future
trigger: boolDetermines the action to take when the expiration timestamp is reached.
true: Trigger the conditional order immediately on expiryfalse: Cancel the conditional order on expiry
§Trigger on Expiry (true)
The order will be immediately executed as if the trigger condition was met, bypassing the original price condition. This is useful for:
- Deadline-based execution strategies
- Ensuring order execution by a specific time
- Market close or session-end orders
§Cancel on Expiry (false)
The order will be removed from the system without execution. This is useful for:
- Preventing stale order execution
- Limiting order exposure duration
- Time-based risk management
Implementations§
§impl ConditionalExpiry
impl ConditionalExpiry
pub fn builder() -> ConditionalExpiryBuilder
pub fn builder() -> ConditionalExpiryBuilder
Create a new ConditionalExpiryBuilder
pub fn trigger_at(timestamp: u128) -> ConditionalExpiry
pub fn trigger_at(timestamp: u128) -> ConditionalExpiry
Create a ConditionalExpiry that triggers on expiry
pub fn cancel_at(timestamp: u128) -> ConditionalExpiry
pub fn cancel_at(timestamp: u128) -> ConditionalExpiry
Create a ConditionalExpiry that cancels on expiry
Trait Implementations§
§impl Clone for ConditionalExpiry
impl Clone for ConditionalExpiry
§fn clone(&self) -> ConditionalExpiry
fn clone(&self) -> ConditionalExpiry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ConditionalExpiry
impl Debug for ConditionalExpiry
§impl<'de> Deserialize<'de> for ConditionalExpiry
impl<'de> Deserialize<'de> for ConditionalExpiry
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ConditionalExpiry, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ConditionalExpiry, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for ConditionalExpiry
impl Serialize for ConditionalExpiry
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ConditionalExpiry
impl RefUnwindSafe for ConditionalExpiry
impl Send for ConditionalExpiry
impl Sync for ConditionalExpiry
impl Unpin for ConditionalExpiry
impl UnsafeUnpin for ConditionalExpiry
impl UnwindSafe for ConditionalExpiry
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.