Implementation:Avhz RustQuant OrderType
| Knowledge Sources | |
|---|---|
| Domains | Order_Management, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete tool for representing trading order types provided by the RustQuant library.
Description
The OrderType enum defines the various order types supported by the trading module, based on definitions from Interactive Brokers and NASDAQ. Six variants are available: Market executes immediately at the current bid/ask with no price protection; Limit fills only at the specified price or better; Stop submits a market order when a trigger price is reached, used to limit losses or protect profits; StopLimit submits a limit order (not a market order) when the stop trigger is hit, providing both a trigger and price ceiling/floor; TrailingStop has a stop price that trails the market by a fixed amount, rising with the market but not falling, triggering a market order when the stop is hit; TrailingStopLimit combines trailing behavior with a limit order, continuously recalculating both stop and limit prices based on user-defined offsets. The enum implements Display for uppercase string output (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP, TRAILING_STOP_LIMIT) and derives Debug, Clone, and Copy.
Usage
Use this enum when constructing Order structs to specify the execution behavior of the order, determining how and when the order interacts with the market.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_trading/src/order_type.rs
- Lines: 1-100
Signature
#[derive(Debug, Clone, Copy)]
pub enum OrderType {
Market,
Limit,
Stop,
StopLimit,
TrailingStop,
TrailingStopLimit,
}
impl fmt::Display for OrderType { ... }
Import
use RustQuant::trading::OrderType;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| variant | OrderType | Yes | One of: Market, Limit, Stop, StopLimit, TrailingStop, TrailingStopLimit |
Outputs
| Name | Type | Description |
|---|---|---|
| OrderType | enum | The selected order type variant |
| Display | String | Uppercase string: "MARKET", "LIMIT", "STOP", "STOP_LIMIT", "TRAILING_STOP", "TRAILING_STOP_LIMIT" |
Usage Examples
use RustQuant::trading::OrderType;
let market = OrderType::Market;
let limit = OrderType::Limit;
let stop_limit = OrderType::StopLimit;
let trailing = OrderType::TrailingStop;
println!("{}", market); // Output: MARKET
println!("{}", limit); // Output: LIMIT
println!("{}", stop_limit); // Output: STOP_LIMIT
println!("{}", trailing); // Output: TRAILING_STOP