File size: 2,431 Bytes
e418f71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <cstdint>
#include <cstddef>
#include <vector>
#include <limits>
#include <string>

// ─── Primitive Types ───────────────────────────────────────────────────────────
using Price    = std::int32_t;   // Fixed-point: actual / 100 (e.g. 10050 = $100.50)
using Quantity = std::uint32_t;
using OrderId  = std::uint64_t;
using OrderIds = std::vector<OrderId>;

// ─── Constants ─────────────────────────────────────────────────────────────────
struct Constants {
    static constexpr Price    InvalidPrice    = std::numeric_limits<Price>::min();
    static constexpr Quantity InvalidQuantity = std::numeric_limits<Quantity>::max();
    static constexpr OrderId  InvalidOrderId  = 0;
};

// ─── Enums ─────────────────────────────────────────────────────────────────────
enum class Side : uint8_t { Buy = 0, Sell = 1 };

enum class OrderType : uint8_t {
    GoodTillCancel = 0,
    FillAndKill    = 1,
    FillOrKill     = 2,
    GoodForDay     = 3,
    Market         = 4,
    ImmediateOrCancel = 5,  // NEW: alias for FAK used in HFT
    PostOnly       = 6,     // NEW: maker-only, reject if would cross
    StopLimit      = 7,     // NEW: stop-limit order
    Iceberg        = 8,     // NEW: show only peak quantity
};

enum class OrderStatus : uint8_t {
    New,
    PartiallyFilled,
    Filled,
    Cancelled,
    Rejected,
    Pending,
};

// ─── Trade Info ─────────────────────────────────────────────────────────────────
struct TradeInfo {
    OrderId  orderId;
    Price    price;
    Quantity quantity;
};

// ─── Level Info ─────────────────────────────────────────────────────────────────
struct LevelInfo {
    Price    price;
    Quantity quantity;
    uint32_t orderCount;
};

using LevelInfos = std::vector<LevelInfo>;

;