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