Core API¶
The lumina_lob.core package implements the matching engine and order book.
lumina_lob.core.order
¶
Order data model.
Classes¶
Order
dataclass
¶
Single order in the book.
Source code in lumina_lob/core/order.py
Methods:¶
reduce_qty(new_qty)
¶
Reduce total desired qty. Return amount removed.
Source code in lumina_lob/core/order.py
lumina_lob.core.price_level
¶
Price level: queue of orders at same price using doubly-linked list.
Classes¶
PriceLevel
dataclass
¶
Orders at one price level. FIFO queue via linked list.
Source code in lumina_lob/core/price_level.py
Methods:¶
append(order)
¶
Add order to tail.
Source code in lumina_lob/core/price_level.py
fill(amount)
¶
Fill from front of queue. Return filled amount.
Source code in lumina_lob/core/price_level.py
reduce(order, new_qty)
¶
Reduce order qty at this level. Return removed amount.
remove(order)
¶
Remove order from queue. Return True if found.
Source code in lumina_lob/core/price_level.py
lumina_lob.core.book
¶
Order book with bid/ask price levels.
Classes¶
OrderBook
¶
Price-time priority order book.
Source code in lumina_lob/core/book.py
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
Methods:¶
add(order)
¶
Insert order into book. Market orders are not stored.
Source code in lumina_lob/core/book.py
cancel(order_id)
¶
Cancel resting order. Return True if cancelled.
Source code in lumina_lob/core/book.py
depth(side, n=5)
¶
Return top N price levels and total qty.
Source code in lumina_lob/core/book.py
full_depth(side)
¶
Return all price levels and total qty for a side.
modify(order_id, new_qty)
¶
Reduce resting order to new total qty. Remove if fully filled.
Source code in lumina_lob/core/book.py
to_pandas()
¶
Return book depth as pandas DataFrame with columns [side, price, qty, order_count].
Source code in lumina_lob/core/book.py
lumina_lob.core.matching
¶
Matching engine: price-time priority fills.
Classes¶
MatchingEngine
¶
Match incoming orders against resting liquidity.
Source code in lumina_lob/core/matching.py
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
Methods:¶
process(order)
¶
Route order: match market/limit aggressive, rest passive remainder.
Source code in lumina_lob/core/matching.py
lumina_lob.core.event_log
¶
Nanosecond-precision event journal for order book lifecycle.
Classes¶
Event
dataclass
¶
Single order book event.
Source code in lumina_lob/core/event_log.py
EventLog
¶
Append-only journal of all book events.
Source code in lumina_lob/core/event_log.py
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |