Overview
NanoARB uses fixed-point arithmetic and zero-copy serialization for maximum performance in HFT applications. All core types are optimized for nanosecond-level precision and deterministic behavior.Price
Fixed-point price representation that avoids floating-point errors.Definition
i64 internally to represent prices in the smallest tick unit. This ensures deterministic arithmetic and avoids floating-point precision issues.
Price
Zero price constant
Price
Maximum price constant (i64::MAX)
Price
Minimum price constant (i64::MIN)
Constructors
fn(ticks: i64) -> Price
Create a price from raw tick value
fn(value: i64, decimals: u8) -> Price
Create a price from ticks and decimal places
fn(value: f64, tick_size: f64) -> Price
Create a price from a floating-point value with specified tick size
Methods
i64
Get the raw tick value
f64
Convert to f64 (assumes tick size of 0.01)
f64
Convert to f64 with specified tick size
bool
Check if the price is zero
bool
Check if the price is positive
bool
Check if the price is negative
Price
Get the absolute value
Arithmetic Operations
Quantity
Represents order and position sizes using unsigned integers.Definition
Quantity
Zero quantity constant
Quantity
Maximum quantity constant (u32::MAX)
Constructors
fn(value: u32) -> Quantity
Create a new quantity
Methods
u32
Get the raw value
bool
Check if quantity is zero
i64
Convert to i64 for position calculations
f64
Convert to f64 for calculations
Example Usage
SignedQuantity
Signed quantity for positions (positive = long, negative = short).Definition
Methods
fn(value: i64) -> SignedQuantity
Create a new signed quantity
i64
Get the raw value
Quantity
Get the absolute value as unsigned quantity
bool
Check if the position is long (positive)
bool
Check if the position is short (negative)
bool
Check if the position is flat (zero)
Example Usage
Side
Order/Trade side enumeration.Definition
Methods
bool
Check if this is a buy side
bool
Check if this is a sell side
Side
Get the opposite side
i64
Convert to a sign multiplier (1 for buy, -1 for sell)
f64
Convert to a sign multiplier as f64
Conversions
Timestamp
Nanosecond-precision timestamp since Unix epoch.Definition
Timestamp
Zero timestamp (Unix epoch)
Timestamp
Maximum timestamp
Timestamp
Minimum timestamp
Constructors
fn(nanos: i64) -> Timestamp
Create a timestamp from nanoseconds since epoch
fn(micros: i64) -> Timestamp
Create a timestamp from microseconds since epoch
fn(millis: i64) -> Timestamp
Create a timestamp from milliseconds since epoch
fn(secs: i64) -> Timestamp
Create a timestamp from seconds since epoch
fn() -> Timestamp
Get the current timestamp
Methods
i64
Get nanoseconds since epoch
i64
Get microseconds since epoch
i64
Get milliseconds since epoch
i64
Get seconds since epoch
u32
Get the nanosecond component (0-999,999,999)
i64
Calculate duration to another timestamp in nanoseconds
Example Usage
OrderId
Unique order identifier.Definition
Methods
fn(id: u64) -> OrderId
Create a new order ID
u64
Get the raw value
Conversions
Order
A trading order with full lifecycle tracking.Definition
Order Types
Time In Force
Order Status
Constructors
fn(id: OrderId, instrument_id: u32, side: Side, price: Price, quantity: Quantity, time_in_force: TimeInForce) -> Order
Create a new limit order
fn(id: OrderId, instrument_id: u32, side: Side, quantity: Quantity) -> Order
Create a new market order
Methods
Quantity
Get remaining quantity to be filled
bool
Check if the order is completely filled
bool
Check if the order can be cancelled
f64
Get fill ratio (0.0 to 1.0)
fn(&mut self, fill_price: Price, fill_qty: Quantity, timestamp: Timestamp)
Update order with a fill
Quote
Best Bid/Offer (BBO) representation.Definition
Methods
fn(instrument_id: u32, bid_price: Price, bid_quantity: Quantity, ask_price: Price, ask_quantity: Quantity, timestamp: Timestamp) -> Quote
Create a new quote
Price
Calculate the mid price
Price
Calculate the spread in ticks
bool
Check if the quote is valid (bid < ask)
Trade
Trade execution information.Definition
Fill
Fill information for an executed order.Definition
Methods
f64
Calculate the notional value of this fill
i64
Calculate the signed quantity (positive for buy, negative for sell)
Level
A price level in the order book.Definition
Methods
fn(price: Price, quantity: Quantity, order_count: u32) -> Level
Create a new level
fn(price: Price) -> Level
Create an empty level at a given price
bool
Check if the level is empty