OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Book.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
21#include <string>
22#include <vector>
23#include <unordered_map>
24#include <thread>
25#include <mutex>
26#include <functional>
27
28#include "Order.h"
29#include "Utils.h"
30
31namespace Samples {
32
34class Book
35{
36public:
38 using BookEntries = std::unordered_map<BookEntryId, OrderPtr>;
39 using Id2crossOrderMap = std::unordered_map<BookEntryId, CrossOrderPtr>;
40
42 Order& store(OrderPtr entry);
43 Order& store(OrderPtr entry, BookEntryId id);
44
47
50
53
55 using OrdersList = std::vector<OrderPtr>;
56 OrdersList getEntries(std::function<bool(const Order&)> predicate = [](const Order&){ return true; });
57
58private:
59 using Mutex = std::recursive_mutex;
60 using Guard = std::lock_guard<Mutex>;
61
62 Mutex mutex_;
63 BookEntries entries_;
64 Id2crossOrderMap crossOrders_;
65};
66
67}
Performs automatic acquisition and release of a synchronization object.
Definition Guard.h:30
Order book.
Definition Book.h:35
OptionalRef< CrossOrder > findCross(BookEntryId id)
Finds a cross order.
Definition Book.cpp:86
std::unordered_map< BookEntryId, CrossOrderPtr > Id2crossOrderMap
Definition Book.h:39
OrdersList getEntries(std::function< bool(const Order &)> predicate=[](const Order &){ return true;})
Definition Book.cpp:65
std::unordered_map< BookEntryId, OrderPtr > BookEntries
Definition Book.h:38
Order & store(OrderPtr entry)
Adds an entry to the book.
Definition Book.cpp:23
Order::OrderId BookEntryId
Definition Book.h:37
OptionalRef< Order > find(BookEntryId id)
Finds an instance of the entry by its identifier.
Definition Book.cpp:78
std::vector< OrderPtr > OrdersList
Returns collection of all the entries.
Definition Book.h:55
std::shared_ptr< CrossOrder > CrossOrderPtr
Definition Order.h:104
std::optional< std::shared_ptr< T > > OptionalRef
Manages an optional contained reference.
Definition Utils.h:224
std::shared_ptr< Order > OrderPtr
Definition Order.h:75
2-sides cross order.
Definition Order.h:84
decltype(std::declval< const ExecutionReport_Trade & >().orderId()) OrderId
Definition Order.h:38