OrderPacket

Enum OrderPacket 

Source
pub enum OrderPacket {
    PostOnly {
        side: Side,
        price_in_ticks: Ticks,
        num_base_lots: BaseLots,
        client_order_id: u128,
        reject_post_only: bool,
        use_only_deposited_funds: bool,
        last_valid_slot: Option<u64>,
        last_valid_unix_timestamp_in_seconds: Option<u64>,
        fail_silently_on_insufficient_funds: bool,
    },
    Limit {
        side: Side,
        price_in_ticks: Ticks,
        num_base_lots: BaseLots,
        self_trade_behavior: SelfTradeBehavior,
        match_limit: Option<u64>,
        client_order_id: u128,
        use_only_deposited_funds: bool,
        last_valid_slot: Option<u64>,
        last_valid_unix_timestamp_in_seconds: Option<u64>,
        fail_silently_on_insufficient_funds: bool,
    },
    ImmediateOrCancel {
        side: Side,
        price_in_ticks: Option<Ticks>,
        num_base_lots: BaseLots,
        num_quote_lots: QuoteLots,
        min_base_lots_to_fill: BaseLots,
        min_quote_lots_to_fill: QuoteLots,
        self_trade_behavior: SelfTradeBehavior,
        match_limit: Option<u64>,
        client_order_id: u128,
        use_only_deposited_funds: bool,
        last_valid_slot: Option<u64>,
        last_valid_unix_timestamp_in_seconds: Option<u64>,
    },
}

Variants§

§

PostOnly

This order type is used to place a limit order on the book. It will never be matched against other existing limit orders

Fields

§side: Side
§price_in_ticks: Ticks

The price of the order, in ticks

§num_base_lots: BaseLots

Number of base lots to place on the book

§client_order_id: u128

Client order id used to identify the order in the response to the client

§reject_post_only: bool

Flag for whether or not to reject the order if it would immediately match or amend it to the best non-crossing price Default value is true

§use_only_deposited_funds: bool

Flag for whether or not the order should only use funds that are already in the account Using only deposited funds will allow the trader to pass in less accounts per instruction and save transaction space as well as compute. This is only for traders who have a seat

§last_valid_slot: Option<u64>

If this is set, the order will be invalid after the specified slot

§last_valid_unix_timestamp_in_seconds: Option<u64>

If this is set, the order will be invalid after the specified unix timestamp

§fail_silently_on_insufficient_funds: bool

If this is set, the order will fail silently if there are insufficient funds

§

Limit

This order type is used to place a limit order on the book It can be matched against other existing limit orders, but will posted at the specified level if it is not matched

Fields

§side: Side
§price_in_ticks: Ticks

The price of the order, in ticks

§num_base_lots: BaseLots

Total number of base lots to place on the book or fill at a better price

§self_trade_behavior: SelfTradeBehavior

How the matching engine should handle a self trade

§match_limit: Option<u64>

Number of orders to match against. If this is None there is no limit

§client_order_id: u128

Client order id used to identify the order in the response to the client

§use_only_deposited_funds: bool

Flag for whether or not the order should only use funds that are already in the account. Using only deposited funds will allow the trader to pass in less accounts per instruction and save transaction space as well as compute. This is only for traders who have a seat

§last_valid_slot: Option<u64>

If this is set, the order will be invalid after the specified slot

§last_valid_unix_timestamp_in_seconds: Option<u64>

If this is set, the order will be invalid after the specified unix timestamp

§fail_silently_on_insufficient_funds: bool

If this is set, the order will fail silently if there are insufficient funds

§

ImmediateOrCancel

This order type is used to place an order that will be matched against existing resting orders If the order matches fewer than min_lots lots, it will be cancelled.

Fill or Kill (FOK) orders are a subset of Immediate or Cancel (IOC) orders where either the num_base_lots is equal to the min_base_lots_to_fill of the order, or the num_quote_lots is equal to the min_quote_lots_to_fill of the order.

