dxFeed Graal CXX API v4.2.0
Loading...
Searching...
No Matches
DXFeedSubscription.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../internal/Conf.hpp"
7#include "osub/ObservableSubscription.hpp"
8
10
11#include "../internal/EventClassList.hpp"
12#include "../internal/context/ApiContext.hpp"
13
14#include "../entity/EntityModule.hpp"
15#include "../event/EventType.hpp"
16#include "../event/EventTypeEnum.hpp"
17#include "../internal/Common.hpp"
18#include "../internal/Handler.hpp"
19#include "../internal/JavaObjectHandle.hpp"
20#include "../symbols/SymbolWrapper.hpp"
21
22#include "../util/TimePeriod.hpp"
23
24#include <concepts>
25#include <memory>
26#include <type_traits>
27#include <unordered_set>
28
30
31struct DXFeed;
32struct MarketEvent;
33struct IndexedEvent;
34struct TimeSeriesEvent;
35struct LastingEvent;
36
37/**
38 * Subscription for a set of symbols and event types.
39 */
41 public:
42 static constexpr std::size_t FAKE_CHANGE_LISTENER_ID{static_cast<std::size_t>(-1)};
43
44 ///
45 using OnEventHandler = SimpleHandler<void(const std::vector<std::shared_ptr<EventType>> &)>;
46
47 // These constants are linked with same ones in RecordBuffer - POOLED_CAPACITY and UNLIMITED_CAPACITY.
48 /**
49 * The optimal events' batch limit for single notification in OnEventHandler.
50 */
51 static const std::int32_t OPTIMAL_BATCH_LIMIT = 0;
52
53 /**
54 * The maximum events' batch limit for single notification in OnEventHandler.
55 */
56 static const std::int32_t MAX_BATCH_LIMIT = std::numeric_limits<std::int32_t>::max();
57
58 protected:
59 friend struct DXFeed;
60
61 inline static std::atomic<std::size_t> lastChangeListenerId_{};
62
63 struct Impl;
64
65 std::unique_ptr<Impl> impl_;
66
67 std::unordered_set<EventTypeEnum> eventTypes_;
68 JavaObjectHandle<DXFeedSubscription> handle_;
69
70 std::mutex eventListenerMutex_{};
71 JavaObjectHandle<DXFeedEventListener> eventListenerHandle_;
72 OnEventHandler onEvent_{};
73 std::unordered_map<std::size_t, std::shared_ptr<ObservableSubscriptionChangeListener>> changeListeners_;
74 std::recursive_mutex changeListenersMutex_{};
75
76 static JavaObjectHandle<DXFeedSubscription>
77 createSubscriptionHandleFromEventClassList(const std::unique_ptr<EventClassList> &list);
78
79 void setEventListenerHandle(Id<DXFeedSubscription> id);
80
81 bool tryToSetEventListenerHandle();
82
83 void setSymbolsImpl(void *graalSymbolList) const;
84 void addSymbolsImpl(void *graalSymbolList) const;
85 void removeSymbolsImpl(void *graalSymbolList) const;
86
87 DXFeedSubscription();
88
89 DXFeedSubscription(const EventTypeEnum &eventType);
90
91 DXFeedSubscription(const EventTypeEnum &eventType, JavaObjectHandle<DXFeedSubscription> &&handle);
92
93 template <typename EventTypeIt>
94#if __cpp_concepts
95 requires requires(EventTypeIt iter) {
96 { *iter } -> dxfcpp::ConvertibleTo<EventTypeEnum>;
97 }
98#endif
99 DXFeedSubscription(EventTypeIt begin, EventTypeIt end) : DXFeedSubscription() {
100 if constexpr (Debugger::isDebug) {
101 // ReSharper disable once CppDFAUnreachableCode
102 Debugger::debug("DXFeedSubscription(eventTypes = " + namesToString(begin, end) + ")");
103 }
104
105 eventTypes_ = std::unordered_set<EventTypeEnum>{begin, end};
106
107 auto list = EventClassList::create(eventTypes_.begin(), eventTypes_.end());
108
109 handle_ = createSubscriptionHandleFromEventClassList(list);
110 }
111
112 template <typename EventTypeIt>
113#if __cpp_concepts
114 requires requires(EventTypeIt iter) {
115 { *iter } -> dxfcpp::ConvertibleTo<EventTypeEnum>;
116 }
117#endif
118 DXFeedSubscription(EventTypeIt begin, EventTypeIt end, JavaObjectHandle<DXFeedSubscription> &&handle)
120 if constexpr (Debugger::isDebug) {
121 // ReSharper disable once CppDFAUnreachableCode
122 Debugger::debug("DXFeedSubscription(eventTypes = " + namesToString(begin, end) + ")");
123 }
124
125 eventTypes_ = std::unordered_set<EventTypeEnum>{begin, end};
126 handle_ = std::move(handle);
127 }
128
129 public:
130 /// The alias to a type of shared pointer to the DXFeedSubscription object
131 using Ptr = std::shared_ptr<DXFeedSubscription>;
132
133 /// The alias to a type of unique pointer to the DXFeedSubscription object
135
136 DXFeedSubscription(LockExternalConstructionTag);
137
138 DXFeedSubscription(LockExternalConstructionTag, const EventTypeEnum &eventType);
139
140 template <typename EventTypeIt>
141#if __cpp_concepts
142 requires requires(EventTypeIt iter) {
143 { *iter } -> dxfcpp::ConvertibleTo<EventTypeEnum>;
144 }
145#endif
146 DXFeedSubscription(LockExternalConstructionTag, EventTypeIt begin, EventTypeIt end)
147 : DXFeedSubscription(begin, end) {
148 }
149
150 DXFeedSubscription(LockExternalConstructionTag tag, std::initializer_list<EventTypeEnum> eventTypes)
151 : DXFeedSubscription(tag, eventTypes.begin(), eventTypes.end()) {
152 }
153
154 template <typename EventTypesCollection>
155 explicit DXFeedSubscription(LockExternalConstructionTag tag, EventTypesCollection &&eventTypes)
156#if __cpp_concepts
157 requires requires {
158 {
159 DXFeedSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
160 std::end(std::forward<EventTypesCollection>(eventTypes)))
161 };
162 }
163#endif
164 : DXFeedSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
165 std::end(std::forward<EventTypesCollection>(eventTypes))) {
166 }
167
168 ///
169 std::string toString() const override;
170
171 ~DXFeedSubscription() override;
172
173 /**
174 * Creates <i>detached</i> subscription for a single event type.
175 *
176 * Example:
177 * ```cpp
178 * auto sub = dxfcpp::DXFeedSubscription::create(dxfcpp::Quote::TYPE);
179 * ```
180 *
181 * @param eventType the event type.
182 */
183 static std::shared_ptr<DXFeedSubscription> create(const EventTypeEnum &eventType);
184
185 /**
186 * Creates <i>detached</i> subscription for the given collection of event types.
187 *
188 * Example:
189 * ```cpp
190 * auto eventTypes = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
191 *
192 * auto sub = dxfcpp::DXFeedSubscription::create(eventTypes.begin(), eventTypes.end());
193 * ```
194 *
195 * ```cpp
196 * std::vector types{dxfcpp::Quote::TYPE, dxfcpp::Trade::TYPE, dxfcpp::Summary::TYPE};
197 *
198 * auto sub = dxfcpp::DXFeedSubscription::create(types.begin(), types.end());
199 * ```
200 *
201 * @tparam EventTypeIt The collection's iterator type
202 * @param begin The beginning of the collection of event types.
203 * @param end The end of event type collection.
204 * @return The new <i>detached</i> subscription for the given collection of event types.
205 */
206 template <typename EventTypeIt>
207#if __cpp_concepts
210 }
211#endif
212 static std::shared_ptr<DXFeedSubscription> create(EventTypeIt begin, EventTypeIt end) {
213 if constexpr (Debugger::isDebug) {
214 // ReSharper disable once CppDFAUnreachableCode
215 Debugger::debug("DXFeedSubscription::create(eventTypes = " + namesToString(begin, end) + ")");
216 }
217
218 auto sub = createShared(begin, end);
219 auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);
220
221 dxfcpp::ignoreUnused(id);
222
223 return sub;
224 }
225
226 /**
227 * Creates <i>detached</i> subscription for the given collection of event types.
228 *
229 * Example:
230 * ```cpp
231 * auto sub = dxfcpp::DXFeedSubscription::create({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
232 * ```
233 *
234 * @param eventTypes The event type collection.
235 * @return The new <i>detached</i> subscription for the given collection of event types.
236 */
237 static std::shared_ptr<DXFeedSubscription> create(std::initializer_list<EventTypeEnum> eventTypes);
238
239 /**
240 * Creates <i>detached</i> subscription for the given collection of event types.
241 *
242 * Example:
243 * ```cpp
244 * auto sub = dxfcpp::DXFeedSubscription::create(std::unordered_set{dxfcpp::Quote::TYPE,
245 * dxfcpp::TimeAndSale::TYPE});
246 * ```
247 *
248 * ```cpp
249 * std::vector types = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
250 * auto sub = dxfcpp::DXFeedSubscription::create(types);
251 * ```
252 *
253 * @tparam EventTypesCollection The type of the collection of event types
254 * @param eventTypes The event type collection.
255 * @return The new <i>detached</i> subscription for the given collection of event types.
256 */
257 template <typename EventTypesCollection>
258 static std::shared_ptr<DXFeedSubscription> create(EventTypesCollection &&eventTypes) {
259 auto sub = createShared(std::forward<EventTypesCollection>(eventTypes));
260 auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);
261
262 dxfcpp::ignoreUnused(id);
263
264 return sub;
265 }
266
267 /**
268 * Attaches subscription to the specified feed.
269 *
270 * @param feed The feed to attach to.
271 */
272 void attach(std::shared_ptr<DXFeed> feed);
273
274 /**
275 * Detaches subscription from the specified feed.
276 *
277 * @param feed The feed to detach from.
278 */
279 void detach(std::shared_ptr<DXFeed> feed);
280
281 /**
282 * Returns `true` if this subscription is closed.
283 *
284 * @return `true` if this subscription is closed.
285 *
286 * @see DXFeedSubscription::close()
287 */
288 bool isClosed() override;
289
290 /**
291 * Closes this subscription and makes it <i>permanently detached</i>.
292 * This method notifies all installed instances of subscription change listeners by invoking `subscriptionClosed`
293 * while holding the lock for this subscription. This method clears lists of all installed
294 * event listeners and subscription change listeners and makes sure that no more listeners
295 * can be added.
296 */
297 void close() const;
298
299 /**
300 * Returns a set of subscribed event types.
301 *
302 * @return A set of subscribed event types.
303 */
305
306 /**
307 * Returns `true` if this subscription contains the corresponding event type.
308 *
309 * @param eventType The type of event that is checked.
310 * @return `true` if this subscription contains the corresponding event type.
311 *
312 * @see DXFeedSubscription::getEventTypes()
313 */
314 bool containsEventType(const EventTypeEnum &eventType) override;
315
316 /**
317 * Clears the set of subscribed symbols.
318 */
319 void clear() const;
320
321 /**
322 * Returns a set of subscribed symbols (depending on the actual implementation of subscription).
323 *
324 * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a
325 * weakly consistent view of the set.
326 *
327 * @return A set of subscribed symbols.
328 */
330
331 /**
332 * Returns a set of decorated symbols (depending on the actual implementation of subscription).
333 *
334 * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a
335 * weakly consistent view of the set.
336 *
337 * @return A set of decorated subscribed symbols.
338 */
340
341 /**
342 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using
343 * iterators).
344 *
345 * Example:
346 * ```cpp
347 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
348 *
349 * sub->setSymbols(v.begin(), v.end());
350 * ```
351 *
352 * @tparam SymbolIt The collection's iterator type
353 * @param begin The beginning of the collection of symbols.
354 * @param end The end of symbol collection.
355 */
356 template <typename SymbolIt> void setSymbols(SymbolIt begin, SymbolIt end) const {
357 if constexpr (Debugger::isDebug) {
358 // ReSharper disable once CppDFAUnreachableCode
359 Debugger::debug(toString() + "::setSymbols(symbols = " + elementsToString(begin, end) + ")");
360 }
361
362 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
363
364 setSymbolsImpl(list.get());
365 }
366
367 /**
368 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection.
369 *
370 * Example:
371 * ```cpp
372 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
373 *
374 * sub->setSymbols(std::vector{"AAPL", "IBM"});
375 * sub->setSymbols(v);
376 * ```
377 *
378 * @tparam SymbolsCollection The symbols collection's type
379 * @param collection The symbols collection
380 */
381 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
382 void setSymbols(SymbolsCollection &&collection) const {
383 setSymbols(std::begin(collection), std::end(collection));
384 }
385
386 /**
387 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection
388 * (initializer list).
389 *
390 * Example:
391 * ```cpp
392 * sub->setSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
393 * ```
394 *
395 * @param collection The symbols collection
396 */
397 void setSymbols(std::initializer_list<SymbolWrapper> collection) const;
398
399 /**
400 * Adds the specified symbol to the set of subscribed symbols.
401 * This is a convenience method to subscribe to one symbol at a time that has a return fast-path for a case when
402 * the symbol is already in the set.
403 * When subscribing to multiple symbols at once it is preferable to use @ref DXFeedSubscription::addSymbols(const
404 * SymbolsCollection &collection) "addSymbols(symbols)" method.
405 *
406 * Example:
407 * ```cpp
408 * sub->addSymbols("TSLA");
409 * sub->addSymbols("XBT/USD:GDAX"s);
410 * sub->addSymbols("BTC/EUR:CXBITF"sv);
411 * ```
412 *
413 * @param symbolWrapper The symbol.
414 */
415 void addSymbols(const SymbolWrapper &symbolWrapper) const;
416
417 /**
418 * Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
419 *
420 * Example:
421 * ```cpp
422 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
423 *
424 * sub->addSymbols(v.begin(), v.end());
425 * ```
426 *
427 * @tparam SymbolIt The collection's iterator type
428 * @param begin The beginning of the collection of symbols.
429 * @param end The end of symbol collection.
430 */
431 template <typename SymbolIt> void addSymbols(SymbolIt begin, SymbolIt end) const {
432 if constexpr (Debugger::isDebug) {
433 // ReSharper disable once CppDFAUnreachableCode
434 Debugger::debug(toString() + "::addSymbols(symbols = " + elementsToString(begin, end) + ")");
435 }
436
437 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
438
439 addSymbolsImpl(list.get());
440 }
441
442 /**
443 * Adds the specified collection of symbols to the set of subscribed symbols.
444 *
445 * Example:
446 * ```cpp
447 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
448 *
449 * sub->addSymbols(std::vector{"AAPL", "IBM"});
450 * sub->addSymbols(v);
451 * ```
452 *
453 * @tparam SymbolsCollection The symbols collection's type
454 * @param collection The symbols collection
455 */
456 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
457 void addSymbols(const SymbolsCollection &collection) const {
458 addSymbols(std::begin(collection), std::end(collection));
459 }
460
461 /**
462 * Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
463 *
464 * Example:
465 * ```cpp
466 * sub->addSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
467 * ```
468 *
469 * @param collection The symbols collection
470 */
471 void addSymbols(std::initializer_list<SymbolWrapper> collection) const;
472
473 /**
474 * Removes the specified symbol from the set of subscribed symbols.
475 * To conveniently remove one or few symbols you can use @ref DXFeedSubscription::removeSymbols(const
476 * SymbolsCollection &collection) "removeSymbols(symbols)" method.
477 *
478 * Example:
479 * ```cpp
480 * sub->removeSymbols("TSLA");
481 * sub->removeSymbols("XBT/USD:GDAX"s);
482 * sub->removeSymbols("BTC/EUR:CXBITF"sv);
483 * ```
484 *
485 * @param symbolWrapper The symbol.
486 */
487 void removeSymbols(const SymbolWrapper &symbolWrapper) const;
488
489 /**
490 * Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
491 *
492 * Example:
493 * ```cpp
494 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
495 *
496 * sub->removeSymbols(v.begin(), v.end());
497 * ```
498 *
499 * @tparam SymbolIt The collection's iterator type
500 * @param begin The beginning of the collection of symbols.
501 * @param end The end of symbol collection.
502 */
503 template <typename SymbolIt> void removeSymbols(SymbolIt begin, SymbolIt end) const {
504 if constexpr (Debugger::isDebug) {
505 // ReSharper disable once CppDFAUnreachableCode
506 Debugger::debug(toString() + "::removeSymbols(symbols = " + elementsToString(begin, end) + ")");
507 }
508
509 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
510
511 removeSymbolsImpl(list.get());
512 }
513
514 /**
515 * Removes the specified collection of symbols from the set of subscribed symbols.
516 *
517 * Example:
518 * ```cpp
519 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
520 *
521 * sub->removeSymbols(std::vector{"AAPL", "IBM"});
522 * sub->removeSymbols(v);
523 * ```
524 *
525 * @tparam SymbolsCollection The symbols collection's type
526 * @param collection The symbols collection
527 */
528 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
529 void removeSymbols(SymbolsCollection &&collection) const {
530 removeSymbols(std::begin(collection), std::end(collection));
531 }
532
533 /**
534 * Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
535 *
536 * Example:
537 * ```cpp
538 * sub->removeSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
539 * ```
540 *
541 * @param collection The symbols collection
542 */
543 void removeSymbols(std::initializer_list<SymbolWrapper> collection) const;
544
545 /**
546 * Returns the aggregation period for data for this subscription instance.
547 *
548 * @return The aggregation period for data, represented as a TimePeriod object.
549 */
551
552 /**
553 * Sets the aggregation period for data.
554 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
555 * data notification. For example, if the current aggregation period is 5 seconds and it is changed
556 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
557 * the new aggregation period will take effect.
558 *
559 * @param aggregationPeriod the new aggregation period for data
560 */
561 void setAggregationPeriod(const TimePeriod &aggregationPeriod) const;
562
563 /**
564 * Sets the aggregation period for data.
565 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
566 * data notification. For example, if the current aggregation period is 5 seconds and it is changed
567 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
568 * the new aggregation period will take effect.
569 *
570 * @param aggregationPeriod the new aggregation period (in millis) for data
571 */
572 void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const {
573 return setAggregationPeriod(TimePeriod::valueOf(aggregationPeriod));
574 }
575
576 /**
577 * Sets the aggregation period for data.
578 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
579 * data notification. For example, if the current aggregation period is 5 seconds and it is changed
580 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
581 * the new aggregation period will take effect.
582 *
583 * @param aggregationPeriod the new aggregation period (in millis) for data
584 */
585 void setAggregationPeriod(std::int64_t aggregationPeriod) const {
586 return setAggregationPeriod(TimePeriod::valueOf(aggregationPeriod));
587 }
588
589 /**
590 * Adds listener for events.
591 * Event lister can be added only when subscription is not producing any events.
592 * The subscription must be either empty
593 * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach()
594 * "attached" to any feed (its set of change listeners is empty).
595 *
596 * This method does nothing if this subscription is closed.
597 *
598 * Example:
599 * ```cpp
600 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
601 *
602 * sub->addEventListener([](auto &&events) {
603 * for (const auto &e : events) {
604 * if (auto quote = e->template sharedAs<dxfcpp::Quote>(); quote) {
605 * std::cout << "Q : " + quote->toString() << std::endl;
606 * } else if (auto tns = e->template sharedAs<dxfcpp::TimeAndSale>(); tns) {
607 * std::cout << "TnS : " + tns->toString() << std::endl;
608 * }
609 * }
610 * });
611 *
612 * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"});
613 * ```
614 *
615 * @tparam EventListener The listener type. Listener can be callable with signature: `void(const
616 * std::vector<std::shared_ptr<EventType>&)`
617 * @param listener The event listener
618 * @return The listener id
619 */
620 template <typename EventListener>
621 std::size_t addEventListener(EventListener &&listener)
622#if __cpp_concepts
624 { listener(std::vector<std::shared_ptr<EventType>>{}) } -> std::same_as<void>;
625 }
626#endif
627 {
628 if (!tryToSetEventListenerHandle()) {
629 return OnEventHandler::FAKE_ID;
630 }
631
632 return onEvent_ += listener;
633 }
634
635 /**
636 * Adds typed listener for events.
637 * Event lister can be added only when subscription is not producing any events.
638 * The subscription must be either empty
639 * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach()
640 * "attached" to any feed (its set of change listeners is empty).
641 *
642 * This method does nothing if this subscription is closed.
643 *
644 * Example:
645 * ```cpp
646 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
647 *
648 * sub->addEventListener(std::function([](const std::vector<std::shared_ptr<dxfcpp::Quotes>> &quotes) -> void {
649 * for (const auto &q : quotes) {
650 * std::cout << "Q : " + q->toString() << std::endl;
651 * }
652 * }));
653 *
654 * sub->addEventListener<dxfcpp::TimeAndSale>([](const auto &timeAndSales) -> void {
655 * for (const auto &tns : timeAndSales) {
656 * std::cout << "TnS : " + tns->toString() << std::endl;
657 * }
658 * });
659 *
660 * sub->addEventListener<dxfcpp::MarketEvent>([](const auto &marketEvents) -> void {
661 * for (const auto &me : marketEvents) {
662 * std::cout << "Market Event's symbol: " + me->getEventSymbol() << std::endl;
663 * }
664 * });
665 *
666 * sub->addSymbols({"$TOP10L/Q", "AAPL", "$TICK", "SPX"});
667 * ```
668 *
669 * @tparam EventT The event type (EventType's child with field TYPE, convertible to EventTypeEnum or MarketEvent
670 * or LastingEvent or TimeSeriesEvent or IndexedEvent)
671 * @param listener The listener. Listener can be callable with signature: `void(const
672 * std::vector<std::shared_ptr<EventT>&)`
673 * @return The listener id
674 */
675 template <typename EventT>
676 std::size_t addEventListener(std::function<void(const std::vector<std::shared_ptr<EventT>> &)> &&listener)
677#if __cpp_concepts
679 (requires {
683#endif
684 {
685 if (!tryToSetEventListenerHandle()) {
686 return SimpleHandler<void(const std::vector<std::shared_ptr<EventType>> &)>::FAKE_ID;
687 }
688
689 return onEvent_ += [l = listener](auto &&events) {
690 std::vector<std::shared_ptr<EventT>> filteredEvents{};
691
692 filteredEvents.reserve(events.size());
693
694 for (const auto &e : events) {
695 if (auto expected = e->template sharedAs<EventT>(); expected) {
696 filteredEvents.emplace_back(expected);
697 }
698 }
699
700 l(filteredEvents);
701 };
702 }
703
704 /**
705 * Removes listener for events.
706 *
707 * Example:
708 * ```cpp
709 * auto id = sub->addEventListener([](auto){});
710 *
711 * sub->removeEventListener(id);
712 * ```
713 *
714 * @param listenerId The listener id
715 */
716 void removeEventListener(std::size_t listenerId);
717
718 /**
719 * Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed.
720 * Listener can be callable with signature: `void(const std::vector<std::shared_ptr<EventType>&)`
721 *
722 * Example:
723 * ```cpp
724 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
725 * auto id = sub->onEvent() += [](auto &&events) {
726 * for (const auto &e : events) {
727 * if (auto quote = e->template sharedAs<dxfcpp::Quote>(); quote) {
728 * std::cout << "Q : " + quote->toString() << std::endl;
729 * } else if (auto tns = e->template sharedAs<dxfcpp::TimeAndSale>(); tns) {
730 * std::cout << "TnS : " + tns->toString() << std::endl;
731 * }
732 * }
733 * };
734 *
735 * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"});
736 * sub->onEvent() -= id;
737 * ```
738 *
739 * @return The incoming events' handler (delegate)
740 */
741 OnEventHandler &onEvent();
742
743 std::size_t addChangeListener(std::shared_ptr<ObservableSubscriptionChangeListener> listener) override;
744
745 void removeChangeListener(std::size_t changeListenerId) override;
746
747 /**
748 * @return maximum number of events in the single notification of OnEventHandler.
749 * Special cases are supported for constants ::OPTIMAL_BATCH_LIMIT and ::MAX_BATCH_LIMIT.
750 */
751 std::int32_t getEventsBatchLimit() const;
752
753 /**
754 * Sets maximum number of events in the single notification of OnEventHandler.
755 * Special cases are supported for constants ::OPTIMAL_BATCH_LIMIT and ::MAX_BATCH_LIMIT.
756 *
757 * @param eventsBatchLimit the notification events limit
758 * @throws JavaException if eventsBatchLimit < 0 (see ::OPTIMAL_BATCH_LIMIT or ::MAX_BATCH_LIMIT)
759 */
760 void setEventsBatchLimit(std::int32_t eventsBatchLimit) const;
761};
762
763/**
764 * Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types.
765 * This class decorates symbols that are passed to `xxxSymbols` methods in DXFeedSubscription by wrapping them into
766 * TimeSeriesSubscriptionSymbol instances with the current value of
767 * @ref DXFeedTimeSeriesSubscription::getFromTime() "fromTime" property. While
768 * @ref DXFeedSubscription::getSymbols() "getSymbols" method returns original (undecorated) symbols, any installed
769 * ObservableSubscriptionChangeListener will see decorated ones.
770 *
771 * <p> Only events that implement TimeSeriesEvent interface can be subscribed to with DXFeedTimeSeriesSubscription.
772 *
773 * <h3>From time</h3>
774 *
775 * The value of @ref DXFeedTimeSeriesSubscription::getFromTime() "fromTime" property defines the time-span of events
776 * that are subscribed to. Only events that satisfy `event.getEventTime() >= thisSubscription->getFromTime()` are
777 * looked for.
778 *
779 * <p> The value `fromTime` is initially set to `std::numeric_limits<std::int64_t>::max()` with a special meaning that
780 * no events will be received until `fromTime` is changed with
781 * @ref DXFeedTimeSeriesSubscription::setFromTime() "setFromTime" method.
782 *
783 * <h3>Threads and locks</h3>
784 *
785 * This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
786 */
788 std::atomic<std::int64_t> fromTime_{std::numeric_limits<std::int64_t>::max()};
789
790 static void registerEntity();
791
792 public:
793 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag lockTag);
794
795 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag lockTag,
796 const EventTypeEnum &eventType, JavaObjectHandle<DXFeedSubscription> &&handle);
797
798 ~DXFeedTimeSeriesSubscription() override;
799
800 template <typename EventTypeIt>
801#if __cpp_concepts
802 requires requires(EventTypeIt iter) {
803 { *iter } -> dxfcpp::ConvertibleTo<EventTypeEnum>;
804 }
805#endif
806 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag,
807 EventTypeIt begin, EventTypeIt end, JavaObjectHandle<DXFeedSubscription> &&handle)
808 : DXFeedSubscription(begin, end, std::move(handle)) {
809 registerEntity();
810 }
811
812 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag lockTag,
813 std::initializer_list<EventTypeEnum> eventTypes,
814 JavaObjectHandle<DXFeedSubscription> &&handle)
815 : DXFeedTimeSeriesSubscription(lockTag, eventTypes.begin(), eventTypes.end(), std::move(handle)) {
816 }
817
818 template <typename EventTypesCollection>
819 explicit DXFeedTimeSeriesSubscription(
820 RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag tag,
821 EventTypesCollection &&eventTypes, JavaObjectHandle<DXFeedSubscription> &&handle)
822#if __cpp_concepts
823 requires requires {
824 {
825 DXFeedTimeSeriesSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
826 std::end(std::forward<EventTypesCollection>(eventTypes)),
827 std::move(handle))
828 };
829 }
830#endif
831 : DXFeedTimeSeriesSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
832 std::end(std::forward<EventTypesCollection>(eventTypes)), std::move(handle)) {
833 }
834
835 ///
836 std::string toString() const override;
837
838 /**
839 * Creates <i>detached</i> subscription for the given collection of event types.
840 *
841 * Example:
842 * ```cpp
843 * auto sub = dxfcpp::DXFeedSubscription::create({dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE});
844 * ```
845 *
846 * @param eventTypes The event type collection.
847 * @return The new <i>detached</i> subscription for the given collection of event types.
848 */
849 static std::shared_ptr<DXFeedTimeSeriesSubscription> create(std::initializer_list<EventTypeEnum> eventTypes);
850
851 /**
852 * Returns the earliest timestamp from which time-series of events shall be received.
853 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
854 *
855 * @return the earliest timestamp from which time-series of events shall be received.
856 */
857 std::int64_t getFromTime();
858
859 /**
860 * Sets the earliest timestamp from which time-series of events shall be received.
861 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
862 *
863 * @param fromTime the timestamp.
864 */
865 void setFromTime(std::int64_t fromTime);
866
867 /**
868 * Sets the earliest timestamp from which time-series of events shall be received.
869 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
870 *
871 * @param fromTime the timestamp.
872 */
873 void setFromTime(std::chrono::milliseconds fromTime);
874};
875
877
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:22
#define DXFCPP_CXX20_CONSTEXPR_STRING
Definition Conf.hpp:121
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:70
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:67
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:38
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:40
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:21
#define DXFCPP_TRACE_ISOLATES
Definition Debug.hpp:19
#define DXFCPP_DEBUG
Definition Debug.hpp:15
#define DXFCPP_TRACE_LISTS
Definition Debug.hpp:22
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:700
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:943
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1133
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:727
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds listener that is notified about changes in state property.
Definition DXEndpoint.cpp:1079
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:994
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:207
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:892
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1045
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:149
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:169
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:153
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but connection is not act...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to remote endpoint is established.
Definition api.h:164
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:785
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1062
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:198
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:683
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:773
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:960
dxfc_error_code_t
List of error codes.
Definition api.h:49
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:60
@ DXFC_EC_SUCCESS
OK.
Definition api.h:53
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:57
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes listener that is notified about changes in state property.
Definition DXEndpoint.cpp:1105
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builder, const char *name)
Changes name that is used to distinguish multiple endpoints in the same process (GraalVM Isolate) in ...
Definition DXEndpoint.cpp:667
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:68
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:744
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1128
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1028
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:875
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:634
void(* dxfc_dxendpoint_state_change_listener)(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:178
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:977
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:909
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:926
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of endpoint that was specified during its creation.
Definition api.h:89
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:127
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:116
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:99
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:136
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without ability to establish network connections.
Definition api.h:143
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:107
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:217
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:830
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:807
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:212
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:650
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:852
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1138
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1011
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:860
bool supportsProperty(const std::string &key)
Checks if a property is supported.
Definition DXEndpoint.cpp:323
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:332
std::shared_ptr< Builder > withProperty(const std::string &key, const std::string &value)
Sets the specified property.
Definition DXEndpoint.cpp:308
std::shared_ptr< Builder > withName(const std::string &name)
Changes name that is used to distinguish multiple endpoints in the same process (GraalVM Isolate) in ...
Definition DXEndpoint.cpp:362
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:949
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:352
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:296
Subscription for a set of symbols and event types.
Definition DXFeedSubscription.hpp:40
void removeEventListener(std::size_t listenerId)
Removes listener for events.
Definition DXFeedSubscription.cpp:254
bool containsEventType(const EventTypeEnum &eventType) override
Returns true if this subscription contains the corresponding event type.
Definition DXFeedSubscription.cpp:181
std::size_t addChangeListener(std::shared_ptr< ObservableSubscriptionChangeListener > listener) override
Adds subscription change listener.
Definition DXFeedSubscription.cpp:264
bool isClosed() override
Returns true if this subscription is closed.
Definition DXFeedSubscription.cpp:159
void addSymbols(SymbolIt begin, SymbolIt end) const
Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.hpp:431
static std::shared_ptr< DXFeedSubscription > create(std::initializer_list< EventTypeEnum > eventTypes)
Creates detached subscription for the given collection of event types.
Definition DXFeedSubscription.cpp:134
void close() const
Closes this subscription and makes it permanently detached.
Definition DXFeedSubscription.cpp:168
void setEventsBatchLimit(std::int32_t eventsBatchLimit) const
Sets maximum number of events in the single notification of OnEventHandler.
Definition DXFeedSubscription.cpp:300
std::unordered_set< EventTypeEnum > getEventTypes() override
Returns a set of subscribed event types.
Definition DXFeedSubscription.cpp:177
void setSymbols(std::initializer_list< SymbolWrapper > collection) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.cpp:212
void removeSymbols(SymbolIt begin, SymbolIt end) const
Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.hpp:503
void removeSymbols(SymbolsCollection &&collection) const
Removes the specified collection of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.hpp:529
static const std::int32_t MAX_BATCH_LIMIT
The maximum events' batch limit for single notification in OnEventHandler.
Definition DXFeedSubscription.hpp:56
void removeSymbols(const SymbolWrapper &symbolWrapper) const
Removes the specified symbol from the set of subscribed symbols.
Definition DXFeedSubscription.cpp:231
static std::shared_ptr< DXFeedSubscription > create(EventTypeIt begin, EventTypeIt end)
Creates detached subscription for the given collection of event types.
Definition DXFeedSubscription.hpp:212
void attach(std::shared_ptr< DXFeed > feed)
Attaches subscription to the specified feed.
Definition DXFeedSubscription.cpp:143
TimePeriod getAggregationPeriod() const
Returns the aggregation period for data for this subscription instance.
Definition DXFeedSubscription.cpp:246
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeedSubscription.cpp:101
static const std::int32_t OPTIMAL_BATCH_LIMIT
The optimal events' batch limit for single notification in OnEventHandler.
Definition DXFeedSubscription.hpp:51
std::size_t addEventListener(std::function< void(const std::vector< std::shared_ptr< EventT > > &)> &&listener)
Adds typed listener for events.
Definition DXFeedSubscription.hpp:676
void addSymbols(std::initializer_list< SymbolWrapper > collection) const
Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.cpp:227
void setSymbols(SymbolsCollection &&collection) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.hpp:382
void setAggregationPeriod(const TimePeriod &aggregationPeriod) const
Sets the aggregation period for data.
Definition DXFeedSubscription.cpp:250
static std::shared_ptr< DXFeedSubscription > create(const EventTypeEnum &eventType)
Creates detached subscription for a single event type.
Definition DXFeedSubscription.cpp:120
std::int32_t getEventsBatchLimit() const
Definition DXFeedSubscription.cpp:296
std::size_t addEventListener(EventListener &&listener)
Adds listener for events.
Definition DXFeedSubscription.hpp:621
static std::shared_ptr< DXFeedSubscription > create(EventTypesCollection &&eventTypes)
Creates detached subscription for the given collection of event types.
Definition DXFeedSubscription.hpp:258
OnEventHandler & onEvent()
Returns a reference to an incoming events' handler (delegate), to which listeners can be added and re...
Definition DXFeedSubscription.cpp:258
void addSymbols(const SymbolsCollection &collection) const
Adds the specified collection of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.hpp:457
void setSymbols(SymbolIt begin, SymbolIt end) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.hpp:356
void setAggregationPeriod(std::int64_t aggregationPeriod) const
Sets the aggregation period for data.
Definition DXFeedSubscription.hpp:585
void removeChangeListener(std::size_t changeListenerId) override
Removes subscription change listener by id.
Definition DXFeedSubscription.cpp:280
std::vector< SymbolWrapper > getDecoratedSymbols() const
Returns a set of decorated symbols (depending on the actual implementation of subscription).
Definition DXFeedSubscription.cpp:203
void clear() const
Clears the set of subscribed symbols.
Definition DXFeedSubscription.cpp:185
void detach(std::shared_ptr< DXFeed > feed)
Detaches subscription from the specified feed.
Definition DXFeedSubscription.cpp:151
void addSymbols(const SymbolWrapper &symbolWrapper) const
Adds the specified symbol to the set of subscribed symbols.
Definition DXFeedSubscription.cpp:216
void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const
Sets the aggregation period for data.
Definition DXFeedSubscription.hpp:572
void removeSymbols(std::initializer_list< SymbolWrapper > collection) const
Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.cpp:242
std::vector< SymbolWrapper > getSymbols() const
Returns a set of subscribed symbols (depending on the actual implementation of subscription).
Definition DXFeedSubscription.cpp:194
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols an...
Definition DXFeedSubscription.hpp:787
std::int64_t getFromTime()
Returns the earliest timestamp from which time-series of events shall be received.
Definition DXFeedSubscription.cpp:329
void setFromTime(std::chrono::milliseconds fromTime)
Sets the earliest timestamp from which time-series of events shall be received.
Definition DXFeedSubscription.cpp:340
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeedSubscription.cpp:325
void setFromTime(std::int64_t fromTime)
Sets the earliest timestamp from which time-series of events shall be received.
Definition DXFeedSubscription.cpp:333
static std::shared_ptr< DXFeedTimeSeriesSubscription > create(std::initializer_list< EventTypeEnum > eventTypes)
Creates detached subscription for the given collection of event types.
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:21
bool isTimeSeries() const noexcept
Definition EventTypeEnum.hpp:174
const std::string & getClassName() const &noexcept
Definition EventTypeEnum.hpp:117
bool isLasting() const noexcept
Definition EventTypeEnum.hpp:160
bool isOnlyIndexed() const noexcept
Definition EventTypeEnum.hpp:181
bool isIndexed() const noexcept
Definition EventTypeEnum.hpp:167
std::uint32_t getId() const noexcept
Definition EventTypeEnum.hpp:103
bool isMarket() const noexcept
Definition EventTypeEnum.hpp:188
const std::string & getName() const &noexcept
Definition EventTypeEnum.hpp:110
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:22
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSource.cpp:21
const std::string & name() const noexcept
Returns the string representation of the object.
Definition IndexedEventSource.hpp:90
static IndexedEventSource fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition IndexedEventSource.cpp:32
static const IndexedEventSource DEFAULT
The default source with zero identifier for all events that do not support multiple sources.
Definition IndexedEventSource.hpp:13
std::int32_t id() const noexcept
Returns the source identifier.
Definition IndexedEventSource.hpp:81
virtual void * toGraal() const
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSource.cpp:15
std::string toString() const
Returns the string representation of the object.
Definition IndexedEventSource.hpp:99
IndexedEventSource(std::int32_t id, std::string name) noexcept
Creates the new IndexedEvent's source by id and name.
Definition IndexedEventSource.hpp:73
Represents subscription to a specific source of indexed events.
Definition IndexedEventSubscriptionSymbol.hpp:40
virtual const std::unique_ptr< SymbolWrapper > & getEventSymbol() const
Returns the wrapped event symbol (CandleSymbol, WildcardSymbol, etc).
Definition IndexedEventSubscriptionSymbol.cpp:16
virtual void * toGraal() const
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSubscriptionSymbol.cpp:24
static IndexedEventSubscriptionSymbol fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure ...
Definition IndexedEventSubscriptionSymbol.cpp:46
virtual const std::unique_ptr< IndexedEventSource > & getSource() const
Returns indexed event source.
Definition IndexedEventSubscriptionSymbol.cpp:20
IndexedEventSubscriptionSymbol(const SymbolWrapper &eventSymbol, const IndexedEventSource &source)
Creates indexed event subscription symbol with a specified event symbol and source.
Definition IndexedEventSubscriptionSymbol.cpp:10
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSubscriptionSymbol.cpp:33
virtual std::string toString() const
Returns string representation of this indexed event subscription symbol.
Definition IndexedEventSubscriptionSymbol.cpp:61
static const OrderSource GLBX
CME Globex.
Definition OrderSource.hpp:307
static const OrderSource smfe
Small Exchange.
Definition OrderSource.hpp:371
static const OrderSource bzx
Bats BZX Exchange.
Definition OrderSource.hpp:235
static const OrderSource DEX
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:202
static const OrderSource NTV
NASDAQ Total View.
Definition OrderSource.hpp:138
static const OrderSource AGGREGATE_ASK
Ask side of an aggregate order book (futures depth and NASDAQ Level II).
Definition OrderSource.hpp:123
static const OrderSource & valueOf(std::int32_t sourceId)
Returns order source for the specified source identifier.
Definition OrderSource.cpp:178
static const OrderSource ESPD
NASDAQ eSpeed.
Definition OrderSource.hpp:162
static const OrderSource CFE
CBOE Futures Exchange.
Definition OrderSource.hpp:347
static const OrderSource ntv
NASDAQ Total View.
Definition OrderSource.hpp:146
static const OrderSource ICE
Intercontinental Exchange.
Definition OrderSource.hpp:178
static const OrderSource BZX
Bats BZX Exchange.
Definition OrderSource.hpp:227
static const OrderSource C2OX
CBOE Options C2 Exchange.
Definition OrderSource.hpp:355
static const OrderSource REGIONAL_ASK
Ask side of a regional Quote.
Definition OrderSource.hpp:111
static const OrderSource REGIONAL_BID
Bid side of a regional Quote.
Definition OrderSource.hpp:104
static const OrderSource ABE
ABE (abe.io) exchange.
Definition OrderSource.hpp:291
static const OrderSource CEUX
Bats Europe DXE Exchange.
Definition OrderSource.hpp:259
static const OrderSource OCEA
Blue Ocean Technologies Alternative Trading System.
Definition OrderSource.hpp:403
static const OrderSource AGGREGATE_BID
Bid side of an aggregate order book (futures depth and NASDAQ Level II).
Definition OrderSource.hpp:117
static const OrderSource BXTR
Bats Europe TRF.
Definition OrderSource.hpp:267
static const OrderSource dex
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:211
static const OrderSource cedx
Cboe European Derivatives.
Definition OrderSource.hpp:444
static const OrderSource COMPOSITE_ASK
Ask side of a composite Quote.
Definition OrderSource.hpp:97
static const OrderSource XNFI
NASDAQ Fixed Income.
Definition OrderSource.hpp:170
static const OrderSource iex
Investors exchange.
Definition OrderSource.hpp:379
static const OrderSource xeur
Eurex Exchange.
Definition OrderSource.hpp:339
static const OrderSource CEDX
Cboe European Derivatives.
Definition OrderSource.hpp:436
static const OrderSource ISE
International Securities Exchange.
Definition OrderSource.hpp:186
static const OrderSource DEA
Direct-Edge EDGA Exchange.
Definition OrderSource.hpp:194
static const OrderSource glbx
CME Globex.
Definition OrderSource.hpp:315
static const OrderSource BI20
Borsa Istanbul Exchange.
Definition OrderSource.hpp:283
static const OrderSource BYX
Bats BYX Exchange.
Definition OrderSource.hpp:219
static const OrderSource FAIR
FAIR (FairX) exchange.
Definition OrderSource.hpp:299
static const OrderSource BATE
Bats Europe BXE Exchange.
Definition OrderSource.hpp:243
static const OrderSource pink
Pink Sheets.
Definition OrderSource.hpp:412
static const OrderSource DEFAULT
Default source for publishing custom order books.
Definition OrderSource.hpp:130
static const OrderSource NFX
NASDAQ Futures Exchange.
Definition OrderSource.hpp:154
static const OrderSource memx
Members Exchange.
Definition OrderSource.hpp:395
static bool isSpecialSourceId(std::int32_t sourceId) noexcept
Determines whether specified source identifier refers to special order source.
Definition OrderSource.cpp:174
static const OrderSource IST
Borsa Istanbul Exchange.
Definition OrderSource.hpp:275
static const OrderSource ARCA
NYSE Arca traded securities.
Definition OrderSource.hpp:420
static const OrderSource CHIX
Bats Europe CXE Exchange.
Definition OrderSource.hpp:251
static const OrderSource & valueOf(const std::string &name)
Returns order source for the specified source name.
Definition OrderSource.cpp:192
static const OrderSource ERIS
Eris Exchange group of companies.
Definition OrderSource.hpp:323
static const OrderSource XEUR
Eurex Exchange.
Definition OrderSource.hpp:331
static const OrderSource MEMX
Members Exchange.
Definition OrderSource.hpp:387
static const OrderSource COMPOSITE_BID
Bid side of a composite Quote.
Definition OrderSource.hpp:90
static const OrderSource arca
NYSE Arca traded securities.
Definition OrderSource.hpp:428
static const OrderSource SMFE
Small Exchange.
Definition OrderSource.hpp:363
TimeSeriesSubscriptionSymbol(const SymbolWrapper &eventSymbol, std::int64_t fromTime)
Creates time-series subscription symbol with a specified event symbol and subscription time.
void * toGraal() const override
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition TimeSeriesSubscriptionSymbol.cpp:19
std::string toString() const override
Returns string representation of this time-series subscription symbol.
Definition TimeSeriesSubscriptionSymbol.cpp:63
std::int64_t getFromTime() const
Returns the subscription time.
Definition TimeSeriesSubscriptionSymbol.cpp:15
static TimeSeriesSubscriptionSymbol fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure ...
Definition TimeSeriesSubscriptionSymbol.cpp:48
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition TimeSeriesSubscriptionSymbol.cpp:32
Candle alignment attribute of CandleSymbol defines how candle are aligned with respect to time.
Definition CandleAlignment.hpp:32
static const CandleAlignment DEFAULT
Default alignment is CandleAlignment::MIDNIGHT.
Definition CandleAlignment.hpp:46
static const CandleAlignment MIDNIGHT
Align candles on midnight.
Definition CandleAlignment.hpp:12
static std::reference_wrapper< const CandleAlignment > getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle alignment of the given candle symbol string.
Definition CandleAlignment.cpp:79
static const CandleAlignment SESSION
Align candles on trading sessions.
Definition CandleAlignment.hpp:13
std::string toString() const
Returns string representation of this candle alignment.
Definition CandleAlignment.cpp:37
static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle symbol string with the normalized representation of the candle alignment attribute.
Definition CandleAlignment.cpp:91
static const std::string ATTRIBUTE_KEY
The attribute key that is used to store the value of CandleAlignment in a symbol string using methods...
Definition CandleAlignment.hpp:15
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this candle alignment set.
Definition CandleAlignment.cpp:32
static std::reference_wrapper< const CandleAlignment > parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of candle alignment into object.
Definition CandleAlignment.cpp:53
Exchange attribute of CandleSymbol defines exchange identifier where data is taken from to build the ...
Definition CandleExchange.hpp:30
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this exchange set.
Definition CandleExchange.hpp:65
static const CandleExchange COMPOSITE
Composite exchange where data is taken from all exchanges.
Definition CandleExchange.hpp:11
char getExchangeCode() const noexcept
Returns exchange code.
Definition CandleExchange.hpp:55
static CandleExchange getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns exchange attribute object of the given candle symbol string.
Definition CandleExchange.hpp:101
static const CandleExchange DEFAULT
Default exchange is CandleExchange::COMPOSITE.
Definition CandleExchange.hpp:39
std::string toString() const
Returns string representation of this exchange.
Definition CandleExchange.hpp:76
static CandleExchange valueOf(char exchangeCode) noexcept
Returns exchange attribute object that corresponds to the specified exchange code character.
Definition CandleExchange.hpp:90
Period attribute of CandleSymbol defines aggregation period of the candles.
Definition CandlePeriod.hpp:37
static CandlePeriod parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of aggregation period into object.
Definition CandlePeriod.hpp:155
double getValue() const noexcept
Returns aggregation period value.
Definition CandlePeriod.hpp:109
static const std::string ATTRIBUTE_KEY
The attribute key that is used to store the value of CandlePeriod in a symbol string using methods of...
Definition CandlePeriod.hpp:53
static const CandlePeriod TICK
Tick aggregation where each candle represents an individual tick.
Definition CandlePeriod.hpp:50
static const CandlePeriod DEFAULT
Default period is CandlePeriod::TICK.
Definition CandlePeriod.hpp:51
std::int64_t getPeriodIntervalMillis() const noexcept
Returns aggregation period in milliseconds as closely as possible.
Definition CandlePeriod.hpp:88
static const CandlePeriod DAY
Day aggregation where each candle represents a day.
Definition CandlePeriod.hpp:51
static CandlePeriod valueOf(double value, const CandleType &type) noexcept
Returns candle period with the given value and type.
Definition CandlePeriod.hpp:188
const CandleType & getType() const &noexcept
Returns aggregation period type.
Definition CandlePeriod.hpp:117
const std::string & toString() const &
Returns string representation of this aggregation period.
Definition CandlePeriod.hpp:131
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this aggregation period set.
Definition CandlePeriod.hpp:97
static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle symbol string with the normalized representation of the candle period attribute.
Definition CandlePeriod.hpp:219
static CandlePeriod getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) noexcept
Returns candle period of the given candle symbol string.
Definition CandlePeriod.hpp:207
Candle price level attribute of CandleSymbol defines how candles shall be aggregated in respect to pr...
Definition CandlePriceLevel.hpp:40
std::string toString() const
Returns string representation of this price level.
Definition CandlePriceLevel.hpp:80
double getValue() const noexcept
Returns price level value.
Definition CandlePriceLevel.hpp:69
static CandlePriceLevel parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of candle price level into object.
Definition CandlePriceLevel.hpp:111
static const std::string ATTRIBUTE_KEY
The attribute key that is used to store the value of CandlePriceLevel in a symbol string using method...
Definition CandlePriceLevel.hpp:13
static CandlePriceLevel valueOf(double value)
Returns candle price level with the given value.
Definition CandlePriceLevel.hpp:122
static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle symbol string with the normalized representation of the candle price level attribute.
Definition CandlePriceLevel.hpp:149
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this candle price level set.
Definition CandlePriceLevel.hpp:98
static const CandlePriceLevel DEFAULT
Default price level corresponds to NaN (std::numeric_limits<double>::quiet_NaN())
Definition CandlePriceLevel.hpp:11
static CandlePriceLevel getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle price level of the given candle symbol string.
Definition CandlePriceLevel.hpp:137
Price type attribute of CandleSymbol defines price that is used to build the candles.
Definition CandlePrice.hpp:34
static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle symbol string with the normalized representation of the candle price type attribute.
Definition CandlePrice.hpp:165
static const CandlePrice BID
Quote bid price.
Definition CandlePrice.hpp:12
static const CandlePrice ASK
Quote ask price.
Definition CandlePrice.hpp:13
static const CandlePrice LAST
Last trading price.
Definition CandlePrice.hpp:11
static std::reference_wrapper< const CandlePrice > getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) noexcept
Returns candle price type of the given candle symbol string.
Definition CandlePrice.hpp:153
static const CandlePrice MARK
Market price defined as average between quote bid and ask prices.
Definition CandlePrice.hpp:14
static std::reference_wrapper< const CandlePrice > parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of candle price type into object.
Definition CandlePrice.hpp:123
const std::string & toString() const &noexcept
Returns string representation of this candle price type.
Definition CandlePrice.hpp:107
static const CandlePrice DEFAULT
Default price type is CandlePrice::LAST.
Definition CandlePrice.hpp:65
static const CandlePrice SETTLEMENT
Official settlement price that is defined by exchange or last trading price otherwise.
Definition CandlePrice.hpp:15
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this candle price type set.
Definition CandlePrice.hpp:95
static const std::string ATTRIBUTE_KEY
The attribute key that is used to store the value of CandlePrice in a symbol string using methods of ...
Definition CandlePrice.hpp:18
const std::string & toString() const &noexcept
Returns string representation of this candle session attribute.
Definition CandleSession.hpp:102
std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const override
Returns candle event symbol string with this session attribute set.
Definition CandleSession.hpp:90
static const CandleSession REGULAR
Only regular trading session data is used to build candles.
Definition CandleSession.hpp:45
static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) noexcept
Returns candle symbol string with the normalized representation of the candle session attribute.
Definition CandleSession.hpp:159
const SessionFilter & getSessionFilter() const &noexcept
Returns session filter that corresponds to this session attribute.
Definition CandleSession.hpp:81
static std::reference_wrapper< const CandleSession > parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of candle session attribute into object.
Definition CandleSession.hpp:118
static const CandleSession ANY
All trading sessions are used to build candles.
Definition CandleSession.hpp:44
static std::reference_wrapper< const CandleSession > getAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol)
Returns candle session attribute of the given candle symbol string.
Definition CandleSession.hpp:147
static const std::string ATTRIBUTE_KEY
The attribute key that is used to store the value of CandleSession in a symbol string using methods o...
Definition CandleSession.hpp:60
static const CandleSession DEFAULT
Default trading session is CandleSession::ANY.
Definition CandleSession.hpp:51
Attribute of the CandleSymbol.
Definition CandleSymbolAttribute.hpp:19
virtual std::string changeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) const =0
Returns candle event symbol string with this attribute set.
Symbol that should be used with DXFeedSubscription class to subscribe for Candle events.
Definition CandleSymbol.hpp:83
static CandleSymbol valueOf(std::string symbol, CandleSymbolAttributesCollection &&attributes) noexcept
Converts the given string symbol into the candle symbol object with the specified attributes set.
Definition CandleSymbol.hpp:347
const std::optional< CandlePeriod > & getPeriod() const &noexcept
Returns aggregation period of this symbol.
Definition CandleSymbol.hpp:210
const std::optional< CandlePriceLevel > & getPriceLevel() const &noexcept
Returns price level attribute of this symbol.
Definition CandleSymbol.hpp:228
static CandleSymbol valueOf(std::string symbol, std::initializer_list< CandleSymbolAttributeVariant > attributes) noexcept
Converts the given string symbol into the candle symbol object with the specified attributes set (ini...
Definition CandleSymbol.hpp:329
const std::optional< CandleExchange > & getExchange() const &noexcept
Returns exchange attribute of this symbol.
Definition CandleSymbol.hpp:183
const std::string & getBaseSymbol() const &noexcept
Returns base market symbol without attributes.
Definition CandleSymbol.hpp:174
static CandleSymbol valueOf(std::string symbol, CandleSymbolAttributeIt begin, CandleSymbolAttributeIt end) noexcept
Converts the given string symbol into the candle symbol object with the specified attribute set (iter...
Definition CandleSymbol.hpp:316
const std::optional< CandlePrice > & getPrice() const &noexcept
Returns price type attribute of this symbol.
Definition CandleSymbol.hpp:192
static CandleSymbol valueOf(std::string symbol) noexcept
Converts the given string symbol into the candle symbol object.
Definition CandleSymbol.hpp:291
static CandleSymbol valueOf(std::string symbol, const CandleSymbolAttributeVariant &attribute) noexcept
Converts the given string symbol into the candle symbol object with the specified attribute set.
Definition CandleSymbol.hpp:302
virtual void * toGraal() const
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition CandleSymbol.cpp:11
const std::string & toString() const &noexcept
Returns string representation of this symbol.
Definition CandleSymbol.hpp:239
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition CandleSymbol.cpp:21
const std::optional< CandleSession > & getSession() const &noexcept
Returns session attribute of this symbol.
Definition CandleSymbol.hpp:201
static CandleSymbol fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition CandleSymbol.cpp:36
const std::optional< CandleAlignment > & getAlignment() const &noexcept
Returns alignment attribute of this symbol.
Definition CandleSymbol.hpp:219
Type of the candle aggregation period constitutes CandlePeriod type together its actual value.
Definition CandleType.hpp:27
static const CandleType VOLUME
Certain volume of trades.
Definition CandleType.hpp:76
static const CandleType MONTH
Certain number of months.
Definition CandleType.hpp:61
static const CandleType PRICE_RENKO
Certain price change, calculated according to the following rules:
Definition CandleType.hpp:111
static std::reference_wrapper< const CandleType > parse(const dxfcpp::StringLikeWrapper &s)
Parses string representation of candle type into object.
Definition CandleType.hpp:177
static const CandleType DAY
Certain number of days.
Definition CandleType.hpp:15
std::int64_t getPeriodIntervalMillis() const noexcept
Returns candle type period in milliseconds as closely as possible.
Definition CandleType.hpp:141
static const CandleType WEEK
Certain number of weeks.
Definition CandleType.hpp:16
static const CandleType HOUR
Certain number of hours.
Definition CandleType.hpp:14
static const CandleType PRICE
Certain price change, calculated according to the following rules:
Definition CandleType.hpp:87
static const CandleType TICK
Certain number of ticks.
Definition CandleType.hpp:11
const std::string & toString() const &noexcept
Returns string representation of this candle type.
Definition CandleType.hpp:164
static const CandleType OPTEXP
Certain number of option expirations.
Definition CandleType.hpp:66
static const CandleType SECOND
Certain number of seconds.
Definition CandleType.hpp:12
static const CandleType MINUTE
Certain number of minutes.
Definition CandleType.hpp:13
const std::string & getName() const &noexcept
Returns a name of this candle type.
Definition CandleType.hpp:150
static const CandleType PRICE_MOMENTUM
Certain price change, calculated according to the following rules:
Definition CandleType.hpp:99
static const CandleType YEAR
Certain number of years.
Definition CandleType.hpp:71
Mixin for wrapping calls to common promise methods.
Definition Promise.hpp:72
JavaException getException() const
Returns exceptional outcome of computation.
Definition Promise.hpp:120
void cancel() const
Cancels computation.
Definition Promise.hpp:167
bool hasResult() const
Returns true when computation has completed normally.
Definition Promise.hpp:88
bool isCancelled() const
Returns true when computation was cancelled.
Definition Promise.hpp:107
bool hasException() const
Returns true when computation has completed exceptionally or was cancelled.
Definition Promise.hpp:97
bool awaitWithoutException(const std::chrono::milliseconds &timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:154
bool isDone() const
Returns true when computation has completed normally, or exceptionally, or was cancelled.
Definition Promise.hpp:78
bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:137
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:186
bool isClosed() const
Definition DXEndpoint.cpp:488
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:500
static const std::string DXFEED_PASSWORD_PROPERTY
"dxfeed.password"
Definition DXEndpoint.hpp:253
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:476
void awaitProcessed()
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:211
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:451
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:471
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but connection is not actua...
Definition DXEndpoint.hpp:461
@ CONNECTED
The connection to remote endpoint is established.
Definition DXEndpoint.hpp:466
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:455
void disconnectAndClear()
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:195
void reconnect()
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:179
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:468
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes listener that is notified about changes in state property.
Definition DXEndpoint.cpp:496
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:492
Role
Represents the role of endpoint that was specified during its creation.
Definition DXEndpoint.hpp:380
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:425
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:413
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without ability to establish network connections.
Definition DXEndpoint.hpp:441
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:404
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:434
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:391
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:371
std::shared_ptr< DXFeed > getFeed()
Definition DXEndpoint.cpp:227
static const std::string DXFEED_WILDCARD_ENABLE_PROPERTY
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:281
std::size_t addStateChangeListener(std::function< void(State, State)> listener) noexcept
Adds listener that is notified about changes in state property.
Definition DXEndpoint.hpp:628
static const std::string DXENDPOINT_EVENT_TIME_PROPERTY
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:326
static const std::string DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:309
std::shared_ptr< DXEndpoint > connect(const std::string &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:168
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:150
static const std::string DXENDPOINT_STORE_EVERYTHING_PROPERTY
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:339
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:452
std::shared_ptr< DXPublisher > getPublisher()
Definition DXEndpoint.cpp:235
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:272
std::shared_ptr< DXEndpoint > password(const std::string &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:161
void close()
Closes this endpoint.
Definition DXEndpoint.cpp:504
static const std::string DXFEED_THREAD_POOL_SIZE_PROPERTY
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:262
void awaitNotConnected()
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:203
void closeAndAwaitTermination()
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:219
std::shared_ptr< DXEndpoint > user(const std::string &user)
Changes user name for this endpoint.
Definition DXEndpoint.cpp:154
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:444
static const std::string DXPUBLISHER_ADDRESS_PROPERTY
"dxpublisher.address"
Definition DXEndpoint.hpp:300
static const std::string DXFEED_USER_PROPERTY
"dxfeed.user"
Definition DXEndpoint.hpp:243
static const std::string NAME_PROPERTY
"name"
Definition DXEndpoint.hpp:203
static const std::string DXSCHEME_ENABLED_PROPERTY_PREFIX
"dxscheme.enabled."
Definition DXEndpoint.hpp:373
static const std::string DXPUBLISHER_PROPERTIES_PROPERTY
"dxpublisher.properties"
Definition DXEndpoint.hpp:290
static const std::string DXSCHEME_NANO_TIME_PROPERTY
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:359
static const std::string DXFEED_ADDRESS_PROPERTY
"dxfeed.address"
Definition DXEndpoint.hpp:233
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:484
static const std::string DXFEED_PROPERTIES_PROPERTY
"dxfeed.properties"
Definition DXEndpoint.hpp:214
static std::shared_ptr< Builder > newBuilder()
Creates new Builder instance.
Definition DXEndpoint.cpp:460
void disconnect()
Terminates all remote network connections.
Definition DXEndpoint.cpp:187
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:116
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime) const
Returns time series of events for the specified event type, symbol, and a range of time (without an u...
Definition DXFeed.hpp:975
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:462
std::shared_ptr< DXFeedSubscription > createSubscription(std::initializer_list< EventTypeEnum > eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:98
void detachSubscriptionAndClear(std::shared_ptr< DXFeedSubscription > subscription)
Detaches the given subscription from this feed and clears data delivered to this subscription by publ...
Definition DXFeed.cpp:67
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:356
std::shared_ptr< PromiseList< E > > getLastEventsPromises(std::initializer_list< SymbolWrapper > collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:691
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypeEnum &eventType)
Creates new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:111
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime, std::chrono::milliseconds toTime) const
Returns time series of events for the specified event type, symbol, and a range of time if there is a...
Definition DXFeed.hpp:959
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const
Returns time series of events for the specified event type, symbol, and a range of time if there is a...
Definition DXFeed.hpp:907
void attachSubscription(std::shared_ptr< DXFeedSubscription > subscription)
Attaches the given subscription to this feed.
Definition DXFeed.cpp:29
std::shared_ptr< Promise< std::vector< std::shared_ptr< E > > > > getTimeSeriesPromise(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const
Requests time series of events for the specified event type, symbol, and a range of time.
Definition DXFeed.hpp:855
std::shared_ptr< E > getLastEventIfSubscribed(const SymbolWrapper &symbol)
Returns the last event for the specified event type and symbol if there is a subscription for it.
Definition DXFeed.hpp:305
std::shared_ptr< PromiseList< E > > getLastEventsPromises(SymbolsCollection &&collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:649
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypesCollection &&eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:403
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypeEnum &eventType)
Creates new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:86
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime) const
Returns time series of events for the specified event type, symbol, and a range of time (without an u...
Definition DXFeed.hpp:990
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypesCollection &&eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:524
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:21
void detachSubscription(std::shared_ptr< DXFeedSubscription > subscription)
Detaches the given subscription from this feed.
Definition DXFeed.cpp:48
std::shared_ptr< E > getLastEvent(std::shared_ptr< E > event)
Returns the last event for the specified event instance.
Definition DXFeed.hpp:245
std::shared_ptr< PromiseList< E > > getLastEventsPromises(SymbolIt begin, SymbolIt end) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:603
std::shared_ptr< Promise< std::shared_ptr< E > > > getLastEventPromise(const SymbolWrapper &symbol) const
Requests the last event for the specified event type and symbol.
Definition DXFeed.hpp:558
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:132
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:217
std::shared_ptr< Promise< std::vector< std::shared_ptr< E > > > > getIndexedEventsPromise(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Requests a container of indexed events for the specified event type, symbol, and source.
Definition DXFeed.hpp:744
std::vector< std::shared_ptr< E > > getIndexedEventsIfSubscribed(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Returns a vector of indexed events for the specified event type, symbol, and source if there is a sub...
Definition DXFeed.hpp:800
const Collection & getLastEvents(const Collection &events)
Returns the last events for the specified list of event instances.
Definition DXFeed.hpp:266
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:62
Base abstract class for all dxFeed C++ API entities.
Definition Entity.hpp:13
virtual ~Entity() noexcept=default
The default virtual d-tor.
Mixin for wrapping Promise method calls for a single event.
Definition Promise.hpp:236
std::shared_ptr< E > getResult() const
Returns result of computation.
Definition Promise.hpp:244
std::shared_ptr< E > await() const
Wait for computation to complete and return its result or throw an exception in case of exceptional c...
Definition Promise.hpp:254
std::shared_ptr< E > await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:284
std::shared_ptr< E > await(std::int32_t timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:269
bool isOrderSource() const noexcept
Definition EventSourceWrapper.hpp:242
std::unique_ptr< void, decltype(&EventSourceWrapper::freeGraal)> toGraalUnique() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:200
std::string toStringUnderlying() const
Returns a string representation of the underlying object.
Definition EventSourceWrapper.hpp:224
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:163
std::string toString() const
Returns a string representation of the current object.
Definition EventSourceWrapper.hpp:209
void * toGraal() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:184
static EventSourceWrapper fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition EventSourceWrapper.cpp:40
const DataType & getData() const noexcept
Definition EventSourceWrapper.hpp:266
EventSourceWrapper(const IndexedEventSource &data) noexcept
Constructs a wrapper from IndexedEventSource.
Definition EventSourceWrapper.hpp:145
bool isIndexedEventSource() const noexcept
Definition EventSourceWrapper.hpp:235
std::optional< IndexedEventSource > asIndexedEventSource() const noexcept
Definition EventSourceWrapper.hpp:250
std::optional< OrderSource > asOrderSource() const noexcept
Definition EventSourceWrapper.hpp:259
EventSourceWrapper(const OrderSource &data) noexcept
Constructs a wrapper from OrderSource.
Definition EventSourceWrapper.hpp:153
Event type parametrized by a symbol.
Definition EventType.hpp:116
virtual const std::optional< Symbol > & getEventSymbolOpt() const &noexcept=0
Returns event symbol that identifies this event type in subscription.
virtual void setEventSymbol(const Symbol &eventSymbol) noexcept=0
Changes event symbol that identifies this event type in subscription.
virtual const Symbol & getEventSymbol() const &noexcept=0
Returns event symbol that identifies this event type in subscription.
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
std::string toString() const override
Returns a string representation of the current object.
Definition EventType.hpp:89
virtual std::int64_t getEventTime() const noexcept
Returns time when event was created or zero when time is not available.
Definition EventType.hpp:54
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition EventType.hpp:84
virtual void * toGraal() const =0
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
virtual void setEventTime(std::int64_t) noexcept
Changes event creation time.
Definition EventType.hpp:66
This marker interface marks subscription symbol classes (like TimeSeriesSubscriptionSymbol) that atta...
Definition FilteredSubscriptionSymbol.hpp:27
The wrapper over CEntryPointErrorsEnum, the error code returned by GraalVM.
Definition GraalException.hpp:22
GraalException(CEntryPointErrorsEnum entryPointErrorsEnum)
Constructs an exception.
Definition GraalException.cpp:10
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:123
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:157
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:209
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:198
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:147
Handler(std::size_t mainFuturesSize=MAIN_FUTURES_DEFAULT_SIZE) noexcept
Creates the new handler by specified size of circular buffer of futures.
Definition Handler.hpp:85
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:237
std::size_t addLowPriority(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group) It will be called after the "main" liste...
Definition Handler.hpp:178
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:218
Represents an indexed collection of up-to-date information about some condition or state of an extern...
Definition IndexedEvent.hpp:41
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:21
A wrapper over the interceptable Java exceptions thrown by the dxFeed Native Graal SDK.
Definition JavaException.hpp:24
JavaException(const StringLikeWrapper &message, const StringLikeWrapper &className, const StringLikeWrapper &stackTrace)
Creates an exception using Java message, className and stack trace.
Definition JavaException.cpp:12
static void throwIfJavaThreadExceptionExists()
Throws a JavaException if it exists (i.e. intercepted by Graal SDK)
Definition JavaException.cpp:30
static JavaException create(void *exceptionHandle)
Creates an exception using native (GraalVM) Java exception handle.
Definition JavaException.cpp:20
Represents up-to-date information about some condition or state of an external entity that updates in...
Definition LastingEvent.hpp:28
Helper class to compose and parse symbols for market events.
Definition MarketEventSymbols.hpp:39
static bool hasExchangeCode(const std::string &symbol) noexcept
Returns true is the specified symbol has the exchange code specification.
Definition MarketEventSymbols.hpp:46
static DXFCPP_CXX20_CONSTEXPR_STRING std::string changeBaseSymbol(const std::string &symbol, const std::string &baseSymbol) noexcept
Changes base symbol while leaving exchange code and attributes intact.
Definition MarketEventSymbols.hpp:91
static DXFCPP_CXX20_CONSTEXPR_STRING std::string changeExchangeCode(const std::string &symbol, char exchangeCode) noexcept
Changes exchange code of the specified symbol or removes it if new exchange code is ‘’\0'`.
Definition MarketEventSymbols.hpp:67
static DXFCPP_CXX20_CONSTEXPR_STRING std::string getBaseSymbol(const std::string &symbol) noexcept
Returns base symbol without exchange code and attributes.
Definition MarketEventSymbols.hpp:81
static DXFCPP_CXX20_CONSTEXPR_STRING std::optional< std::string > getAttributeStringByKey(const std::string &symbol, const std::string &key) noexcept
Returns value of the attribute with the specified key.
Definition MarketEventSymbols.hpp:110
static DXFCPP_CXX20_CONSTEXPR_STRING std::string removeAttributeStringByKey(const std::string &symbol, const std::string &key) noexcept
Removes one attribute with the specified key while leaving exchange code and other attributes intact.
Definition MarketEventSymbols.hpp:139
static DXFCPP_CXX20_CONSTEXPR_STRING std::string changeAttributeStringByKey(const std::string &symbol, const std::string &key, const std::string &value) noexcept
Changes value of one attribute value while leaving exchange code and other attributes intact.
Definition MarketEventSymbols.hpp:124
static char getExchangeCode(const std::string &symbol) noexcept
Returns exchange code of the specified symbol or ‘’\0'` if none is defined.
Definition MarketEventSymbols.hpp:56
Base class for all market events.
Definition MarketEvent.hpp:25
Observable set of subscription symbols.
Definition ObservableSubscription.hpp:25
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:76
A list of event receiving results that will be completed normally or exceptionally in the future.
Definition Promise.hpp:424
Result of a computation that will be completed normally or exceptionally in the future.
Definition Promise.hpp:350
Utility methods to manipulate promises.
Definition Promises.hpp:20
A helper class needed to construct smart pointers to objects, and does not allow explicit constructio...
Definition SharedEntity.hpp:89
static auto createShared(Args &&...args)
Creates smart pointer to object.
Definition SharedEntity.hpp:103
A runtime axception with stacktrace.
Definition RuntimeException.hpp:20
RuntimeException(const StringLikeWrapper &message, const StringLikeWrapper &additionalStackTrace="")
Constructs a runtime exception.
Definition RuntimeException.cpp:71
const std::string & getStackTrace() const &
Definition RuntimeException.cpp:85
static const SessionFilter TRADING
Accepts trading sessions only - those with (Session::isTrading() == true).
Definition SessionFilter.hpp:33
static const SessionFilter ANY
Accepts any session - useful for pure schedule navigation.
Definition SessionFilter.hpp:32
static const SessionFilter AFTER_MARKET
Accepts any session with type SessionType::AFTER_MARKET.
Definition SessionFilter.hpp:41
static const SessionFilter REGULAR
Accepts any session with type SessionType::REGULAR.
Definition SessionFilter.hpp:40
SessionFilter(SessionFilterEnum code, std::string name, std::optional< SessionType > type, std::optional< bool > trading) noexcept
Creates filter with specified type and trading flag conditions.
Definition CandleSession.cpp:17
static const SessionFilter NO_TRADING
Accepts any session with type SessionType::NO_TRADING.
Definition SessionFilter.hpp:36
static const SessionFilter NON_TRADING
Accepts non-trading sessions only - those with (Session::isTrading() == false).
Definition SessionFilter.hpp:34
static const SessionFilter PRE_MARKET
Accepts any session with type SessionType::PRE_MARKET.
Definition SessionFilter.hpp:38
bool accept(Session session) const noexcept
Tests whether or not the specified session is an acceptable result.
Definition SessionFilter.hpp:104
std::optional< bool > trading_
Required trading flag, std::nullopt if not relevant.
Definition SessionFilter.hpp:70
std::optional< SessionType > type_
Required type, std::nullopt if not relevant.
Definition SessionFilter.hpp:68
Defines type of session - what kind of trading activity is allowed (if any), what rules are used,...
Definition SessionType.hpp:33
static const SessionType AFTER_MARKET
After-market session type marks extended trading session after regular trading hours.
Definition SessionType.hpp:15
static const SessionType PRE_MARKET
Pre-market session type marks extended trading session before regular trading hours.
Definition SessionType.hpp:13
static const SessionType REGULAR
Regular session type marks regular trading hours session.
Definition SessionType.hpp:14
static const SessionType NO_TRADING
Non-trading session type is used to mark periods of time during which trading is not allowed.
Definition SessionType.hpp:12
bool isTrading() const noexcept
Returns true if trading activity is allowed for this type of session.
Definition SessionType.hpp:70
Base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:21
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:78
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:56
bool is() const noexcept
Checks that pointer to the current type could be converted to type T* In other words: whether type T ...
Definition SharedEntity.hpp:35
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:378
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:398
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:316
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:327
SimpleHandler() noexcept=default
Creates the new handler.
std::size_t addLowPriority(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group) It will be called after the "main" liste...
Definition Handler.hpp:358
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:417
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:389
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:337
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition Common.hpp:911
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:794
StringSymbol(std::string_view stringView) noexcept
Constructs StringSymbol from a std::string_view.
Definition StringSymbol.hpp:53
StringSymbol(const char *chars) noexcept
Constructs StringSymbol from a char array.
Definition StringSymbol.hpp:40
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition StringSymbol.cpp:54
std::string toString() const
Returns a string representation of the current object.
Definition StringSymbol.hpp:100
static StringSymbol fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition StringSymbol.cpp:69
void * toGraal() const
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition StringSymbol.cpp:44
std::optional< CandleSymbol > asCandleSymbol() const noexcept
Definition SymbolWrapper.hpp:382
SymbolWrapper(Symbol &&symbol) noexcept
Constructor for any wrapped symbol.
Definition SymbolWrapper.hpp:158
bool isIndexedEventSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:340
std::string toString() const
Returns a string representation of the current object.
Definition SymbolWrapper.hpp:286
static SymbolWrapper fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition SymbolWrapper.cpp:79
std::string toStringUnderlying() const
Returns a string representation of the underlying object.
Definition SymbolWrapper.hpp:301
std::unique_ptr< void, decltype(&SymbolWrapper::freeGraal)> toGraalUnique() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.hpp:277
bool isStringSymbol() const noexcept
Definition SymbolWrapper.hpp:312
std::optional< IndexedEventSubscriptionSymbol > asIndexedEventSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:348
bool isWildcardSymbol() const noexcept
Definition SymbolWrapper.hpp:326
void * toGraal() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.hpp:258
SymbolWrapper(const IndexedEventSubscriptionSymbol &indexedEventSubscriptionSymbol) noexcept
Constructor for IndexedEventSubscriptionSymbol.
Definition SymbolWrapper.hpp:197
const DataType & getData() const noexcept
Definition SymbolWrapper.hpp:389
std::string asStringSymbol() const noexcept
Definition SymbolWrapper.hpp:319
SymbolWrapper(const StringSymbol &stringSymbol) noexcept
Constructor for any wrapped string symbol.
Definition SymbolWrapper.hpp:171
std::optional< WildcardSymbol > asWildcardSymbol() const noexcept
Definition SymbolWrapper.hpp:333
SymbolWrapper(const CandleSymbol &candleSymbol) noexcept
Constructor for CandleSymbol.
Definition SymbolWrapper.hpp:225
SymbolWrapper(const WildcardSymbol &wildcardSymbol) noexcept
Constructor for any wrapped wildcard (*) symbol.
Definition SymbolWrapper.hpp:184
bool isTimeSeriesSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:357
SymbolWrapper(const TimeSeriesSubscriptionSymbol &timeSeriesSubscriptionSymbol) noexcept
Constructor for TimeSeriesSubscriptionSymbol.
Definition SymbolWrapper.hpp:211
bool isCandleSymbol() const noexcept
Definition SymbolWrapper.hpp:374
std::optional< TimeSeriesSubscriptionSymbol > asTimeSeriesSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:365
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.cpp:42
Utility class for parsing and formatting dates and times in ISO-compatible format.
Definition TimeFormat.hpp:29
std::string format(std::int64_t timestamp) const
Converts timestamp into string according to the format.
Definition TimeFormat.cpp:55
static const TimeFormat GMT
An instance of TimeFormat that corresponds to GMT timezone as returned by TimeZone::getTimeZone("GMT"...
Definition TimeFormat.hpp:41
std::int64_t parse(const StringLikeWrapper &value) const
Reads Date from String and returns timestamp.
Definition TimeFormat.cpp:49
static const TimeFormat DEFAULT
An instance of TimeFormat that corresponds to default timezone as returned by TimeZone::getDefault() ...
Definition TimeFormat.hpp:33
Value class for period of time with support for ISO8601 duration format.
Definition TimePeriod.hpp:19
static TimePeriod valueOf(std::chrono::milliseconds value)
Returns TimePeriod with value milliseconds.
Definition TimePeriod.hpp:42
static TimePeriod valueOf(const StringLikeWrapper &value)
Returns TimePeriod represented with a given string.
Definition TimePeriod.cpp:31
std::int64_t getNanos() const
Returns value in nanoseconds.
Definition TimePeriod.cpp:47
static const TimePeriod ZERO
Time-period of zero.
Definition TimePeriod.hpp:23
std::int32_t getSeconds() const
Returns value in seconds.
Definition TimePeriod.cpp:41
std::int64_t getTime() const
Returns value in milliseconds.
Definition TimePeriod.cpp:35
static const TimePeriod UNLIMITED
Time-period of "infinity" (time of std::numeric_limits<std::int64_t>::max() or LLONG_MAX).
Definition TimePeriod.hpp:26
static TimePeriod valueOf(std::int64_t value)
Returns TimePeriod with value milliseconds.
Definition TimePeriod.cpp:27
Represents time-series snapshots of some process that is evolving in time or actual events in some ex...
Definition TimeSeriesEvent.hpp:81
Mixin for wrapping Promise method calls for a void.
Definition Promise.hpp:177
void await(std::int32_t timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:209
void await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:224
void await() const
Wait for computation to complete and return its result or throw an exception in case of exceptional c...
Definition Promise.hpp:194
void getResult() const
Returns result of computation.
Definition Promise.hpp:184
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition WildcardSymbol.cpp:25
static const WildcardSymbol & fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition WildcardSymbol.cpp:31
void * toGraal() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition WildcardSymbol.cpp:15
static const WildcardSymbol ALL
Represents [wildcard] subscription to all events of the specific event type.
Definition WildcardSymbol.hpp:13
std::string toString() const
Returns string representation of this wildcard subscription symbol.
Definition WildcardSymbol.hpp:94
static const std::string RESERVED_PREFIX
Symbol prefix that is reserved for wildcard subscriptions.
Definition WildcardSymbol.hpp:28
The simple key-value structure that represents an endpoint's property.
Definition api.h:184
const char * key
The property's key.
Definition api.h:186
const char * value
The property's value.
Definition api.h:188