Types
StockMarketABM.Types keeps numerical representations fast and predictable. Constants define the scalar types used across the project, while enumerations capture categorical domains such as order side or time-in-force instructions.
StockMarketABM.Types.Cash — Typeconst Cash = Int64Cash balance measured in the same minimal currency unit as Price. The signed representation allows tracking both assets and liabilities.
StockMarketABM.Types.EventType — Type@enum EventType::UInt8 begin
OrderNew = 1
OrderCancel = 2
OrderExpire = 3
Trade = 4
endClassification for matching-engine events. Distinguishing event types keeps the event log compact and simplifies reporting.
StockMarketABM.Types.Instrument — Typeconst Instrument = SymbolIdentifier of a traded instrument. The code uses Symbol to avoid heap allocations and simplifies comparisons.
StockMarketABM.Types.OrderType — Type@enum OrderType::UInt8 begin
Market = 1
Limit = 2
endType of order submitted to the market. A market order executes immediately at the best available price, while a limit order specifies a price threshold.
StockMarketABM.Types.PositionQty — Typeconst PositionQty = Int64Net position held by an agent. The sign indicates long (positive) or short (negative) exposure.
StockMarketABM.Types.Price — Typeconst Price = Int32Price expressed in the smallest currency unit (for example cents). Using a fixed-width integer keeps arithmetic fast and deterministic.
StockMarketABM.Types.Qty — Typeconst Qty = UInt32Number of instruments in an order or trade. Quantities are non-negative and stored as whole units.
StockMarketABM.Types.Side — Type@enum Side::UInt8 begin
Buy = 1
Sell = 2
endSide of the order or position. The UInt8 backing type keeps the representation compact for storage within larger structs.
StockMarketABM.Types.TIF — Type@enum TIF::UInt8 begin
GTC = 1
IOC = 2
FOK = 3
GTT = 4
endTime-in-force instructions that control order lifetimes:
GTC— Good Till CancelledIOC— Immediate Or CancelFOK— Fill Or KillGTT— Good Till Time (requires explicit expiry)
StockMarketABM.Types.TickSize — Typeconst TickSize = Int32Minimal price increment supported by the market. All limit prices must be expressible as multiples of this value.
StockMarketABM.Types.Time — Typeconst Time = Int64Discrete timestamp used by the simulator to order events. The value represents integer ticks rather than wall-clock time so the unit is project specific.
StockMarketABM.Types.opposite — Methodopposite(side::Side) -> SideReturn the opposing side (Buy -> Sell, Sell -> Buy).
StockMarketABM.Types.side_sign — Methodside_sign(side::Side) -> IntReturn +1 for a buy side and -1 for a sell side. Useful for converting quantities into signed deltas when updating cash or positions.