OnixS C++ CME MDP Premium Market Data Handler 5.9.0
Users' manual and API documentation
Loading...
Searching...
No Matches
BookManagement.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <string>
24
26
28
31
33
35
38{
39 throw std::runtime_error("Threshold for tracking best bids "
40 "or offers can't be a negative value. ");
41}
42
45{
46public:
52 : group_(group ? *group : SettingGroup::null())
53 , threshold_()
54 , enabled_(false)
55 {
56 }
57
65 : group_(SettingGroup::null())
66 , threshold_(other.threshold_)
67 , enabled_(other.enabled_)
68 {
69 }
70
73
75 bool enabled() const
76 {
77 return enabled_;
78 }
79
81 BboThreshold& enabled(bool value)
82 {
83 group_.controlAssignment("BBO Threshold Enable", enabled_, value);
84
85 return *this;
86 }
87
89 const Decimal& threshold() const
90 {
91 return threshold_;
92 }
93
97 {
98 if (0 <= value.mantissa())
99 {
100 group_.controlAssignment("BBO Threshold", threshold_, value);
101 }
102 else
103 {
105 }
106
107 return *this;
108 }
109
115 {
116 group_.controlChange("BBO Threshold Settings", &BboThreshold::assignNoControl, *this, other);
117
118 return *this;
119 }
120
121protected:
124
127
130
133 const SettingGroup& group() const
134 {
135 return group_;
136 }
137
140 void assignNoControl(const BboThreshold& other)
141 {
142 threshold_ = other.threshold_;
143 enabled_ = other.enabled_;
144 }
145
146private:
147 // Group which the given set of settings belongs to.
148 const SettingGroup& group_;
149
150 // Actual threshold value.
151 Decimal threshold_;
152
153 // Indicates whether threshold must be used.
154 bool enabled_;
155};
156
160bool thresholdExceeded(const Decimal&, const Decimal&, const Decimal&);
161
165bool thresholdExceeded(const Decimal&, Int64, Int64);
166
169{
170public:
174 : price_(group)
175 {
176 }
177
183 : price_(other.price_)
184 {
185 }
186
189
191 const BboThreshold& price() const
192 {
193 return price_;
194 }
195
198 {
199 return price_;
200 }
201
203 bool enabled() const
204 {
205 return (price_.enabled());
206 }
207
209 bool exceeded(const Order& previous, const Order& current) const
210 {
211 return (price_.enabled() && thresholdExceeded(price_.threshold(), previous.price(), current.price()));
212 }
213
217 {
218 group().controlChange("MBO BBO Tracking Settings", &MboBboTracking::assignNoControl, *this, other);
219
220 return *this;
221 }
222
223protected:
225 template <class>
226 friend class BaseBookManagement;
227
230 const SettingGroup& group() const
231 {
232 return price_.group();
233 }
234
238 {
239 price_.assignNoControl(other.price_);
240 }
241
242private:
243 BboThreshold price_;
244};
245
248void toStr(std::string&, const MboBboTracking&);
249
251inline std::string toStr(const MboBboTracking& tracking)
252{
253 std::string str;
254
255 toStr(str, tracking);
256
257 return str;
258}
259
262{
263public:
267 : price_(group)
268 , quantity_(group)
269 {
270 }
271
279 : price_(other.price_)
280 , quantity_(other.quantity_)
281 {
282 }
283
286
288 const BboThreshold& price() const
289 {
290 return price_;
291 }
292
295 {
296 return price_;
297 }
298
300 const BboThreshold& quantity() const
301 {
302 return quantity_;
303 }
304
307 {
308 return quantity_;
309 }
310
312 bool enabled() const
313 {
314 return (price_.enabled() || quantity_.enabled());
315 }
316
318 bool exceeded(const ImpliedPriceLevel& previous, const ImpliedPriceLevel& current) const
319 {
320 return (
321 (price_.enabled() && thresholdExceeded(price_.threshold(), previous.price(), current.price()))
322 || (quantity_.enabled() && thresholdExceeded(quantity_.threshold(), previous.quantity(), current.quantity())
323 )
324 );
325 }
326
334 {
335 group().controlChange("Implied BBO Tracking Settings", &ImpliedBboTracking::assignNoControl, *this, other);
336
337 return *this;
338 }
339
340protected:
342 template <class>
343 friend class BaseBookManagement;
344
347 const SettingGroup& group() const
348 {
349 return price_.group();
350 }
351
355 {
356 price_.assignNoControl(other.price_);
357 quantity_.assignNoControl(other.quantity_);
358 }
359
360private:
361 BboThreshold price_;
362 BboThreshold quantity_;
363};
364
367void toStr(std::string&, const ImpliedBboTracking&);
368
370inline std::string toStr(const ImpliedBboTracking& tracking)
371{
372 std::string str;
373
374 toStr(str, tracking);
375
376 return str;
377}
378
381{
382public:
387 , numberOfOrders_(group)
388 {
389 }
390
398 : ImpliedBboTracking(static_cast<const ImpliedBboTracking&>(other))
399 , numberOfOrders_(other.numberOfOrders_)
400 {
401 }
402
405
408 {
409 return numberOfOrders_;
410 }
411
414 {
415 return numberOfOrders_;
416 }
417
419 bool enabled() const
420 {
421 return (ImpliedBboTracking::enabled() || numberOfOrders_.enabled());
422 }
423
425 bool exceeded(const DirectPriceLevel& previous, const DirectPriceLevel& current) const
426 {
427 return (
428 ImpliedBboTracking::exceeded(previous, current)
429 || (numberOfOrders_.enabled()
430 && thresholdExceeded(numberOfOrders_.threshold(), previous.numberOfOrders(), current.numberOfOrders()))
431 );
432 }
433
441 {
442 group().controlChange("Direct BBO Tracking Settings", &DirectBboTracking::assignNoControl, *this, other);
443
444 return *this;
445 }
446
447protected:
450 template <class>
451 friend class BaseBookManagement;
452
456 {
458
459 numberOfOrders_.assignNoControl(other.numberOfOrders_);
460 }
461
462private:
463 BboThreshold numberOfOrders_;
464};
465
468void toStr(std::string&, const DirectBboTracking&);
469
471inline std::string toStr(const DirectBboTracking& tracking)
472{
473 std::string str;
474
475 toStr(str, tracking);
476
477 return str;
478}
479
482template <class BboTracking>
484{
485public:
489 : maintain_(false)
490 , bboTracking_(group)
491 {
492 }
493
501 : maintain_(other.maintain_)
502 , bboTracking_(other.bboTracking_)
503 {
504 }
505
508
517 bool maintain() const
518 {
519 return maintain_;
520 }
521
524 {
525 group().controlAssignment("Maintain", maintain_, value);
526
527 return *this;
528 }
529
532 const BboTracking& bboTracking() const
533 {
534 return bboTracking_;
535 }
536
539 BboTracking& bboTracking()
540 {
541 return bboTracking_;
542 }
543
551 {
552 group().controlChange("Base Book Management Settings", &BaseBookManagement::assignNoControl, *this, other);
553
554 return *this;
555 }
556
557protected:
561
564 const SettingGroup& group() const
565 {
566 return bboTracking_.group();
567 }
568
572 {
573 maintain_ = other.maintain_;
574
575 bboTracking_.assignNoControl(other.bboTracking_);
576 }
577
578private:
579 // Indicates whether feature is enabled.
580 bool maintain_;
581
582 // Parameters for tracking.
583 BboTracking bboTracking_;
584};
585
588template <class BboTracking, typename Depth>
590{
591public:
595 : Base(group)
596 , defaultDepth_(defaultDepth)
597 {
598 }
599
607 : Base(static_cast<const Base&>(other))
608 , defaultDepth_(other.defaultDepth_)
609 {
610 }
611
614
618 Depth defaultDepth() const
619 {
620 return defaultDepth_;
621 }
622
627 {
628 this->group().controlAssignment("Default Depth", defaultDepth_, value);
629
630 return *this;
631 }
632
640 {
641 this->group().controlChange(
642 "Fixed Depth Book Management Settings", &FixedDepthBookManagement::assignNoControl, *this, other
643 );
644
645 return *this;
646 }
647
648private:
649 // Lets grouping and value assignment control functioning.
651
652 // Alias for the base class.
654
655 //
656
657 Depth defaultDepth_;
658
659 // Re-initializes as a copy of the other instance
660 // without involving value assignment control services.
661 void assignNoControl(const FixedDepthBookManagement& other)
662 {
663 Base::assignNoControl(other);
664
665 defaultDepth_ = other.defaultDepth_;
666 }
667};
668
671template <class BboTracking, typename Depth>
673{
674public:
681
689 : Base(static_cast<const Base&>(other))
690 {
691 }
692
700 {
701 this->group().controlChange(
702 "Any Depth Book Management Settings", &AnyDepthBookManagement::assignNoControl, *this, other
703 );
704
705 return *this;
706 }
707
708private:
709 // Lets grouping and value assignment control functioning.
711
712 // Alias for the base class.
714
715 Depth reserved_;
716
717 // Re-initializes as a copy of the other instance
718 // without involving value assignment control services.
719 void assignNoControl(const AnyDepthBookManagement& other)
720 {
721 Base::assignNoControl(other);
722 }
723};
724
752
756
758inline std::string toStr(BookUpdateNotification::Enum strategy)
759{
760 std::string str;
761
762 toStr(str, strategy);
763
764 return str;
765}
766
767// Aliases for instantiations.
768
771
774
777
780
783{
784public:
787 : SettingGroup(controller)
788 , mboBooks_(&group())
789 , directBooks_(&group(), 10)
790 , impliedBooks_(&group(), 2)
791 , updateNotification_(BookUpdateNotification::OnEndOfEvent)
792 {
793 }
794
802 : SettingGroup()
803 , mboBooks_(other.mboBooks_)
804 , directBooks_(other.directBooks_)
805 , impliedBooks_(other.impliedBooks_)
806 , consolidatedBooks_(other.consolidatedBooks_)
807 , updateNotification_(other.updateNotification_)
808 {
809 }
810
811 // Finalizes the instance.
813
816 {
817 return mboBooks_;
818 }
819
822 {
823 return mboBooks_;
824 }
825
828 {
829 return directBooks_;
830 }
831
834 {
835 return directBooks_;
836 }
837
840 {
841 return impliedBooks_;
842 }
843
846 {
847 return impliedBooks_;
848 }
849
852 {
853 return consolidatedBooks_;
854 }
855
858 {
859 return consolidatedBooks_;
860 }
861
866 {
867 return updateNotification_;
868 }
869
872 {
873 group().controlAssignment("Update Notification", updateNotification_, value);
874
875 return *this;
876 }
877
883 {
884 group().controlChange("Book Management Settings", &BookManagement::assignNoControl, *this, other);
885
886 return *this;
887 }
888
889private:
890 // Lets grouping and value
891 // assignment control functioning.
893
894 // Subsets of parameters.
895
896 MboBookManagement mboBooks_;
897
898 DirectBookManagement directBooks_;
899 ImpliedBookManagement impliedBooks_;
900
901 ConsolidatedBookManagement consolidatedBooks_;
902
903 BookUpdateNotification::Enum updateNotification_;
904
905 // Casts the given instance to an
906 // instance of SettingGroup class.
907 const SettingGroup& group() const
908 {
909 return *this;
910 }
911
912 // Re-initializes the given instance
913 // as a copy of the other one without
914 // involving assignment control service.
915 void assignNoControl(const BookManagement& other)
916 {
917 mboBooks_.assignNoControl(other.mboBooks_);
918
919 directBooks_.assignNoControl(other.directBooks_);
920
921 impliedBooks_.assignNoControl(other.impliedBooks_);
922
923 consolidatedBooks_.assignNoControl(other.consolidatedBooks_);
924
925 updateNotification_ = other.updateNotification_;
926 }
927};
928
931void toStr(std::string&, const BookManagement&);
932
934inline std::string toStr(const BookManagement& settings)
935{
936 std::string str;
937
938 toStr(str, settings);
939
940 return str;
941}
942
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition Bootstrap.h:48
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_NULLPTR
Definition Compiler.h:178
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
AnyDepthBookManagement(const SettingGroup *group=nullptr)
AnyDepthBookManagement(const AnyDepthBookManagement &other)
AnyDepthBookManagement & operator=(const AnyDepthBookManagement &other)
BaseBookManagement(const SettingGroup *group=nullptr)
BaseBookManagement(const BaseBookManagement &other)
const BboTracking & bboTracking() const
~BaseBookManagement()
Finalizes the instance.
BaseBookManagement & maintain(bool value)
Forces Handler to maintain order books.
BaseBookManagement & operator=(const BaseBookManagement &other)
void assignNoControl(const BaseBookManagement &other)
Defines tracking attributes for a particular BBO parameter.
BboThreshold & threshold(const Decimal &value)
const Decimal & threshold() const
Threshold for the parameter being tracked.
BboThreshold(const BboThreshold &other)
const SettingGroup & group() const
friend class DirectBboTracking
Lets grouping and value assignment control functioning.
BboThreshold & operator=(const BboThreshold &other)
friend class ImpliedBboTracking
Lets grouping and value assignment control functioning.
void assignNoControl(const BboThreshold &other)
friend class MboBboTracking
Lets grouping and value assignment control functioning.
~BboThreshold()
Finalizes the group.
BboThreshold(const SettingGroup *group=nullptr)
BboThreshold & enabled(bool value)
Indicates whether tracking is enabled.
bool enabled() const
Indicates whether tracking is enabled.
Parameters affecting book management machinery.
MboBookManagement & mboBooks()
Management and tracking parameters for direct books.
ImpliedBookManagement & impliedBooks()
Management and tracking parameters for implied books.
BookManagement & updateNotification(BookUpdateNotification::Enum value)
Defines the way Handler raises order book update event.
ConsolidatedBookManagement & consolidatedBooks()
Management and tracking parameters for consolidated books.
const DirectBookManagement & directBooks() const
Management and tracking parameters for direct books.
BookManagement(const BookManagement &other)
BookUpdateNotification::Enum updateNotification() const
const ConsolidatedBookManagement & consolidatedBooks() const
Management and tracking parameters for consolidated books.
DirectBookManagement & directBooks()
Management and tracking parameters for direct books.
const MboBookManagement & mboBooks() const
Management and tracking parameters for direct books.
BookManagement(SettingChangeController *controller=nullptr)
Initializes instance with default values.
const ImpliedBookManagement & impliedBooks() const
Management and tracking parameters for implied books.
BookManagement & operator=(const BookManagement &other)
A real number with floating exponent.
Definition Decimal.h:137
Defines tracking for BBO in direct books.
const BboThreshold & numberOfOrders() const
Tracking for order quantity.
void assignNoControl(const DirectBboTracking &other)
DirectBboTracking(const DirectBboTracking &other)
bool exceeded(const DirectPriceLevel &previous, const DirectPriceLevel &current) const
Checks whether any of thresholds is exceeded.
DirectBboTracking(const SettingGroup *group=nullptr)
DirectBboTracking & operator=(const DirectBboTracking &other)
~DirectBboTracking()
Finalizes the instance.
bool enabled() const
Indicates whether tracking enabled at all.
BboThreshold & numberOfOrders()
Tracking for order quantity.
Encapsulates price level concept.
Int32 & numberOfOrders()
Updates total number of orders.
~FixedDepthBookManagement()
Finalizes the instance.
FixedDepthBookManagement(const SettingGroup *group=nullptr, Depth defaultDepth=0)
FixedDepthBookManagement(const FixedDepthBookManagement &other)
FixedDepthBookManagement & defaultDepth(Depth value)
FixedDepthBookManagement & operator=(const FixedDepthBookManagement &other)
Defines tracking for BBO in implied books.
ImpliedBboTracking(const ImpliedBboTracking &other)
friend class BaseBookManagement
Lets grouping and value assignment control functioning.
const BboThreshold & price() const
Price tracking attributes.
void assignNoControl(const ImpliedBboTracking &other)
const SettingGroup & group() const
const BboThreshold & quantity() const
Quantity tracking attributes.
bool exceeded(const ImpliedPriceLevel &previous, const ImpliedPriceLevel &current) const
Checks whether any of thresholds is exceeded.
BboThreshold & quantity()
Quantity tracking attributes.
~ImpliedBboTracking()
Finalizes the instance.
BboThreshold & price()
Price tracking attributes.
ImpliedBboTracking(const SettingGroup *group=nullptr)
ImpliedBboTracking & operator=(const ImpliedBboTracking &other)
bool enabled() const
Indicates whether tracking enabled at all.
Encapsulates price level concept.
MbpBookQuantity quantity() const
Quantity for the given price.
Defines tracking for BBO in MBO books.
friend class BaseBookManagement
Lets grouping and value assignment control functioning.
const BboThreshold & price() const
Price tracking attributes.
void assignNoControl(const MboBboTracking &other)
MboBboTracking & operator=(const MboBboTracking &other)
~MboBboTracking()
Finalizes the instance.
const SettingGroup & group() const
MboBboTracking(const SettingGroup *group=nullptr)
bool exceeded(const Order &previous, const Order &current) const
Checks whether any of thresholds is exceeded.
BboThreshold & price()
Price tracking attributes.
MboBboTracking(const MboBboTracking &other)
bool enabled() const
Indicates whether tracking enabled at all.
Order as the member of the Market By Order (MBO) book.
Definition Order.h:73
const Decimal & price() const
Order price.
Definition Order.h:118
Base services for settings grouped by a certain criteria.
void controlAssignment(const Char *description, Assignee &assignee, Value value) const
SettingGroup(SettingChangeController *controller=nullptr)
void controlChange(const Char *description, void(Changeable::*change)(), Changeable &changeable) const
FixedDepthBookManagement< ImpliedBboTracking, MbpBookDepth > ImpliedBookManagement
Management and tracking parameters for implied books.
bool thresholdExceeded(const Decimal &, const Decimal &, const Decimal &)
BaseBookManagement< ImpliedBboTracking > ConsolidatedBookManagement
Management and tracking parameters for consolidated books.
FixedDepthBookManagement< DirectBboTracking, MbpBookDepth > DirectBookManagement
Management and tracking parameters for direct books.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
UInt32 UInt32
uInt32.
Definition Fields.h:202
AnyDepthBookManagement< MboBboTracking, SortedOrders::size_type > MboBookManagement
Management and tracking parameters for MBO books.
void throwBadBboThreshold()
Raises exception on invalid best bid/offer threshold value.
Defines book update notification strategies.