Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Avhz RustQuant OrderSide

From Leeroopedia


Knowledge Sources
Domains Order_Management, Quantitative_Finance
Last Updated 2026-02-07 19:00 GMT

Overview

Concrete tool for representing the buy/sell side of a trading order provided by the RustQuant library.

Description

The OrderSide enum indicates which side of the order book an order belongs to: BID for buy orders or ASK for sell orders. The enum implements the Not trait (logical negation operator), so applying the ! operator to a BID returns ASK and vice versa, which is convenient for computing the opposite side in order matching logic. It also implements Display for human-readable output ("BID (buy)" and "ASK (sell)"). The enum derives Debug, Clone, Copy, PartialEq, and Eq.

Usage

Use this enum when constructing orders to specify whether they are buy or sell orders, and when routing orders to the correct side of an order book.

Code Reference

Source Location

Signature

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OrderSide {
    BID,
    ASK,
}

impl std::ops::Not for OrderSide {
    type Output = OrderSide;
    fn not(self) -> Self::Output;
}

impl fmt::Display for OrderSide { ... }

Import

use RustQuant::trading::OrderSide;

I/O Contract

Inputs

Name Type Required Description
variant OrderSide Yes One of: BID (buy side) or ASK (sell side)

Outputs

Name Type Description
OrderSide enum The selected order side
!OrderSide OrderSide The opposite side (BID becomes ASK, ASK becomes BID)
Display String "BID (buy)" or "ASK (sell)"

Usage Examples

use RustQuant::trading::OrderSide;

let buy = OrderSide::BID;
let sell = OrderSide::ASK;

// Logical negation flips the side
assert_eq!(!buy, OrderSide::ASK);
assert_eq!(!sell, OrderSide::BID);

// Display formatting
println!("{}", buy);  // Output: BID (buy)
println!("{}", sell); // Output: ASK (sell)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment