#[non_exhaustive]pub struct OrderWire {
pub asset: u32,
pub is_buy: bool,
pub limit_px: String,
pub sz: String,
pub reduce_only: bool,
pub order_type: OrderTypeWire,
pub cloid: Option<String>,
}Expand description
Wire format for an order sent to the Hyperliquid exchange.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.asset: u32Asset index (perp index or spot index with offset).
is_buy: boolWhether this is a buy order.
limit_px: StringLimit price as a decimal string.
sz: StringSize as a decimal string.
reduce_only: boolWhether the order is reduce-only.
order_type: OrderTypeWireOrder type wire format.
cloid: Option<String>Optional client order ID.
Implementations§
Source§impl OrderWire
impl OrderWire
Sourcepub fn limit_buy(asset: u32, limit_px: Decimal, sz: Decimal) -> OrderWireBuilder
pub fn limit_buy(asset: u32, limit_px: Decimal, sz: Decimal) -> OrderWireBuilder
Start building a limit buy order.
Defaults to Tif::Gtc, reduce_only = false, no cloid.
§Example
use hl_types::{OrderWire, Tif};
use rust_decimal::Decimal;
use std::str::FromStr;
let order = OrderWire::limit_buy(0, Decimal::from(90000), Decimal::from_str("0.001").unwrap())
.tif(Tif::Gtc)
.cloid("my-order-1")
.build()
.unwrap();
assert!(order.is_buy);
assert_eq!(order.limit_px, "90000");Sourcepub fn limit_sell(
asset: u32,
limit_px: Decimal,
sz: Decimal,
) -> OrderWireBuilder
pub fn limit_sell( asset: u32, limit_px: Decimal, sz: Decimal, ) -> OrderWireBuilder
Start building a limit sell order.
Defaults to Tif::Gtc, reduce_only = false, no cloid.
Sourcepub fn trigger_buy(
asset: u32,
trigger_px: Decimal,
sz: Decimal,
tpsl: Tpsl,
) -> OrderWireBuilder
pub fn trigger_buy( asset: u32, trigger_px: Decimal, sz: Decimal, tpsl: Tpsl, ) -> OrderWireBuilder
Start building a trigger buy order (e.g. stop-loss or take-profit).
Trigger orders fire as market orders when the trigger price is hit.
Defaults to reduce_only = true, no cloid.
Sourcepub fn trigger_sell(
asset: u32,
trigger_px: Decimal,
sz: Decimal,
tpsl: Tpsl,
) -> OrderWireBuilder
pub fn trigger_sell( asset: u32, trigger_px: Decimal, sz: Decimal, tpsl: Tpsl, ) -> OrderWireBuilder
Start building a trigger sell order (e.g. stop-loss or take-profit).
Trigger orders fire as market orders when the trigger price is hit.
Defaults to reduce_only = true, no cloid.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OrderWire
impl<'de> Deserialize<'de> for OrderWire
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>,
impl Eq for OrderWire
impl StructuralPartialEq for OrderWire
Auto Trait Implementations§
impl Freeze for OrderWire
impl RefUnwindSafe for OrderWire
impl Send for OrderWire
impl Sync for OrderWire
impl Unpin for OrderWire
impl UnsafeUnpin for OrderWire
impl UnwindSafe for OrderWire
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
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
key and return true if they are equal.