Skip to content

Commit 18a66f3

Browse files
author
Sean Collins
committed
Remove code the matching engine made dead
BookSimulator no longer drives anything in production - the feed comes from the matching engine now - so it moves to the test project, where its actual job is to exercise the aggregated books and the feed decoder without dragging in orders or a network. Also drops Order.Priority, which was written on every add and never read (queue position is the list itself), and the domain OrderbookLevelUpdate record, whose last reference went with the simulator rewrite. State that must be maintained and is never consulted is a liability, not a spare part.
1 parent 8062015 commit 18a66f3

4 files changed

Lines changed: 10 additions & 15 deletions

File tree

Common/Matching/LimitOrderBook.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ public void Clear()
224224

225225
_pool.Clear();
226226
_orderPool.Clear();
227-
_priority = 0;
228227
}
229228

230229
// ------------------------------------------------------------------ matching
@@ -325,7 +324,6 @@ private void Rest(ulong orderId, Side side, int price, uint quantity, ICollectio
325324
order.Price = price;
326325
order.Quantity = quantity;
327326
order.Remaining = quantity;
328-
order.Priority = ++_priority;
329327
order.Level = level;
330328

331329
// Joins at the tail: newest order, worst time priority.
@@ -447,6 +445,5 @@ private void Release(OrderLevel level)
447445
private readonly Dictionary<ulong, Order> _orders = new Dictionary<ulong, Order>();
448446
private readonly List<OrderLevel> _pool = new List<OrderLevel>();
449447
private readonly List<Order> _orderPool = new List<Order>();
450-
private ulong _priority;
451448
}
452449
}

Common/Matching/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ public sealed class Order
5252
/// <summary>Unfilled size. Zero means fully executed.</summary>
5353
public uint Remaining;
5454

55-
/// <summary>Sequence in which the order joined its price level; lower is ahead in the queue.</summary>
56-
public ulong Priority;
57-
5855
internal Order Previous;
5956
internal Order Next;
6057
internal OrderLevel Level;

Common/OrderbookLevel.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@ public enum OrderbookUpdateType
1414
Remove,
1515
}
1616
public record OrderbookLevel(int Price, bool IsBuy, uint Quantity);
17-
public record OrderbookLevelUpdate(OrderbookUpdateType UpdateType, OrderbookLevel Level)
18-
{
19-
public static OrderbookLevelUpdate Empty { get; } = new OrderbookLevelUpdate(OrderbookUpdateType.Invalid, null);
20-
}
2117
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
using MarketData.Common.Books;
12
using System;
23
using System.Collections.Generic;
34

4-
namespace MarketData.Common.Books
5+
namespace MarketData.Tests.Framework
56
{
67
public enum MutationKind
78
{
@@ -18,14 +19,18 @@ public readonly record struct Mutation(MutationKind Kind, Side Side, PriceLevel
1819
}
1920

2021
/// <summary>
21-
/// Deterministic random walk of a limit order book.
22+
/// Deterministic random walk over an aggregated book, used as a test fixture.
2223
/// </summary>
2324
/// <remarks>
2425
/// <para>
26+
/// The live feed is produced by the matching engine, not by this. What this is for is
27+
/// exercising the aggregated books and the feed decoder in isolation: it generates a stream of
28+
/// level mutations without dragging in orders, matching or a network, so a test of loss
29+
/// recovery is a test of loss recovery and nothing else.
30+
/// </para>
31+
/// <para>
2532
/// Deliberately free of I/O, timers and threads: given a seed it produces exactly the same
26-
/// sequence of mutations every time. That makes the interesting properties testable without a
27-
/// network - in particular that the incremental stream is a faithful description of the book,
28-
/// which is the one thing a market data feed must never get wrong.
33+
/// sequence of mutations every time.
2934
/// </para>
3035
/// <para>
3136
/// Prices are always derived from the current book, extending outwards from the tail or

0 commit comments

Comments
 (0)