Implementation:Avhz RustQuant Order
| Knowledge Sources | |
|---|---|
| Domains | Order_Management, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete tool for representing trading orders in a limit order book provided by the RustQuant library.
Description
The Order struct models a single order in a limit order book with comprehensive fields covering general information (order ID as OrderID type alias for u64, symbol ID, order type, and order side), price information (price and stop price as f64), quantity information (total quantity, executed quantity, and leaves/remaining quantity as u64), and time information (time-in-force policy and timestamp via OffsetDateTime). The struct provides getter methods for all fields: id(), symbol_id(), order_type(), order_side(), price(), stop_price(), quantity(), executed_quantity(), leaves_quantity(), time_in_force(), and timestamp(). It implements Display for formatted string output showing all order parameters, and a validate() method stub for future order validation logic. The struct derives Debug, Clone, and Copy.
Usage
Use this struct when constructing orders to be placed into an OrderBook, whether for live trading simulation, backtesting, or market microstructure research requiring detailed order-level tracking.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_trading/src/order.rs
- Lines: 1-191
Signature
pub type OrderID = u64;
#[derive(Debug, Clone, Copy)]
pub struct Order {
pub id: OrderID,
pub symbol_id: u32,
pub order_type: OrderType,
pub order_side: OrderSide,
pub price: f64,
pub stop_price: f64,
pub quantity: u64,
pub executed_quantity: u64,
pub leaves_quantity: u64,
pub time_in_force: OrderTimeInForce,
pub timestamp: OffsetDateTime,
}
impl Order {
pub fn validate(&self);
pub fn id(&self) -> u64;
pub fn symbol_id(&self) -> u32;
pub fn order_type(&self) -> &OrderType;
pub fn order_side(&self) -> &OrderSide;
pub fn price(&self) -> f64;
pub fn stop_price(&self) -> f64;
pub fn quantity(&self) -> u64;
pub fn executed_quantity(&self) -> u64;
pub fn leaves_quantity(&self) -> u64;
pub fn time_in_force(&self) -> &OrderTimeInForce;
pub fn timestamp(&self) -> OffsetDateTime;
}
Import
use RustQuant::trading::{Order, OrderID};
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | OrderID (u64) | Yes | Unique order identifier |
| symbol_id | u32 | Yes | Identifier for the traded symbol/instrument |
| order_type | OrderType | Yes | Type of order (Market, Limit, Stop, etc.) |
| order_side | OrderSide | Yes | Side of the book (BID or ASK) |
| price | f64 | Yes | Order price |
| stop_price | f64 | Yes | Stop trigger price (for stop orders) |
| quantity | u64 | Yes | Total order quantity |
| executed_quantity | u64 | Yes | Number of shares already executed |
| leaves_quantity | u64 | Yes | Remaining quantity to be filled |
| time_in_force | OrderTimeInForce | Yes | Order lifespan policy (GTC, IOC, FOK, AON) |
| timestamp | OffsetDateTime | Yes | Time the order was placed |
Outputs
| Name | Type | Description |
|---|---|---|
| Order | struct | A complete order representation for use in an order book |
| Display | String | Formatted string showing all order fields |
Usage Examples
use RustQuant::trading::{Order, OrderType, OrderSide, OrderTimeInForce};
use time::OffsetDateTime;
let order = Order {
id: 12345,
symbol_id: 1,
order_type: OrderType::Limit,
order_side: OrderSide::BID,
price: 150.50,
stop_price: 0.0,
quantity: 100,
executed_quantity: 0,
leaves_quantity: 100,
time_in_force: OrderTimeInForce::GoodTillCancelled,
timestamp: OffsetDateTime::now_utc(),
};
assert_eq!(order.id(), 12345);
assert_eq!(order.quantity(), 100);
println!("{}", order);