Implementation:Avhz RustQuant OrderLifespan
| Knowledge Sources | |
|---|---|
| Domains | Order_Management, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete tool for representing order time-in-force policies provided by the RustQuant library.
Description
The OrderTimeInForce enum defines the lifespan and fill behavior of trading orders, based on standard order types from Interactive Brokers and NASDAQ. Four variants are supported: GoodTillCancelled (GTC) keeps the order active until filled or explicitly cancelled, allowing resting orders for extended periods; ImmediateOrCancel (IOC) fills whatever portion is immediately available and cancels the remainder; FillOrKill (FOK) requires the entire order to execute immediately or the whole order is cancelled, ensuring no partial fills; AllOrNone (AON) requires the order to be filled in its entirety but unlike FOK, the order stays on the book until it can be fully matched or is cancelled. The enum implements Display for short-form output (GTC, IOC, FOK, AON) and derives Debug, Clone, Copy, PartialEq, and Eq.
Usage
Use this enum when constructing Order structs to specify how long an order should remain active and under what conditions partial fills are acceptable.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_trading/src/order_lifespan.rs
- Lines: 1-59
Signature
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OrderTimeInForce {
GoodTillCancelled,
ImmediateOrCancel,
FillOrKill,
AllOrNone,
}
impl fmt::Display for OrderTimeInForce { ... }
Import
use RustQuant::trading::OrderTimeInForce;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| variant | OrderTimeInForce | Yes | One of: GoodTillCancelled, ImmediateOrCancel, FillOrKill, AllOrNone |
Outputs
| Name | Type | Description |
|---|---|---|
| OrderTimeInForce | enum | The selected time-in-force policy |
| Display | String | Short-form abbreviation: "GTC", "IOC", "FOK", or "AON" |
Usage Examples
use RustQuant::trading::OrderTimeInForce;
let tif = OrderTimeInForce::GoodTillCancelled;
println!("{}", tif); // Output: GTC
let ioc = OrderTimeInForce::ImmediateOrCancel;
assert_eq!(format!("{}", ioc), "IOC");
// Comparison
assert_ne!(
OrderTimeInForce::FillOrKill,
OrderTimeInForce::AllOrNone
);