Trait OrderBookUnits

Source
pub trait OrderBookUnits {
    // Required methods
    fn lot_size(&self) -> u64;
    fn tick_size(&self) -> u64;

    // Provided methods
    fn price_to_ifixed(&self, price: u64) -> IFixed { ... }
    fn ifixed_to_price(&self, ifixed: IFixed) -> Result<u64, Error> { ... }
    fn lots_to_ifixed(&self, lots: u64) -> IFixed { ... }
    fn ifixed_to_lots(&self, ifixed: IFixed) -> Result<u64, Error> { ... }
}
Expand description

Convenience trait to convert to/from units used in the orderbook.

Required Methods§

Source

fn lot_size(&self) -> u64

Source

fn tick_size(&self) -> u64

Provided Methods§

Source

fn price_to_ifixed(&self, price: u64) -> IFixed

Source

fn ifixed_to_price(&self, ifixed: IFixed) -> Result<u64, Error>

The price in ticks/lot closest to the desired value.

Note that this:

  • rounds the equivalent ticks/lot down to the nearest integer.
  • errors if the equivalent ticks/lot < 1, signaling not enough precision.
Source

fn lots_to_ifixed(&self, lots: u64) -> IFixed

Source

fn ifixed_to_lots(&self, ifixed: IFixed) -> Result<u64, Error>

Implementors§