OnixS C++ CME MDP Conflated UDP Handler 1.1.2
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
30
32
34
36inline
37void
39{
40 throw std::runtime_error
41 (
42 "Threshold for tracking best bids "
43 "or offers can't be a negative value. "
44 );
45}
46
49{
50 // Group which the given set of settings belongs to.
51 const SettingGroup& group_;
52
53 // Actual threshold value.
54 Decimal threshold_;
55
56 // Indicates whether threshold must be used.
57 bool enabled_;
58
59protected:
60
62 friend
64 (
66 );
67
70 const SettingGroup& group() const
71 {
72 return group_;
73 }
74
77 void
79 const BboThreshold& other)
80 {
81 threshold_ = other.threshold_;
82 enabled_ = other.enabled_;
83 }
84
85public:
91 const SettingGroup* group = NULL)
92 : group_(group ? *group : SettingGroup::null())
93 , threshold_(), enabled_(false)
94 {
95 }
96
104 const BboThreshold& other)
105 : group_(
106 SettingGroup::null())
107 , threshold_(
108 other.threshold_)
109 , enabled_(
110 other.enabled_)
111 {
112 }
113
116 {
117 }
118
120 bool
121 enabled() const
122 {
123 return enabled_;
124 }
125
127 void
129 bool value)
130 {
131 group_.
132 controlAssignment
133 (
134 "BBO Threshold Enable",
135 enabled_,
136 value
137 );
138 }
139
141 const
142 Decimal&
143 threshold() const
144 {
145 return threshold_;
146 }
147
150 void
152 const Decimal& value)
153 {
154 if (0 <= value.mantissa())
155 {
156 group_.
157 controlAssignment
158 (
159 "BBO Threshold",
160 threshold_,
161 value
162 );
163 }
164 else
165 {
167 }
168 }
169
175 operator =(
176 const BboThreshold& other)
177 {
178 group_.
179 controlAssignment
180 (
181 "BBO Threshold Settings",
183 *this,
184 other
185 );
186
187 return *this;
188 }
189};
190
193ONIXS_CONFLATEDUDP_EXPORTED
194bool
196 const Decimal&,
197 const Decimal&,
198 const Decimal&);
199
202ONIXS_CONFLATEDUDP_EXPORTED
203bool
205 const Decimal&,
206 Int64,
207 Int64);
208
212{
213 BboThreshold price_;
214 BboThreshold quantity_;
215 BboThreshold numberOfOrders_;
216
217protected:
220 template<class>
221 friend
222 class
224
227 const
229 group() const
230 {
231 return price_.group();
232 }
233
236 void
238 const DirectBboTracking& other)
239 {
240 price_.assignNoControl(other.price_);
241 quantity_.assignNoControl(other.quantity_);
242 numberOfOrders_.assignNoControl(other.numberOfOrders_);
243 }
244
245public:
249 const SettingGroup* group = NULL)
250 : price_(group)
251 , quantity_(group)
252 , numberOfOrders_(group)
253 {
254 }
255
263 const DirectBboTracking& other)
264 : price_(other.price_)
265 , quantity_(other.quantity_)
266 , numberOfOrders_(other.numberOfOrders_)
267 {
268 }
269
272 {
273 }
274
276 const
278 price() const
279 {
280 return price_;
281 }
282
285 {
286 return price_;
287 }
288
290 const
292 quantity() const
293 {
294 return quantity_;
295 }
296
299 {
300 return quantity_;
301 }
302
304 const
307 {
308 return numberOfOrders_;
309 }
310
314 {
315 return numberOfOrders_;
316 }
317
319 bool
320 enabled() const
321 {
322 return (
323 price_.enabled()
324 ||
325 quantity_.enabled()
326 ||
327 numberOfOrders_.enabled()
328 );
329 }
330
332 bool
334 const DirectPriceLevel& previous,
335 const DirectPriceLevel& current) const
336 {
337 return
338 (
339 (price_.enabled() && thresholdExceeded(price_.threshold(), previous.price(), current.price()))
340 ||
341 (quantity_.enabled() && thresholdExceeded(quantity_.threshold(), previous.quantity(), current.quantity()))
342 ||
343 (numberOfOrders_.enabled() && thresholdExceeded( numberOfOrders_.threshold(), previous.numberOfOrders(), current.numberOfOrders()))
344 );
345 }
346
354 operator =(
355 const DirectBboTracking& other)
356 {
357 group().
358 controlAssignment
359 (
360 "Direct BBO Tracking Settings",
362 *this,
363 other
364 );
365
366 return *this;
367 }
368};
369
371ONIXS_CONFLATEDUDP_EXPORTED
372void
374 std::string&,
375 const DirectBboTracking&);
376
378inline
379std::string
381 const DirectBboTracking& tracking)
382{
383 std::string str;
384
385 toStr(str, tracking);
386
387 return str;
388}
389
392template
393<
394 class BboTracking
395>
396class
398{
399 // Indicates whether feature is enabled.
400 bool maintain_;
401
402 // Parameters for tracking.
403 BboTracking bboTracking_;
404
405protected:
408 friend
410 (
412 );
413
416 const
418 group() const
419 {
420 return bboTracking_.group();
421 }
422
425 void
427 const BaseBookManagement& other)
428 {
429 maintain_ =
430 other.maintain_;
431
432 bboTracking_.
434 other.bboTracking_);
435 }
436
437public:
441 const SettingGroup* group = NULL)
442 : maintain_(false), bboTracking_(group)
443 {
444 }
445
453 const BaseBookManagement& other)
454 : maintain_(other.maintain_)
455 , bboTracking_(other.bboTracking_)
456 {
457 }
458
461 {
462 }
463
472 bool
473 maintain() const
474 {
475 return maintain_;
476 }
477
479 void
481 bool value)
482 {
483 group().
484 controlAssignment
485 (
486 "Maintain",
487 maintain_,
488 value
489 );
490 }
491
494 const
495 BboTracking&
497 {
498 return bboTracking_;
499 }
500
503 BboTracking& bboTracking()
504 {
505 return bboTracking_;
506 }
507
515 operator =(
516 const
517 BaseBookManagement& other)
518 {
519 group().
520 controlAssignment
521 (
522 "Base Book Management Settings",
524 *this,
525 other
526 );
527
528 return *this;
529 }
530};
531
534template
535<
536 class BboTracking,
537 typename Depth
538>
539class
541: public BaseBookManagement
542<
543 BboTracking
544>
545{
546 // Lets grouping and value assignment control functioning.
547 friend
549 (
551 );
552
553 // Alias for the base class.
554 typedef
556 <
557 BboTracking
558 >
559 Base;
560
561 //
562
563 Depth defaultDepth_;
564
565 // Re-initializes as a copy of the other instance
566 // without involving value assignment control services.
567 void
568 assignNoControl(
569 const FixedDepthBookManagement& other)
570 {
571 Base::assignNoControl(other);
572
573 defaultDepth_ =
574 other.defaultDepth_;
575 }
576
577public:
581 const SettingGroup* group = NULL,
582 Depth defaultDepth = 0)
583 : Base(group)
584 , defaultDepth_(
586 {
587 }
588
596 const
598 : Base(
599 static_cast
600 <const Base&>
601 (other))
602 , defaultDepth_(
603 other.defaultDepth_)
604 {
605 }
606
611
615 Depth
617 {
618 return defaultDepth_;
619 }
620
624 void
626 Depth value)
627 {
628 this->
629 group().
630 controlAssignment
631 (
632 "Default Depth",
633 defaultDepth_,
634 value
635 );
636 }
637
645 operator =(
646 const
648 {
649 this->
650 group().
651 controlAssignment
652 (
653 "Fixed Depth Book Management Settings",
654 &FixedDepthBookManagement::assignNoControl,
655 *this,
656 other
657 );
658
659 return *this;
660 }
661};
662
688
690ONIXS_CONFLATEDUDP_EXPORTED
691void
693 std::string&,
695
697inline
698std::string
701{
702 std::string str;
703
704 toStr(str, strategy);
705
706 return str;
707}
708
709// Aliases for instantiations.
710
712typedef
713FixedDepthBookManagement
714<
715 DirectBboTracking,
716 MbpBookDepth
717>
719
722BookManagement : public SettingGroup
723{
724 // Lets grouping and value
725 // assignment control functioning.
726 friend
728 (
730 );
731
732 // Subsets of parameters.
733
734 DirectBookManagement directBooks_;
735
736 BookUpdateNotification::Enum updateNotification_;
737
738 // Casts the given instance to an
739 // instance of SettingGroup class.
740 const
741 SettingGroup&
742 group() const
743 {
744 return *this;
745 }
746
747 // Re-initializes the given instance
748 // as a copy of the other one without
749 // involving assignment control service.
750 void
751 assignNoControl(
752 const BookManagement& other)
753 {
754 directBooks_.
755 assignNoControl(
756 other.directBooks_);
757
758 updateNotification_ =
759 other.updateNotification_;
760 }
761
762public:
766 controller = NULL)
767 : SettingGroup(controller)
768 , directBooks_(&group(), 10)
769 , updateNotification_(
771 OnEndOfEvent)
772 {
773 }
774
782 const BookManagement& other)
783 : SettingGroup()
784 , directBooks_(
785 other.directBooks_)
786 , updateNotification_(
787 other.updateNotification_)
788 {
789 }
790
791 // Finalizes the instance.
793 {
794 }
795
797 const
800 {
801 return directBooks_;
802 }
803
807 {
808 return directBooks_;
809 }
810
816 {
817 return updateNotification_;
818 }
819
821 void
824 {
825 group().
827 (
828 "Update Notification",
829 updateNotification_,
830 value
831 );
832 }
833
839 operator =(
840 const BookManagement& other)
841 {
842 group().
844 (
845 "Book Management Settings",
846 &BookManagement::assignNoControl,
847 *this,
848 other
849 );
850
851 return *this;
852 }
853};
854
856ONIXS_CONFLATEDUDP_EXPORTED
857void
859 std::string&,
860 const BookManagement&);
861
863inline
864std::string
866 const BookManagement& settings)
867{
868 std::string str;
869
870 toStr(str, settings);
871
872 return str;
873}
874
#define ONIXS_CONFLATEDUDP_LTWT_STRUCT
Definition Bootstrap.h:99
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition Bootstrap.h:95
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition Bootstrap.h:157
#define ONIXS_CONFLATEDUDP_LTWT_CLASS_DECL(name)
Definition Bootstrap.h:107
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition Bootstrap.h:153
BaseBookManagement(const BaseBookManagement &other)
void maintain(bool value)
Forces Handler to maintain order books.
BaseBookManagement(const SettingGroup *group=NULL)
void assignNoControl(const BaseBookManagement &other)
Defines tracking attributes for a particular BBO parameter.
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.
void threshold(const Decimal &value)
void assignNoControl(const BboThreshold &other)
void enabled(bool value)
Indicates whether tracking is enabled.
BboThreshold(const SettingGroup *group=NULL)
bool enabled() const
Indicates whether tracking is enabled.
Parameters affecting book management machinery.
const DirectBookManagement & directBooks() const
Management and tracking parameters for direct books.
void updateNotification(BookUpdateNotification::Enum value)
Defines the way Handler raises order book update event.
BookManagement(const BookManagement &other)
BookUpdateNotification::Enum updateNotification() const
DirectBookManagement & directBooks()
Management and tracking parameters for direct books.
BookManagement(SettingAssignController *controller=NULL)
Initializes instance with default values.
A real number with floating exponent.
Definition Decimal.h:232
Defines tracking for BBO in direct books.
const BboThreshold & price() const
Price tracking attributes.
const BboThreshold & numberOfOrders() const
Tracking for order quantity.
const BboThreshold & quantity() const
Quantity tracking attributes.
BboThreshold & quantity()
Quantity tracking attributes.
void assignNoControl(const DirectBboTracking &other)
DirectBboTracking(const SettingGroup *group=NULL)
DirectBboTracking(const DirectBboTracking &other)
bool exceeded(const DirectPriceLevel &previous, const DirectPriceLevel &current) const
Checks whether any of thresholds is exceeded.
BboThreshold & price()
Price tracking attributes.
bool enabled() const
Indicates whether tracking enabled at all.
BboThreshold & numberOfOrders()
Tracking for order quantity.
Encapsulates price level concept.
Int64 quantity() const
Quantify for the given price.
Int32 & numberOfOrders()
Updates total number of orders.
FixedDepthBookManagement(const FixedDepthBookManagement &other)
FixedDepthBookManagement(const SettingGroup *group=NULL, Depth defaultDepth=0)
Base services for settings grouped by a certain criteria.
void controlAssignment(const Char *description, Assignee &assignee, Value value) const
FixedDepthBookManagement< DirectBboTracking, MbpBookDepth > DirectBookManagement
Management and tracking parameters for direct books.
ONIXS_CONFLATEDUDP_EXPORTED void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
UInt32 UInt32
uInt32.
Definition Fields.h:261
void throwBadBboThreshold()
Raises exception on invalid best bid/offer threshold value.
ONIXS_CONFLATEDUDP_EXPORTED bool thresholdExceeded(const Decimal &, const Decimal &, const Decimal &)
Defines book update notification strategies.