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