Fields

§side: Side
§price_in_ticks: Option<Ticks>

The most aggressive price an order can be matched at. For example, if there is an IOC buy order to purchase 10 lots with the tick_per_lot parameter set to 10, then the order will never be matched at a price higher than 10 quote ticks per base unit. If this value is None, then the order is treated as a market order.

§num_base_lots: BaseLots

The number of base lots to fill against the order book. Either this parameter or the num_quote_lots parameter must be set to a nonzero value.

§num_quote_lots: QuoteLots

The number of quote lots to fill against the order book. Either this parameter or the num_base_lots parameter must be set to a nonzero value.

§min_base_lots_to_fill: BaseLots

The minimum number of base lots to fill against the order book. If the order does not fill this many base lots, it will be voided.

§min_quote_lots_to_fill: QuoteLots

The minimum number of quote lots to fill against the order book. If the order does not fill this many quote lots, it will be voided.

§self_trade_behavior: SelfTradeBehavior

How the matching engine should handle a self trade.

§match_limit: Option<u64>

Number of orders to match against. If set to None, there is no limit.

§client_order_id: u128

Client order id used to identify the order in the program’s inner instruction data.

§use_only_deposited_funds: bool

Flag for whether or not the order should only use funds that are already in the account. Using only deposited funds will allow the trader to pass in less accounts per instruction and save transaction space as well as compute. This is only for traders who have a seat

§last_valid_slot: Option<u64>

If this is set, the order will be invalid after the specified slot

§last_valid_unix_timestamp_in_seconds: Option<u64>

If this is set, the order will be invalid after the specified unix timestamp

Implementations§

Source§

impl OrderPacket

Source

pub fn new_post_only_default( side: Side, price_in_ticks: u64, num_base_lots: u64, ) -> Self

Source

pub fn new_post_only_default_with_client_order_id( side: Side, price_in_ticks: u64, num_base_lots: u64, client_order_id: u128, ) -> Self

Source

pub fn new_adjustable_post_only_default_with_client_order_id( side: Side, price_in_ticks: u64, num_base_lots: u64, client_order_id: u128, ) -> Self

Source

