Skip to main content

BookConfig

Struct BookConfig 

Source
pub struct BookConfig {
    pub max_orders: u32,
    pub grid_len: u32,
    pub tick_size: u64,
    pub grid_start_tick: u64,
    pub default_stp: StpPolicy,
}
Expand description

Static configuration for one crate::Book.

Fields§

§max_orders: u32

Arena capacity: the maximum number of simultaneously live orders. At least 1 and at most 2^31 - 2, so slot indices can reserve u32::MAX as NIL.

§grid_len: u32

Number of price ticks on the grid. A multiple of 64, at least 64, at most 2^22.

§tick_size: u64

Quote units per tick, at least 1.

§grid_start_tick: u64

Tick value of grid index 0. A price whose tick is t maps to grid index t - grid_start_tick.

§default_stp: StpPolicy

Self-trade prevention policy applied when a command does not name one (executes from Milestone 2).

Implementations§

Source§

impl BookConfig

Source

pub fn grid_end_tick(&self) -> Result<u64, BookError>

The tick value one past the last tick on the grid.

§Errors

Returns BookError::InvalidConfig if the grid end overflows u64 (the m9a construction bound, ARCHITECTURE.md section 3.2).

Source

pub const fn min_price(&self) -> u64

Smallest valid raw price on the grid, in quote units.

Price zero is never valid on a crate::Book (ARCHITECTURE.md section 3.2), so when grid_start_tick is 0 the lowest addressable price tick is 1 (tick_size); otherwise it is grid_start_tick * tick_size.

§Examples
use chronicle_core::{BookConfig, StpPolicy};

let cfg = BookConfig {
    max_orders: 64,
    grid_len: 640,
    tick_size: 5,
    grid_start_tick: 100,
    default_stp: StpPolicy::CancelIncoming,
};
assert_eq!(cfg.min_price(), 500);
assert_eq!(cfg.max_price().unwrap(), 3695);
Source

pub fn max_price(&self) -> Result<u64, BookError>

Largest valid raw price on the grid, in quote units: (grid_start_tick + grid_len - 1) * tick_size.

§Errors

Returns BookError::InvalidConfig when grid_len or tick_size is zero or when the grid end or highest raw price overflows u64.

Source

pub fn validate(&self) -> Result<(), BookError>

Validate every construction rule.

§Errors

Returns BookError::InvalidConfig naming the first field and rule that fail.

Trait Implementations§

Source§

impl Clone for BookConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for BookConfig

Source§

impl Debug for BookConfig

Source§

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

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

impl Eq for BookConfig

Source§

impl PartialEq for BookConfig

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BookConfig

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.