dxFeed Graal CXX API v8.1.0
Loading...
Searching...
No Matches
DXFeed.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
9
10#include "../event/LastingEvent.hpp"
11#include "../internal/CEntryPointErrors.hpp"
12#include "../internal/Common.hpp"
13#include "../internal/Isolate.hpp"
14#include "../internal/JavaObjectHandle.hpp"
15#include "../internal/managers/EntityManager.hpp"
16#include "../promise/Promise.hpp"
17#include "./DXFeedSubscription.hpp"
18
19#include <iterator>
20#include <memory>
21#include <type_traits>
22#include <utility>
23
24/**
25 * \addtogroup dxfcpp_api
26 * @{
27 */
28
30
31struct DXEndpoint;
32class EventTypeEnum;
33struct IndexedTxModelImpl;
34struct TimeSeriesTxModelImpl;
35
36namespace detail {
37
38/// Whether `T` is `std::shared_ptr<E>`, where `E` is a descendant of LastingEvent (the elements of
39/// DXFeed::getLastEvents).
40template <typename T> struct IsSharedPtrOfLastingEvent : std::false_type {};
41
42template <typename E> struct IsSharedPtrOfLastingEvent<std::shared_ptr<E>> : std::is_base_of<LastingEvent, E> {};
43
44} // namespace detail
45
46/**
47 * A collection of `std::shared_ptr<Event>`, where `Event` is a descendant of LastingEvent (the argument of
48 * DXFeed::getLastEvents): for example, `std::vector<std::shared_ptr<Quote>>` or `std::list<std::shared_ptr<Trade>>`.
49 */
50template <typename Collection>
51concept LastingEventCollection =
52 detail::IsSharedPtrOfLastingEvent<std::remove_cvref_t<decltype(*std::begin(std::declval<Collection &>()))>>::value;
53
54/**
55 * Main entry class for dxFeed API (<b>read it first</b>).
56 *
57 * <h3>Sample usage</h3>
58 *
59 * This section gives sample usage scenarios.
60 *
61 * <h4>Default singleton instance</h4>
62 *
63 * There is a singleton instance of the feed that is returned by DXFeed::getInstance() method.
64 * It is created on the first use with default configuration properties that are explained in detail in
65 * documentation for DXEndpoint class in the "Default properties" section.
66 *
67 * <p>In particular,
68 * you can provide a default address to connect and credentials using
69 * @ref DXEndpoint::DXFEED_ADDRESS_PROPERTY "dxfeed.address",
70 * @ref DXEndpoint::DXFEED_USER_PROPERTY "dxfeed.user", and
71 * @ref DXEndpoint::DXFEED_PASSWORD_PROPERTY "dxfeed.password"
72 * system properties or by putting them into
73 * @ref DXEndpoint::DXFEED_PROPERTIES_PROPERTY "dxfeed.properties"
74 * file in the same directory. dxFeed API samples come with a ready-to-use <b>"dxfeed.properties"</b>
75 * file that contains an address of dxFeed demo feed at <b>"demo.dxfeed.com:7300"</b> and
76 * demo access credentials.
77 *
78 * <h4>Subscribe for single event type</h4>
79 *
80 * The following code creates listener that prints mid-price for each quote
81 * and subscribes for quotes on SPDR S&P 500 ETF symbol:
82 * <pre><tt>
83 * auto sub = @ref DXFeed "DXFeed"::@ref DXFeed::getInstance() "getInstance"()->@ref DXFeed::createSubscription()
84 * "createSubscription"(Quote::TYPE);
85 *
86 * sub->@ref DXFeedSubscription::addEventListener() "addEventListener"<Quote>([](const auto& quotes) {
87 * for (const auto& quote : quotes) {
88 * std::cout << "Mid = " + (quote->@ref Quote::getBidPrice() "getBidPrice"() + quote->@ref Quote::getAskPrice()
89 * "getAskPrice"()) / 2) << std::endl;
90 * }
91 * });
92 *
93 * sub->@ref DXFeedSubscription::addSymbols() "addSymbols"("SPY");</tt></pre>
94 *
95 * Note, that order of calls is important here. By attaching listeners first and then setting
96 * a subscription, we ensure that the current quote gets received by the listener. See DXFeedSubscription::addSymbols()
97 * for details. If a set of symbols is changed first, then @ref DXFeedSubscription::addEventListener()
98 * "sub->addEventListener" raises an IllegalStateException in JVM to protect from hard-to-catch bugs with potentially
99 * missed events.
100 *
101 * <h4>Subscribe for multiple event types</h4>
102 *
103 * The following code creates listener that prints each received event and
104 * subscribes for quotes and trades on SPDR S&P 500 ETF symbol:
105 * <pre><tt>
106 * auto sub = @ref DXFeed "DXFeed"::@ref DXFeed::getInstance() "getInstance"()->@ref DXFeed::createSubscription()
107 * "createSubscription"({Quote::TYPE, Trade::TYPE});
108 *
109 * sub->@ref DXFeedSubscription::addEventListener() "addEventListener"([](auto&& events) {
110 * for (const auto& event : events) {
111 * std::cout << event << std::endl;
112 * }
113 * });
114 *
115 * sub->@ref DXFeedSubscription::addSymbols() "addSymbols"("SPY");</tt></pre>
116 *
117 * <h4>Subscribe for event and query periodically its last value</h4>
118 *
119 * The following code subscribes for trades on SPDR S&P 500 ETF symbol and
120 * prints last trade every second.
121 *
122 * <pre><tt>
123 * using namespace std::chrono_literals;
124 *
125 * auto sub = @ref DXFeed "DXFeed"::@ref DXFeed::getInstance() "getInstance"()->@ref DXFeed::createSubscription()
126 * "createSubscription"({Trade::TYPE});
127 *
128 * sub->@ref DXFeedSubscription::addSymbols() "addSymbols"("SPY");
129 *
130 * auto feed = @ref DXFeed "DXFeed"::@ref DXFeed::getInstance() "getInstance"();
131 *
132 * while (true) {
133 * std::cout << System.out.println(feed->@ref DXFeed::getLastEvent() "getLastEvent"(Trade::create("SPY")));
134 * std::this_thread::sleep_for(1000ms);
135 * }</tt></pre>
136 *
137 * <h3>Threads and locks</h3>
138 *
139 * This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
140 */
142 /// The alias to a type of shared pointer to the DXFeed object
143 using Ptr = std::shared_ptr<DXFeed>;
144
145 /// The alias to a type of unique pointer to the DXFeed object
147
148 friend struct DXEndpoint;
149 friend struct TimeSeriesTxModelImpl;
150 friend struct IndexedTxModelImpl;
151
152 private:
153 JavaObjectHandle<DXFeed> handle_{};
154 static std::shared_ptr<DXFeed> create(void *feedHandle);
155
156 void *getLastEventPromiseImpl(const EventTypeEnum &eventType, const SymbolWrapper &symbol) const;
157
158 void *getLastEventsPromisesImpl(const EventTypeEnum &eventType, void *graalSymbolList) const;
159
160 void *getIndexedEventsPromiseImpl(const EventTypeEnum &eventType, const SymbolWrapper &symbol,
161 const IndexedEventSource &source) const;
162
163 void *getTimeSeriesPromiseImpl(const EventTypeEnum &eventType, const SymbolWrapper &symbol, std::int64_t fromTime,
164 std::int64_t toTime) const;
165
166 std::shared_ptr<EventType> getLastEventIfSubscribedImpl(const EventTypeEnum &eventType,
167 const SymbolWrapper &symbol) const;
168
169 std::vector<std::shared_ptr<EventType>> getIndexedEventsIfSubscribedImpl(const EventTypeEnum &eventType,
170 const SymbolWrapper &symbol,
171 const IndexedEventSource &source) const;
172
173 std::vector<std::shared_ptr<EventType>> getTimeSeriesIfSubscribedImpl(const EventTypeEnum &eventType,
174 const SymbolWrapper &symbol,
175 std::int64_t fromTime,
176 std::int64_t toTime) const;
177
178 JavaObjectHandle<DXFeedSubscription>
179 createTimeSeriesSubscriptionHandleFromEventClassList(const std::unique_ptr<EventClassList> &list) const;
180
181 protected:
182 DXFeed() noexcept;
183
184 public:
185 ~DXFeed() noexcept override;
186
187 /**
188 * Returns a default application-wide singleton instance of feed. Most applications use only a single
189 * data-source and should rely on this method to get one. This is a shortcut to
190 * @ref DXEndpoint "DXEndpoint"::@ref DXEndpoint::getInstance() "getInstance()"->@ref DXEndpoint::getFeed()
191 * "getFeed()".
192 *
193 * @return The DXFeed instance
194 */
195 static std::shared_ptr<DXFeed> getInstance();
196
197 /**
198 * Attaches the given subscription to this feed. This method does nothing if the
199 * corresponding subscription is already attached to this feed.
200 *
201 * <p> This feed publishes data to the attached subscription.
202 * Application can attach an event listener via DXFeedSubscription::addEventListener to get notified about data
203 * changes and can change its data subscription via DXFeedSubscription methods.
204 *
205 * <h3>Implementation notes</h3>
206 *
207 * This method adds a non-serializable ObservableSubscriptionChangeListener for the given subscription
208 * via DXFeedSubscription::addChangeListener method.
209 *
210 * @param subscription The subscription.
211 * @see DXFeedSubscription
212 */
213 void attachSubscription(const std::shared_ptr<DXFeedSubscription> &subscription) const;
214
215 /**
216 * Detaches the given subscription from this feed. This method does nothing if the
217 * corresponding subscription is not attached to this feed.
218 *
219 * <h3>Implementation notes</h3>
220 *
221 * This method removes ObservableSubscriptionChangeListener from the given subscription
222 * via DXFeedSubscription::removeChangeListener method.
223 *
224 * @param subscription The subscription.
225 * @see DXFeedSubscription
226 */
227 void detachSubscription(const std::shared_ptr<DXFeedSubscription> &subscription) const;
228
229 /**
230 * Detaches the given subscription from this feed and clears data delivered to this subscription
231 * by publishing empty events. This method does nothing if the
232 * corresponding subscription is not attached to this feed.
233 *
234 * @param subscription The subscription.
235 * @see DXFeed::detachSubscription()
236 */
237 void detachSubscriptionAndClear(const std::shared_ptr<DXFeedSubscription> &subscription) const;
238
239 /**
240 * Returns the last event for the specified event instance.
241 * This method works only for event types that implement the LastingEvent marker interface.
242 * This method <b>does not</b> make any remote calls to the uplink data provider.
243 * It just retrieves the last received event from the local cache of this feed.
244 * The events are stored in the cache only if there is some attached DXFeedSubscription that is subscribed to the
245 * corresponding symbol and event type.
246 * WildcardSymbol::ALL subscription does not count for that purpose.
247 *
248 * <p>Use @ref ::getLastEventPromise() "getLastEventPromise" method if an event needs to be requested in the absence
249 * of subscription.
250 *
251 * <p> This method fills in the values for the last event into the `event` argument.
252 * If the last event is not available for any reason (no subscription, no connection to uplink, etc.)
253 * then the event object is not changed.
254 * This method always returns the same `event` instance passed to it as an argument.
255 *
256 * <p>This method provides no way to distinguish a case when there is no subscription from the case when
257 * there is a subscription, but the event data have not arrived yet. It is recommended to use
258 * @ref ::getLastEventIfSubscribed() "getLastEventIfSubscribed" method instead of this `getLastEvent` method to
259 * fail-fast in case when the subscription was supposed to be set by the logic of the code, since
260 * @ref ::getLastEventIfSubscribed() "getLastEventIfSubscribed" method returns `std::shared_ptr<E>(nullptr)` when
261 * there is no subscription.
262 *
263 * <p>Note that this method does not work when DXEndpoint was created with
264 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (never fills in the event).
265 *
266 * @tparam E The type of event.
267 * @param event The event.
268 * @return The same event.
269 */
270 template <Derived<LastingEvent> E> std::shared_ptr<E> getLastEvent(std::shared_ptr<E> event) {
271 if (auto last = getLastEventIfSubscribed<E>(event->getEventSymbol())) {
272 event->assign(last);
273 }
274
275 return event;
276 }
277
278 /**
279 * Returns the last events for the specified list of event instances.
280 * This is a bulk version of @ref ::getLastEvent() "getLastEvent" method.
281 *
282 * <p>Note, that this method does not work when DXEndpoint was created with
283 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role.
284 *
285 * <p>For a named collection (an lvalue) this method returns a reference to it. A temporary collection is returned
286 * by value (moved), so the result can be used after the full expression, for example in a range-based for loop:
287 * `for (const auto &quote : feed->getLastEvents(std::vector{std::make_shared<Quote>("AAPL")}))`.
288 *
289 * @tparam Collection The collection type, a LastingEventCollection.
290 * @param events The collection of shared ptrs of events.
291 * @return The same collection of shared ptrs of events: a reference to `events` for an lvalue, `events` moved for
292 * an rvalue.
293 */
294 template <LastingEventCollection Collection> Collection getLastEvents(Collection &&events) {
295 for (const auto &event : events) {
296 getLastEvent(event);
297 }
298
299 return std::forward<Collection>(events);
300 }
301
302 /**
303 * Returns the last event for the specified event type and symbol if there is a subscription for it.
304 * This method works only for event types that implement the LastingEvent marker interface.
305 * This method <b>does not</b> make any remote calls to the uplink data provider.
306 * It just retrieves the last received event from the local cache of this feed.
307 * The events are stored in the cache only if there is some attached DXFeedSubscription that is subscribed to the
308 * corresponding event type and symbol.
309 * The subscription can also be permanently defined using DXEndpoint properties.
310 * WildcardSymbol::ALL subscription does not count for that purpose.
311 * If there is no subscription, then this method returns `std::shared_ptr<E>(nullptr)`.
312 *
313 * <p>If there is a subscription, but the event has not arrived from the uplink data provider,
314 * this method returns a non-initialized event object: its @ref EventType#getEventSymbol() "eventSymbol"
315 * property is set to the requested symbol, but all the other properties have their default values.
316 *
317 * <p>Use @ref ::getLastEventPromise() "getLastEventPromise" method if an event needs to be requested in the
318 * absence of subscription.
319 *
320 * <p>Note that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
321 * "STREAM_FEED" role (always returns `std::shared_ptr<E>(nullptr)`).
322 *
323 * @tparam E The type of event.
324 * @param symbol The symbol.
325 * @return the event or `std::shared_ptr<E>(nullptr)` if there is no subscription for the specified event type and
326 * symbol.
327 */
328 template <Derived<LastingEvent> E> std::shared_ptr<E> getLastEventIfSubscribed(const SymbolWrapper &symbol) {
329 // https://youtrack.jetbrains.com/issue/RSCPP-15139
330 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67965
331 // https://bugs.llvm.org/show_bug.cgi?id=25179
332 const auto event = getLastEventIfSubscribedImpl(E::TYPE, symbol);
333
334 // No subscription for the symbol: the native SDK returns no event.
335 if (!event) {
336 return {};
337 }
338
339 // ReSharper disable once CppRedundantTemplateKeyword
340 return event->template sharedAs<E>();
341 }
342
343 /**
344 * Creates a new subscription for a single event type that is <i>attached</i> to this feed.
345 * This method creates a new DXFeedSubscription and invokes DXFeed::attachSubscription().
346 *
347 * Example:
348 * ```cpp
349 * auto sub = dxfcpp::DXFeed::getInstance()->createSubscription(dxfcpp::Quote::TYPE);
350 * ```
351 *
352 * @param eventType The type of event
353 * @return The new subscription
354 */
355 std::shared_ptr<DXFeedSubscription> createSubscription(const EventTypeEnum &eventType) const;
356
357 /**
358 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
359 * This method creates new DXFeedSubscription and invokes DXFeed::attachSubscription().
360 *
361 * Example:
362 * ```cpp
363 * auto eventTypes = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
364 *
365 * auto sub = dxfcpp::DXFeed::getInstance()->createSubscription(eventTypes.begin(), eventTypes.end());
366 * ```
367 *
368 * ```cpp
369 * std::vector types{dxfcpp::Quote::TYPE, dxfcpp::Trade::TYPE, dxfcpp::Summary::TYPE};
370 *
371 * auto sub = dxfcpp::DXFeed::getInstance()->createSubscription(types.begin(), types.end());
372 * ```
373 *
374 * ```cpp
375 * std::set types{dxfcpp::Quote::TYPE, dxfcpp::Trade::TYPE, dxfcpp::Summary::TYPE};
376 * auto endpoint = dxfcpp::DXEndpoint::newBuilder()->withRole(dxfcpp::DXEndpoint::Role::FEED)->build();
377 * auto sub = endpoint->getFeed()->createSubscription(eventTypes.begin(), eventTypes.end());
378 *
379 * endpoint->connect("demo.dxfeed.com:7300");
380 * ```
381 *
382 * @tparam EventTypeIt The iterator type of the collection of event types
383 * @param begin The start iterator
384 * @param end The end iterator
385 * @return The new subscription
386 */
387 template <typename EventTypeIt>
388 std::shared_ptr<DXFeedSubscription> createSubscription(EventTypeIt begin, EventTypeIt end) const {
389 if constexpr (Debugger::isDebug) {
390 // ReSharper disable once CppDFAUnreachableCode
391 Debugger::debug("{}::createSubscription(eventTypes = " + namesToString(begin, end) + ")");
392 }
393
394 auto sub = DXFeedSubscription::create(begin, end);
395
397
398 return sub;
399 }
400
401 /**
402 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
403 * This method creates new DXFeedSubscription and invokes DXFeed::attachSubscription().
404 *
405 * Example:
406 * ```cpp
407 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
408 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
409 * ```
410 *
411 * @param eventTypes The initializer list of event types
412 * @return The new subscription
413 */
414 std::shared_ptr<DXFeedSubscription> createSubscription(std::initializer_list<EventTypeEnum> eventTypes) const;
415
416 /**
417 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
418 * This method creates a new DXFeedSubscription and invokes DXFeed::attachSubscription().
419 *
420 * Example:
421 * ```cpp
422 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
423 * auto sub = endpoint->getFeed()->createSubscription(std::unordered_set{dxfcpp::Quote::TYPE,
424 * dxfcpp::TimeAndSale::TYPE});
425 * ```
426 *
427 * ```cpp
428 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
429 * std::vector types = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
430 * auto sub = endpoint->getFeed()->createSubscription(types);
431 * ```
432 *
433 * @tparam EventTypesCollection The class of the collection of event types
434 * @param eventTypes The collection of event types
435 * @return The new subscription
436 */
437 template <typename EventTypesCollection>
438 std::shared_ptr<DXFeedSubscription> createSubscription(const EventTypesCollection &eventTypes) const {
439 if constexpr (Debugger::isDebug) {
440 // ReSharper disable once CppDFAUnreachableCode
441 auto begin = std::begin(eventTypes);
442 auto end = std::end(eventTypes);
443
444 Debugger::debug(toString() + "::createSubscription(eventTypes = " + namesToString(begin, end) + ")");
445 }
446
447 auto sub = DXFeedSubscription::create(eventTypes);
448
450
451 return sub;
452 }
453
454 /**
455 * Creates a new subscription for a single event type that is <i>attached</i> to this feed.
456 * This method creates a new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
457 *
458 * Example:
459 * ```cpp
460 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
461 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription(dxfcpp::TimeAndSale::TYPE);
462 * ```
463 *
464 * @param eventType The type of event
465 * @return The new subscription
466 */
467 std::shared_ptr<DXFeedTimeSeriesSubscription> createTimeSeriesSubscription(const EventTypeEnum &eventType) const;
468
469 /**
470 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
471 * This method creates new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
472 *
473 * Example:
474 * ```cpp
475 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
476 * auto eventTypes = {dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE};
477 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription(eventTypes.begin(), eventTypes.end());
478 * ```
479 *
480 * ```cpp
481 * std::vector types{dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE, dxfcpp::Candle::TYPE};
482 *
483 * auto sub = dxfcpp::DXFeed::getInstance()->createTimeSeriesSubscription(types.begin(), types.end());
484 * ```
485 *
486 * ```cpp
487 * std::set types{dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE, dxfcpp::Candle::TYPE};
488 * auto endpoint = dxfcpp::DXEndpoint::newBuilder()->withRole(dxfcpp::DXEndpoint::Role::FEED)->build();
489 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription(eventTypes.begin(), eventTypes.end());
490 *
491 * endpoint->connect("demo.dxfeed.com:7300");
492 * ```
493 *
494 * @tparam EventTypeIt The iterator type of the collection of event types
495 * @param begin The start iterator
496 * @param end The end iterator
497 * @return The new subscription
498 */
499 template <typename EventTypeIt>
501 EventTypeIt end) const {
502 if constexpr (Debugger::isDebug) {
503 // ReSharper disable once CppDFAUnreachableCode
504 Debugger::debug("{}::createTimeSeriesSubscription(eventTypes = " + namesToString(begin, end) + ")");
505 }
506
507 for (EventTypeIt iter = begin; iter != end; ++iter) {
508 if (!iter->isTimeSeries()) {
509 throw InvalidArgumentException("DXFeed::createTimeSeriesSubscription(): event type " +
510 iter->getClassName() + " is not TimeSeries");
511 }
512 }
513
514 auto list = EventClassList::create(begin, end);
515 auto sub = RequireMakeShared<DXFeedTimeSeriesSubscription>::createShared(
516 begin, end, std::move(createTimeSeriesSubscriptionHandleFromEventClassList(list)));
517 auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);
518
519 dxfcpp::ignoreUnused(id);
520
522
523 return sub;
524 }
525
526 /**
527 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
528 * This method creates a new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
529 *
530 * Example:
531 * ```cpp
532 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
533 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription({dxfcpp::Underlying::TYPE,
534 * dxfcpp::TimeAndSale::TYPE});
535 * ```
536 *
537 * @param eventTypes The initializer list of event types
538 * @return The new subscription
539 */
540 std::shared_ptr<DXFeedTimeSeriesSubscription>
541 createTimeSeriesSubscription(std::initializer_list<EventTypeEnum> eventTypes) const;
542
543 /**
544 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
545 * This method creates a new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
546 *
547 * Example:
548 * ```cpp
549 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
550 * auto sub =
551 * endpoint->getFeed()->createTimeSeriesSubscription(std::unordered_set{dxfcpp::Underlying::TYPE,
552 * dxfcpp::TimeAndSale::TYPE});
553 * ```
554 *
555 * ```cpp
556 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
557 * std::vector types = {dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE};
558 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription(types);
559 * ```
560 *
561 * @tparam EventTypesCollection The class of the collection of event types
562 * @param eventTypes The collection of event types
563 * @return The new subscription
564 */
565 template <typename EventTypesCollection>
566 std::shared_ptr<DXFeedTimeSeriesSubscription>
567 createTimeSeriesSubscription(const EventTypesCollection &eventTypes) const {
568 if constexpr (Debugger::isDebug) {
569 // ReSharper disable once CppDFAUnreachableCode
570 auto dbgBegin = std::begin(eventTypes);
571 auto dbgEnd = std::end(eventTypes);
572
573 // ReSharper disable once CppDFAUnreachableCode
574 Debugger::debug(toString() +
575 "::createTimeSeriesSubscription(eventTypes = " + namesToString(dbgBegin, dbgEnd) + ")");
576 }
577
578 auto begin = std::begin(eventTypes);
579 auto end = std::end(eventTypes);
580
581 return createTimeSeriesSubscription(begin, end);
582 }
583
584 /**
585 * Requests the last event for the specified event type and symbol.
586 * This method works only for event types that implement LastingEvent marker "interface".
587 * This method requests the data from the uplink data provider, creates a new event of the specified event type
588 * and completes the resulting promise with this event.
589 *
590 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
591 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
592 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
593 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
594 * If the event is permanently not available (not supported), then the promise completes exceptionally with
595 * JavaException "IllegalArgumentException".
596 *
597 * <p>There is a bulk version of this method that works much faster for a single event type and multiple symbols.
598 * See getLastEventsPromises().
599 *
600 * <p>Note that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
601 * "STREAM_FEED" role (promise completes exceptionally).
602 *
603 * @tparam E The type of event.
604 * @param symbol The symbol.
605 * @return The promise for the result of the request.
606 */
607 template <Derived<LastingEvent> E>
608 std::shared_ptr<Promise<std::shared_ptr<E>>> getLastEventPromise(const SymbolWrapper &symbol) const {
609 return std::make_shared<Promise<std::shared_ptr<E>>>(getLastEventPromiseImpl(E::TYPE, symbol));
610 }
611
612 /**
613 * Requests the last events for the specified event type and a collection of symbols.
614 * This method works only for event types that implement LastingEvent marker "interface".
615 * This method requests the data from the uplink data provider,
616 * creates new events of the specified evet type and completes the resulting promises with these events.
617 *
618 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
619 *
620 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
621 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
622 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
623 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
624 * If the event is permanently not available (not supported), then the promise
625 * completes exceptionally with JavaException "IllegalArgumentException".
626 *
627 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
628 * events) and wait with a single timeout for all of them:
629 *
630 * ```cpp
631 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
632 * std::vector<dxfcpp::SymbolWrapper> symbols{"AAPL&Q", "IBM&Q"};
633 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>(symbols.begin(), symbols.end());
634 *
635 * // combine the list of promises into one with Promises utility method and wait
636 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
637 *
638 * // now iterate the promises to retrieve results
639 * for (const auto& promise : *promises) {
640 * auto quote = promise.getResult(); // InvalidArgumentException if result is nullptr
641 * doSomethingWith(quote);
642 * // std::cout << quote->toString() << std::endl;
643 * }
644 * ```
645 *
646 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
647 * "STREAM_FEED" role (promise completes exceptionally).
648 *
649 * @tparam E The event type.
650 * @tparam SymbolIt The symbols collection's iterator type.
651 * @param begin The beginning of the collection of symbols (SymbolWrapper).
652 * @param end The end of the collection of symbols (SymbolWrapper).
653 * @return The list of promises for the result of the requests, one item in list per symbol.
654 */
655 template <Derived<LastingEvent> E, typename SymbolIt>
656 std::shared_ptr<PromiseList<E>> getLastEventsPromises(SymbolIt begin, SymbolIt end) const {
657 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
658
659 return PromiseList<E>::create(getLastEventsPromisesImpl(E::TYPE, list.get()));
660 }
661
662 /**
663 * Requests the last events for the specified event type and a collection of symbols.
664 * This method works only for event types that implement LastingEvent marker "interface".
665 * This method requests the data from the uplink data provider,
666 * creates new events of the specified evet type and completes the resulting promises with these events.
667 *
668 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
669 *
670 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
671 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
672 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
673 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
674 * If the event is permanently not available (not supported), then the promise
675 * completes exceptionally with JavaException "IllegalArgumentException".
676 *
677 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
678 * events) and wait with a single timeout for all of them:
679 *
680 * ```cpp
681 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
682 * std::vector<dxfcpp::SymbolWrapper> symbols{"AAPL&Q", "IBM&Q"};
683 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>(symbols);
684 *
685 * // combine the list of promises into one with Promises utility method and wait
686 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
687 *
688 * // now iterate the promises to retrieve results
689 * for (const auto& promise : *promises) {
690 * doSomethingWith(promise.getResult()); // InvalidArgumentException if result is nullptr
691 * }
692 * ```
693 *
694 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
695 * "STREAM_FEED" role (promise completes exceptionally).
696 *
697 * @tparam E The event type.
698 * @tparam SymbolsCollection The symbol collection's type.
699 * @param collection The symbol collection.
700 * @return The list of promises for the result of the requests, one item in the list per symbol.
701 */
702 template <Derived<LastingEvent> E, ConvertibleToSymbolWrapperCollection SymbolsCollection>
703 std::shared_ptr<PromiseList<E>> getLastEventsPromises(const SymbolsCollection &collection) const {
704 auto begin = std::begin(collection);
705 auto end = std::end(collection);
706
707 return getLastEventsPromises<E>(begin, end);
708 }
709
710 /**
711 * Requests the last events for the specified event type and a collection of symbols.
712 * This method works only for event types that implement LastingEvent marker "interface".
713 * This method requests the data from the uplink data provider,
714 * creates new events of the specified event type and completes the resulting promises with these events.
715 *
716 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
717 *
718 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
719 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
720 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
721 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
722 * If the event is permanently not available (not supported), then the promise
723 * completes exceptionally with JavaException "IllegalArgumentException".
724 *
725 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
726 * events) and wait with a single timeout for all of them:
727 *
728 * ```cpp
729 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
730 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>({"AAPL&Q", "IBM&Q"});
731 *
732 * // combine the list of promises into one with Promises utility method and wait
733 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
734 *
735 * // now iterate the promises to retrieve results
736 * for (const auto& promise : *promises) {
737 * doSomethingWith(promise.getResult()); // InvalidArgumentException if result is nullptr
738 * }
739 * ```
740 *
741 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
742 * "STREAM_FEED" role (promise completes exceptionally).
743 *
744 * @tparam E The event type.
745 * @param collection The symbol collection.
746 * @return The list of promises for the result of the requests, one item in list per symbol.
747 */
748 template <Derived<LastingEvent> E>
749 std::shared_ptr<PromiseList<E>> getLastEventsPromises(std::initializer_list<SymbolWrapper> collection) const {
750 return getLastEventsPromises<E>(collection.begin(), collection.end());
751 }
752
753 /**
754 * Requests a container of indexed events for the specified event type, symbol and source.
755 * This method works only for event types that implement IndexedEvent "interface".
756 * This method requests the data from the uplink data provider, creates a container of events of the specified
757 * event type `E` and completes the resulting promise with this container. The events are ordered by @ref
758 * IndexedEvent::getIndex() "index" in the container.
759 *
760 * <p> This method is designed for retrieval of a snapshot only.
761 * Use IndexedEventModel if you need a container of indexed events that updates in real time.
762 *
763 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
764 * If the events are not available for any transient reason (no subscription, no connection to uplink, etc.),
765 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
766 * Use Promise::await() method to specify timeout while waiting for promise to complete.
767 * If the events are permanently not available (not supported), then the promise
768 * completes exceptionally with JavaException "IllegalArgumentException".
769 *
770 * <p>Note that this method does not work when DXEndpoint was created with
771 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (promise completes exceptionally).
772 *
773 * <h3>Event source.</h3>
774 *
775 * Use the @ref IndexedEventSource::DEFAULT "DEFAULT" value for `source` with events that do not
776 * have multiple sources (like Series). For events with multiple sources (like Order,
777 * AnalyticOrder, OtcMarketsOrder and SpreadOrder), use an event-specific source class (for example, OrderSource).
778 * This method does not support <em>synthetic</em> sources of orders (orders that are automatically
779 * generated from Quote events).
780 *
781 * <p>This method does not accept an instance of IndexedEventSubscriptionSymbol as a `symbol`.
782 * The later class is designed for use with DXFeedSubscription and to observe source-specific subscription
783 * in DXPublisher.
784 *
785 * <h3>Event flags and consistent snapshot</h3>
786 *
787 * This method completes promise only when a consistent snapshot of indexed events has been received from
788 * the data feed. The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
789 * is always zero.
790 *
791 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
792 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
793 * event class for details on how they should be published.
794 *
795 * @tparam E The type of event.
796 * @param symbol The symbol.
797 * @param source The source.
798 * @return The promise for the result of the request.
799 */
800 template <Derived<IndexedEvent> E>
802 getIndexedEventsPromise(const SymbolWrapper &symbol, const IndexedEventSource &source) const {
803 return std::make_shared<Promise<std::vector<std::shared_ptr<E>>>>(
804 getIndexedEventsPromiseImpl(E::TYPE, symbol, source));
805 }
806
807 /**
808 * Returns a vector of indexed events for the specified event type, symbol and source if there is a subscription
809 * for it. This method works only for event types that implement IndexedEvent interface. This method <b>does not</b>
810 * make any remote calls to the uplink data provider. It just retrieves last received events from the local cache of
811 * this feed. The events are stored in the cache only if there is some attached DXFeedSubscription that is
812 * subscribed to the corresponding event type, symbol and source. The subscription can also be permanently defined
813 * using DXEndpoint properties. If there is no subscription, then this method returns an empty vector.
814 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
815 *
816 * The events are ordered by @ref IndexedEvent::getIndex() "index" in the vector.
817 *
818 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
819 * this method returns an empty vector.
820 *
821 * <p>Use @ref DXFeed::getIndexedEventsPromise() "getIndexedEventsPromise" method
822 * if events need to be requested in the absence of subscription.
823 *
824 * <p>Note that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
825 * "STREAM_FEED" role (always returns an empty vector).
826 *
827 * <h3>Event source.</h3>
828 *
829 * Use the @ref IndexedEventSource::DEFAULT "DEFAULT" value for `source` with events that do not
830 * have multiple sources (like Series). For events with multiple sources (like Order, AnalyticOrder,
831 * OtcMarketsOrder and SpreadOrder), use an event-specific source class (for example, OrderSource).
832 * This method does not support <em>synthetic</em> sources of orders (orders that are automatically generated from
833 * Quote events).
834 *
835 * <p>This method does not accept an instance of IndexedEventSubscriptionSymbol as a `symbol`.
836 * The later class is designed for use with DXFeedSubscription and to observe source-specific subscription
837 * in @DXPublisher.
838 *
839 * <h3>Event flags and consistent snapshot</h3>
840 *
841 * This method returns a vector of events that are currently in the cache without any wait or delay, and it <b>does
842 * not</b> guarantee that a consistent snapshot of events is returned. See IndexedEvent documentation for details.
843 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
844 * is always zero regardless. Use @ref DXFeed::getIndexedEventsPromise() "getIndexedEventsPromise" method
845 * if a consistent snapshot of events needs to be requested.
846 *
847 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
848 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
849 * event class for details on how they should be published.
850 *
851 * @tparam E The type of event.
852 * @param symbol The symbol.
853 * @param source The source.
854 * @return The vector of events or an empty vector if there is no subscription for the specified event
855 * type, symbol and source.
856 */
857 template <Derived<IndexedEvent> E>
858 std::vector<std::shared_ptr<E>> getIndexedEventsIfSubscribed(const SymbolWrapper &symbol,
859 const IndexedEventSource &source) const {
860 return convertEvents<EventType, E>(getIndexedEventsIfSubscribedImpl(E::TYPE, symbol, source));
861 }
862
863 /**
864 * Requests time series of events for the specified event type, symbol and a range of time.
865 *
866 * This method works only for event types that implement TimeSeriesEvent "interface".
867 * This method requests the data from the uplink data provider, creates a vector of events of the specified
868 * event type `E` and completes the resulting promise with this container.
869 *
870 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the container.
871 *
872 * <p> This method is designed for retrieval of a snapshot only.
873 * Use TimeSeriesEventModel if you need a vector of time-series events that updates in real time.
874 *
875 * <p>The range and depth of events that are available with this service is typically constrained by
876 * upstream data provider.
877 *
878 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
879 *
880 * If events are not available for any transient reason (no subscription, no connection to uplink, etc.),
881 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
882 * Use EventsPromiseMixin::await() method to specify timeout while waiting for promise to complete.
883 * If events are permanently not available (not supported), then the promise
884 * completes exceptionally with JavaException "IllegalArgumentException".
885 *
886 * <p>Note, that this method does not work when DXEndpoint was created with
887 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (promise completes exceptionally).
888 *
889 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
890 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription
891 * in DXPublisher.
892 *
893 * <h3>Event flags</h3>
894 *
895 * This method completes promise only when a consistent snapshot of time series has been received from
896 * the data feed. The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting
897 * container is always zero.
898 *
899 * <p>Note that the resulting container <em>should not</em> be used with DXPublisher::publishEvents() method,
900 * because the latter expects events in a different order and with an appropriate flags set. See documentation on a
901 * specific event class for details on how they should be published.
902 *
903 * @tparam E The type of event.
904 * @param symbol The symbol.
905 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
906 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
907 * Use `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX` macro to retrieve events without an
908 * upper limit on time.
909 * @return The promise for the result of the request.
910 */
911 template <Derived<TimeSeriesEvent> E>
912 std::shared_ptr<Promise<std::vector<std::shared_ptr<E>>>>
913 getTimeSeriesPromise(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const {
914 return std::make_shared<Promise<std::vector<std::shared_ptr<E>>>>(
915 getTimeSeriesPromiseImpl(E::TYPE, symbol, fromTime, toTime));
916 }
917
918 /**
919 * Returns time series of events for the specified event type, symbol and a range of time if there is a
920 * subscription for it. This method <b>does not</b> make any remote calls to the uplink data provider. It just
921 * retrieves last received events from the local cache of this feed. The events are stored in the cache only if
922 * there is some attached DXFeedSubscription that is subscribed to the corresponding event type, symbol and time.
923 * The subscription can also be permanently defined using DXEndpoint properties.
924 * If there is no subscription, then this method returns an empty vector.
925 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
926 *
927 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the vector.
928 *
929 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
930 * this method returns an empty vector.
931 *
932 * <p>Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
933 * if events need to be requested in the absence of subscription.
934 *
935 * <p>Note that this method does not work when DXEndpoint was created with
936 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (always returns an empty vector).
937 *
938 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
939 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription in
940 * DXPublisher.
941 *
942 * <h3>Event flags and consistent snapshot</h3>
943 *
944 * This method returns a vector of events that are currently in the cache without any wait or delay,
945 * and it <b>does not</b> guarantee that a consistent snapshot of events is returned.
946 * See IndexedEvent documentation for details.
947 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
948 * is always zero regardless. Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
949 * if a consistent snapshot of events needs to be requested.
950 *
951 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
952 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
953 * event class for details on how they should be published.
954 *
955 * @tparam E The type of event.
956 * @param symbol The symbol.
957 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
958 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
959 * Use `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX` macro to retrieve events without an
960 * upper limit on time.
961 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
962 * and time range.
963 */
964 template <Derived<TimeSeriesEvent> E>
965 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime,
966 std::int64_t toTime) const {
967 return convertEvents<EventType, E>(getTimeSeriesIfSubscribedImpl(E::TYPE, symbol, fromTime, toTime));
968 }
969
970 /**
971 * Returns time series of events for the specified event type, symbol and a range of time if there is a
972 * subscription for it. This method <b>does not</b> make any remote calls to the uplink data provider. It just
973 * retrieves last received events from the local cache of this feed. The events are stored in the cache only if
974 * there is some attached DXFeedSubscription that is subscribed to the corresponding event type, symbol and time.
975 * The subscription can also be permanently defined using DXEndpoint properties.
976 * If there is no subscription, then this method returns an empty vector.
977 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
978 *
979 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the vector.
980 *
981 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
982 * this method returns an empty vector.
983 *
984 * <p>Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
985 * if events need to be requested in the absence of subscription.
986 *
987 * <p>Note that this method does not work when DXEndpoint was created with
988 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (always returns an empty vector).
989 *
990 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
991 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription in
992 * DXPublisher.
993 *
994 * <h3>Event flags and consistent snapshot</h3>
995 *
996 * This method returns a vector of events that are currently in the cache without any wait or delay,
997 * and it <b>does not</b> guarantee that a consistent snapshot of events is returned.
998 * See IndexedEvent documentation for details.
999 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
1000 * is always zero regardless. Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
1001 * if a consistent snapshot of events needs to be requested.
1002 *
1003 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
1004 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
1005 * event class for details on how they should be published.
1006 *
1007 * @tparam E The type of event.
1008 * @param symbol The symbol.
1009 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
1010 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
1011 * Use `std::chrono::milliseconds(std::numeric_limits<std::int64_t>::max())`
1012 * or `std::chrono::milliseconds(LLONG_MAX)` to retrieve events without an upper limit on time.
1013 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
1014 * and time range.
1015 */
1016 template <Derived<TimeSeriesEvent> E>
1017 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
1018 std::chrono::milliseconds fromTime,
1019 std::chrono::milliseconds toTime) const {
1020 return getTimeSeriesIfSubscribed<E>(symbol, fromTime.count(), toTime.count());
1021 }
1022
1023 /**
1024 * Returns time series of events for the specified event type, symbol and a range of time (without an upper limit
1025 * on time) if there is a subscription for it.
1026 * @tparam E The type of event.
1027 * @param symbol The symbol.
1028 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
1029 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
1030 * and time range.
1031 */
1032 template <Derived<TimeSeriesEvent> E>
1033 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
1034 std::int64_t fromTime) const {
1035 return getTimeSeriesIfSubscribed<E>(symbol, fromTime, std::numeric_limits<std::int64_t>::max());
1036 }
1037
1038 /**
1039 * Returns time series of events for the specified event type, symbol and a range of time (without an upper limit
1040 * on time) if there is a subscription for it.
1041 * @tparam E The type of event.
1042 * @param symbol The symbol.
1043 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
1044 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
1045 * and time range.
1046 */
1047 template <Derived<TimeSeriesEvent> E>
1048 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
1049 std::chrono::milliseconds fromTime) const {
1050 return getTimeSeriesIfSubscribed<E>(symbol, fromTime.count());
1051 }
1052
1053 std::string toString() const override;
1054};
1055
1057
1058/// @}
1059
#define DXFCPP_MACRO_CONCAT_INNER(a, b)
Definition Common.hpp:135
#define DXFCPP_MACRO_CONCAT(a, b)
Definition Common.hpp:134
#define DXFCPP_MACRO_UNIQUE_NAME(base)
Definition Common.hpp:136
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCXX_DISABLE_CLANG_WARNINGS_PUSH(warnings)
Definition Conf.hpp:65
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:47
#define DXFCXX_DISABLE_CLANG_WARNINGS_POP()
Definition Conf.hpp:67
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:49
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
#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_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:721
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:754
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1002
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1192
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:781
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1138
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1053
#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:951
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:1104
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 the connection is not...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the 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:840
#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:1121
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:737
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:828
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:1019
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 a listener notified about changes in state property.
Definition DXEndpoint.cpp:1164
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:74
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:798
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1187
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:1087
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:934
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:688
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:1036
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:968
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:985
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 an 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 the 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:887
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:863
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:704
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:910
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1197
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:1070
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:866
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:348
std::shared_ptr< Builder > withName(const StringLike &name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:391
std::shared_ptr< Builder > withExecutor(const std::shared_ptr< Executor > &executor)
Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to bui...
Definition DXEndpoint.hpp:995
bool supportsProperty(const StringLike &key) const
Checks if a property is supported.
Definition DXEndpoint.cpp:338
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:957
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:380
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:300
std::shared_ptr< Builder > withProperty(const StringLike &key, const StringLike &value)
Sets the specified property.
Definition DXEndpoint.cpp:313
Subscription for a set of symbols and event types.
Definition DXFeedSubscription.hpp:45
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols an...
Definition DXFeedSubscription.hpp:787
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:29
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:29
static JavaObjectHandleRegistry & getInstance() noexcept
Returns the process-wide handle registry.
Definition JavaObjectHandle.cpp:68
void releaseAll() noexcept
Releases all currently registered handles while the Graal isolate is still available.
Definition JavaObjectHandle.cpp:125
void reset(void *handle=nullptr) noexcept
Replaces the owned handle, releasing the previous one.
Definition JavaObjectHandle.cpp:163
JavaObjectHandleState(void *handle, Deleter deleter) noexcept
Creates an ownership state for a native handle.
Definition JavaObjectHandle.cpp:150
void * get() const noexcept
Returns the currently owned native handle.
Definition JavaObjectHandle.hpp:115
void moveFrom(JavaObjectHandleState &other) noexcept
Transfers ownership from another state and releases the handle previously owned by this state.
Definition JavaObjectHandle.cpp:159
~JavaObjectHandleState() noexcept
Releases the owned handle, if any, and unregisters the state.
Definition JavaObjectHandle.cpp:155
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:179
bool isClosed() const
Definition DXEndpoint.cpp:540
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:552
static const std::string DXFEED_PASSWORD_PROPERTY
"dxfeed.password"
Definition DXEndpoint.hpp:246
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:527
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:227
std::shared_ptr< DXEndpoint > password(const StringLike &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:154
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:444
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:464
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:454
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:459
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:448
std::shared_ptr< DXEndpoint > user(const StringLike &user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:147
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:173
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:518
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:548
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:544
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:373
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:418
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:406
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:434
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:397
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:427
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:384
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:401
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:209
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:236
static const std::string DXFEED_WILDCARD_ENABLE_PROPERTY
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:274
std::size_t addStateChangeListener(std::function< void(State, State)> listener) noexcept
Adds a listener notified about changes in state property.
Definition DXEndpoint.hpp:619
static const std::string DXENDPOINT_EVENT_TIME_PROPERTY
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:319
static const std::string DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:302
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:143
static const std::string DXENDPOINT_STORE_EVERYTHING_PROPERTY
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:332
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:200
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:500
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:265
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:556
static const std::string DXFEED_THREAD_POOL_SIZE_PROPERTY
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:255
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:182
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:218
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:491
static const std::string DXPUBLISHER_ADDRESS_PROPERTY
"dxpublisher.address"
Definition DXEndpoint.hpp:293
static const std::string DXFEED_USER_PROPERTY
"dxfeed.user"
Definition DXEndpoint.hpp:236
static const std::string NAME_PROPERTY
"name"
Definition DXEndpoint.hpp:196
static const std::string DXSCHEME_ENABLED_PROPERTY_PREFIX
"dxscheme.enabled."
Definition DXEndpoint.hpp:366
static const std::string DXPUBLISHER_PROPERTIES_PROPERTY
"dxpublisher.properties"
Definition DXEndpoint.hpp:283
static const std::string DXSCHEME_NANO_TIME_PROPERTY
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:352
static const std::string DXFEED_ADDRESS_PROPERTY
"dxfeed.address"
Definition DXEndpoint.hpp:226
std::shared_ptr< DXEndpoint > executor(const std::shared_ptr< Executor > &executor)
Changes the executor that is used for notifications (events, state changes, etc.) of this endpoint.
Definition DXEndpoint.hpp:655
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:191
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:536
static const std::string DXFEED_PROPERTIES_PROPERTY
"dxfeed.properties"
Definition DXEndpoint.hpp:207
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:509
std::shared_ptr< DXEndpoint > connect(const StringLike &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:161
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:141
void detachSubscriptionAndClear(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed and clears data delivered to this subscription by publ...
Definition DXFeed.cpp:68
Collection getLastEvents(Collection &&events)
Returns the last events for the specified list of event instances.
Definition DXFeed.hpp:294
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:749
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:1017
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:88
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:137
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:388
std::shared_ptr< PromiseList< E > > getLastEventsPromises(const SymbolsCollection &collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:703
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:328
std::shared_ptr< DXFeedSubscription > createSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:101
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 up...
Definition DXFeed.hpp:1048
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:500
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:19
std::shared_ptr< E > getLastEvent(std::shared_ptr< E > event)
Returns the last event for the specified event instance.
Definition DXFeed.hpp:270
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:656
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:438
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:608
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:567
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:226
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:802
void detachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed.
Definition DXFeed.cpp:48
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 subs...
Definition DXFeed.hpp:858
void attachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Attaches the given subscription to this feed.
Definition DXFeed.cpp:28
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:116
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:60
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:37
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:67
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:54
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:63
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:58
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:122
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:156
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:208
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:197
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:146
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:84
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:236
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:177
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:217
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:23
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:89
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:104
A runtime axception with stacktrace.
Definition RuntimeException.hpp:26
const std::string & getStackTrace() const &
Definition RuntimeException.cpp:83
RuntimeException(const StringLike &message, const StringLike &additionalStackTrace="")
Constructs a runtime exception.
Definition RuntimeException.cpp:67
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
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 or std::shared_ptr<T>{nu...
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 or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:58
bool is() const noexcept
Checks that the pointer to the current type could be converted to type T* In other words: whether typ...
Definition SharedEntity.hpp:39
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:379
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:399
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:317
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:328
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:359
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:418
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:390
SimpleHandler() noexcept
Creates the new handler.
Definition Handler.hpp:289
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:338
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition StringUtils.hpp:120
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:728
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:28
Common string constants used across the library.
Definition StringUtils.hpp:137
static const std::string NUL
Textual representation of a null / missing string: "<null>".
Definition StringUtils.hpp:142
static const std::string EMPTY
Empty string constant: "".
Definition StringUtils.hpp:139
Whether T is std::shared_ptr<E>, where E is a descendant of LastingEvent (the elements of DXFeed::get...
Definition DXFeed.hpp:40
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