pub fn new_post_only( side: Side, price_in_ticks: u64, num_base_lots: u64, client_order_id: u128, reject_post_only: bool, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_limit_order_default( side: Side, price_in_ticks: u64, num_base_lots: u64, ) -> Self

Source

pub fn new_limit_order_default_with_client_order_id( side: Side, price_in_ticks: u64, num_base_lots: u64, client_order_id: u128, ) -> Self

Source

pub fn new_limit_order( side: Side, price_in_ticks: u64, num_base_lots: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_fok_sell_with_limit_price( target_price_in_ticks: u64, base_lot_budget: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_fok_buy_with_limit_price( target_price_in_ticks: u64, base_lot_budget: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_ioc_sell_with_limit_price( price_in_ticks: u64, num_base_lots: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_ioc_buy_with_limit_price( price_in_ticks: u64, num_quote_lots: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_ioc_by_lots( side: Side, price_in_ticks: u64, base_lot_budget: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, ) -> Self

Source

pub fn new_ioc_buy_with_slippage( quote_lots_in: u64, min_base_lots_out: u64, ) -> Self

Source

pub fn new_ioc_sell_with_slippage( base_lots_in: u64, min_quote_lots_out: u64, ) -> Self

Source

pub fn new_ioc( side: Side, price_in_ticks: Option<u64>, num_base_lots: u64, num_quote_lots: u64, min_base_lots_to_fill: u64, min_quote_lots_to_fill: u64, self_trade_behavior: SelfTradeBehavior, match_limit: Option<u64>, client_order_id: u128, use_only_deposited_funds: bool, last_valid_slot: Option<u64>, last_valid_unix_timestamp_in_seconds: Option<u64>, ) -> Self

Source§

impl OrderPacket

Source

pub fn side(&self) -> Side

Source

pub fn fail_silently_on_insufficient_funds(&self) -> bool

Source

pub fn client_order_id(&self) -> u128

Source

pub fn num_base_lots(&self) -> BaseLots

Source

pub fn num_quote_lots(&self) -> QuoteLots

Source

pub fn base_lot_budget(&self) -> BaseLots

Source

pub fn quote_lot_budget(&self) -> Option<QuoteLots>

Source

pub fn match_limit(&self) -> u64

Source

pub fn self_trade_behavior(&self) -> SelfTradeBehavior

Source

pub fn get_price_in_ticks(&self) -> Ticks

Source

pub fn set_price_in_ticks(&mut self, price_in_ticks: Ticks)

Source

pub fn get_last_valid_slot(&self) -> Option<u64>

Source

pub fn get_last_valid_unix_timestamp_in_seconds(&self) -> Option<u64>

Source

pub fn is_expired( &self, current_slot: u64, current_unix_timestamp_in_seconds: u64, ) -> bool

Trait Implementations§

Source§

impl BorshDeserialize for OrderPacket

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for OrderPacket

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for OrderPacket

Source§

fn clone(&self) -> OrderPacket

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OrderPacket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl EnumExt for OrderPacket

Source§

fn deserialize_variant<R: Read>( reader: &mut R, variant_idx: u8, ) -> Result<Self, Error>

Deserialises given variant of an enum from the reader. Read more
Source§

impl<MarketTraderId: Debug + PartialOrd + Ord + Default + Copy + Clone + Zeroable + Pod + BorshDeserialize + BorshSerialize, const BIDS_SIZE: usize, const ASKS_SIZE: usize, const NUM_SEATS: usize> Market<MarketTraderId, FIFOOrderId, FIFORestingOrder, OrderPacket> for FIFOMarket<MarketTraderId, BIDS_SIZE, ASKS_SIZE, NUM_SEATS>

Source§

fn get_data_size(&self) -> usize

Source§

fn get_taker_fee_bps(&self) -> u64

Source§

fn get_tick_size(&self) -> QuoteLotsPerBaseUnitPerTick

Source§

fn get_base_lots_per_base_unit(&self) -> BaseLotsPerBaseUnit

Source§

fn get_sequence_number(&self) -> u64

Source§

fn get_collected_fee_amount(&self) -> QuoteLots

Source§

fn get_uncollected_fee_amount(&self) -> QuoteLots

Source§

fn get_registered_traders( &self, ) -> &dyn OrderedNodeAllocatorMap<MarketTraderId, TraderState>

Source§

fn get_trader_state(&self, trader_id: &MarketTraderId) -> Option<&TraderState>

Source§

fn get_trader_state_from_index(&self, index: u32) -> &TraderState

Source§

fn get_trader_index(&self, trader_id: &MarketTraderId) -> Option<u32>

Source§

fn get_trader_id_from_index(&self, trader_index: u32) -> MarketTraderId

Source§

fn get_book( &self, side: Side, ) -> &dyn OrderedNodeAllocatorMap<FIFOOrderId, FIFORestingOrder>

Source§

fn get_ladder(&self, levels: u64) -> Ladder

Source§

fn get_ladder_with_expiration( &self, levels: u64, last_valid_slot: Option<u64>, last_valid_unix_timestamp_in_seconds: Option<u64>, ) -> Ladder

Source§

fn get_typed_ladder(&self, levels: u64) -> TypedLadder

Source§

fn get_typed_ladder_with_expiration( &self, levels: u64, last_valid_slot: Option<u64>, last_valid_unix_timestamp_in_seconds: Option<u64>, ) -> TypedLadder

Source§

impl OrderPacketMetadata for OrderPacket

Source§

impl PartialEq for OrderPacket

Source§

fn eq(&self, other: &OrderPacket) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for OrderPacket

Source§

impl Eq for OrderPacket

Source§

impl StructuralPartialEq for OrderPacket

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V