pub struct TrailingStop { /* private fields */ }Expand description
A stop that trails the best price by its Retracement. Size and prices go on the wire
exactly as given, so put them on the asset’s grid first (crate::utils::Grid).
Implementations§
Source§impl TrailingStop
impl TrailingStop
Sourcepub fn new(
asset: Asset,
side: Side,
size: Dec,
retracement: Retracement,
) -> Result<TrailingStop, BadTrailingStop>
pub fn new( asset: Asset, side: Side, size: Dec, retracement: Retracement, ) -> Result<TrailingStop, BadTrailingStop>
size of asset, trading side when the price falls back from its best by retracement.
Sourcepub fn activated_at(self, px: Dec) -> Result<TrailingStop, BadTrailingStop>
pub fn activated_at(self, px: Dec) -> Result<TrailingStop, BadTrailingStop>
Starts to trail only once the market reaches px.
Sourcepub const fn reduce_only(self) -> TrailingStop
pub const fn reduce_only(self) -> TrailingStop
Only ever shrinks the position.
Sourcepub const fn is_reduce_only(&self) -> bool
pub const fn is_reduce_only(&self) -> bool
Whether it only ever shrinks the position.
Sourcepub const fn retracement(&self) -> Retracement
pub const fn retracement(&self) -> Retracement
How far the price may fall back from its best before it fires.
Sourcepub const fn activation(&self) -> Option<Dec>
pub const fn activation(&self) -> Option<Dec>
The price the market must reach before it starts to trail; None to trail at once.
Trait Implementations§
Source§impl Clone for TrailingStop
impl Clone for TrailingStop
impl Copy for TrailingStop
Source§impl Debug for TrailingStop
impl Debug for TrailingStop
impl Eq for TrailingStop
Source§impl From<TrailingStop> for TradeAction
impl From<TrailingStop> for TradeAction
Source§fn from(action: TrailingStop) -> TradeAction
fn from(action: TrailingStop) -> TradeAction
Converts to this type from the input type.
Source§impl L1Action for TrailingStop
impl L1Action for TrailingStop
Source§fn action(&self) -> Map
fn action(&self) -> Map
The action’s keys and values in wire order, which is the hashed order.
Source§fn msgpack(&self) -> Vec<u8> ⓘ
fn msgpack(&self) -> Vec<u8> ⓘ
The action as msgpack bytes, the first part of the connection id’s hash.
Source§fn typed(
&self,
nonce: u64,
vault: Option<Address>,
network: Network,
) -> TypedStruct<'static>
fn typed( &self, nonce: u64, vault: Option<Address>, network: Network, ) -> TypedStruct<'static>
The phantom agent struct the key signs for this action.
Source§fn digest(
&self,
nonce: u64,
vault: Option<Address>,
network: Network,
) -> [u8; 32]
fn digest( &self, nonce: u64, vault: Option<Address>, network: Network, ) -> [u8; 32]
What the key signs for this action: the phantom agent’s digest under
Domain::EXCHANGE.Source§impl PartialEq for TrailingStop
impl PartialEq for TrailingStop
impl StructuralPartialEq for TrailingStop
Auto Trait Implementations§
impl Forget for TrailingStop
impl Freeze for TrailingStop
impl Move for TrailingStop
impl RefUnwindSafe for TrailingStop
impl Send for TrailingStop
impl Sync for TrailingStop
impl Unpin for TrailingStop
impl UnsafeUnpin for TrailingStop
impl UnwindSafe for TrailingStop
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
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.