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.
Zero price constant
Maximum price constant (i64::MAX)
Minimum price constant (i64::MIN)
Constructors
Create a price from raw tick value
Create a price from ticks and decimal places
Create a price from a floating-point value with specified tick size
Methods
Get the raw tick value
Convert to f64 (assumes tick size of 0.01)
Convert to f64 with specified tick size
Check if the price is zero
Check if the price is positive
Check if the price is negative
Get the absolute value
Arithmetic Operations
Quantity
Represents order and position sizes using unsigned integers.Definition
Zero quantity constant
Maximum quantity constant (u32::MAX)
Constructors
Create a new quantity
Methods
Get the raw value
Check if quantity is zero
Convert to i64 for position calculations
Convert to f64 for calculations
Example Usage
SignedQuantity
Signed quantity for positions (positive = long, negative = short).Definition
Methods
Create a new signed quantity
Get the raw value
Get the absolute value as unsigned quantity
Check if the position is long (positive)
Check if the position is short (negative)
Check if the position is flat (zero)
Example Usage
Side
Order/Trade side enumeration.Definition
Methods
Check if this is a buy side
Check if this is a sell side
Get the opposite side
Convert to a sign multiplier (1 for buy, -1 for sell)
Convert to a sign multiplier as f64
Conversions
Timestamp
Nanosecond-precision timestamp since Unix epoch.Definition
Zero timestamp (Unix epoch)
Maximum timestamp
Minimum timestamp
Constructors
Create a timestamp from nanoseconds since epoch
Create a timestamp from microseconds since epoch
Create a timestamp from milliseconds since epoch
Create a timestamp from seconds since epoch
Get the current timestamp
Methods
Get nanoseconds since epoch
Get microseconds since epoch
Get milliseconds since epoch
Get seconds since epoch
Get the nanosecond component (0-999,999,999)
Calculate duration to another timestamp in nanoseconds
Example Usage
OrderId
Unique order identifier.Definition
Methods
Create a new order ID
Get the raw value
Conversions
Order
A trading order with full lifecycle tracking.Definition
Order Types
Time In Force
Order Status
Constructors
new_limit
fn(id: OrderId, instrument_id: u32, side: Side, price: Price, quantity: Quantity, time_in_force: TimeInForce) -> Order
Create a new limit order
Create a new market order
Methods
Get remaining quantity to be filled
Check if the order is completely filled
Check if the order can be cancelled
Get fill ratio (0.0 to 1.0)
Update order with a fill
Quote
Best Bid/Offer (BBO) representation.Definition
Methods
new
fn(instrument_id: u32, bid_price: Price, bid_quantity: Quantity, ask_price: Price, ask_quantity: Quantity, timestamp: Timestamp) -> Quote
Create a new quote
Calculate the mid price
Calculate the spread in ticks
Check if the quote is valid (bid < ask)
Trade
Trade execution information.Definition
Fill
Fill information for an executed order.Definition
Methods
Calculate the notional value of this fill
Calculate the signed quantity (positive for buy, negative for sell)
Level
A price level in the order book.Definition
Methods
Create a new level
Create an empty level at a given price
Check if the level is empty