General Observations
The code is still missing the #include <sstream> directive in main.cpp and does not compile for me without it. The file OrderBook.cpp is missing the #include <string> directive and does not compile without it.
To be honest, I don't see a lot of improvement from the original question.
I still think that the enum Side should be a parameter to functions where it is necessary and the templates don't make a lot of sense to me.
I still think that Side is not an appropriate name for the enum.
Include Guards
The header files Order.hpp and OrderBook.hpp do no contain any form of include guards, this leads to multiply defined objects in the code and causes linking errors. By adding include guards to the 2 header files I was able to compile and link without problems.
There are 2 forms of include guards you can use in C++, the older style
#ifndef ORDER_HPP_
#define ORDER_HPP_
struct Order {
int id;
int quantity; // hiddenQuantity needs to be >= peakSize
int peakSize;
int hiddenQuantity;
short price; // we don't really need this, cause price is the index
Order(int id = 0, int quantity = 0, int peakSize = 0, int hiddenQuantity = 0, short price = 0) :
id(id),
quantity(quantity),
peakSize(peakSize),
hiddenQuantity(hiddenQuantity),
price(price) { }
};
#endif // !ORDER_HPP_
Or the newer #pragma once which is not portable to all compilers.
C++ Header Files
There are libraries that provide header.hpp files, but the contention is to use header.h rather than header.hpp.
Constants in C++
There are 3 symbolic constants defined in OrderBook.hpp. These 3 symbolic constants are using the older C programming language method of using macros to define constants. In C++ we prefer to use constexpr or const assignments because they are type safe where the macros are not type safe.
The existing code is
#define BOOK_TOP 32768 // one level above SHRT_MAX
#define BOOK_BOTTOM -1 // one level blow bottom of book
#define BOOK_SIZE 32767 // SHRT_MAX
The suggested code is
constexpr int BOOK_TOP = 32768; // one level above SHRT_MAX
constexpr int BOOK_BOTTOM = -1; // one level blow bottom of book
constexpr int BOOK_SIZE = 32767; // SHRT_MAX
This code should be moved into OrderBook.cpp. The constructor for OrderBook should also be moved into OrderBook.cpp.
Use of the inline Keyword in Declarations
I mentioned this in the review for the previous version of this question, the keyword inline is only a suggestion to the compiler there is no guarantee that the compiler will inline these functions. For better optimization use the compiler optimization switches.