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: u32Arena 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: u32Number of price ticks on the grid. A multiple of 64, at least 64, at most 2^22.
tick_size: u64Quote units per tick, at least 1.
grid_start_tick: u64Tick value of grid index 0. A price whose tick is t maps to grid
index t - grid_start_tick.
default_stp: StpPolicySelf-trade prevention policy applied when a command does not name one (executes from Milestone 2).
Implementations§
Source§impl BookConfig
impl BookConfig
Sourcepub fn grid_end_tick(&self) -> Result<u64, BookError>
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).
Sourcepub const fn min_price(&self) -> u64
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);