dxFeed Graal CXX API v5.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() for
71 * 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) {
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) {
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>
469 std::shared_ptr<DXFeedTimeSeriesSubscription> createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end) {
470 if constexpr (Debugger::isDebug) {
471 // ReSharper disable once CppDFAUnreachableCode
472 Debugger::debug("{}::createTimeSeriesSubscription(eventTypes = " + namesToString(begin, end) + ")");
473 }
474
475 for (EventTypeIt iter = begin; iter != end; ++iter) {
476 if (!iter->isTimeSeries()) {
477 throw InvalidArgumentException("DXFeed::createTimeSeriesSubscription(): event type " +
478 iter->getClassName() + " is not TimeSeries");
479 }
480 }
481
482 auto list = EventClassList::create(begin, end);
483 auto sub = RequireMakeShared<DXFeedTimeSeriesSubscription>::createShared(
484 begin, end, std::move(createTimeSeriesSubscriptionHandleFromEventClassList(list)));
485 auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);
486
487 dxfcpp::ignoreUnused(id);
488
490
491 return sub;
492 }
493
494 /**
495 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
496 * This method creates a new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
497 *
498 * Example:
499 * ```cpp
500 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
501 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription({dxfcpp::Underlying::TYPE,
502 * dxfcpp::TimeAndSale::TYPE});
503 * ```
504 *
505 * @param eventTypes The initializer list of event types
506 * @return The new subscription
507 */
508 std::shared_ptr<DXFeedTimeSeriesSubscription>
509 createTimeSeriesSubscription(std::initializer_list<EventTypeEnum> eventTypes);
510
511 /**
512 * Creates new subscription for multiple event types that is <i>attached</i> to this feed.
513 * This method creates a new DXFeedTimeSeriesSubscription and invokes DXFeed::attachSubscription().
514 *
515 * Example:
516 * ```cpp
517 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
518 * auto sub =
519 * endpoint->getFeed()->createTimeSeriesSubscription(std::unordered_set{dxfcpp::Underlying::TYPE,
520 * dxfcpp::TimeAndSale::TYPE});
521 * ```
522 *
523 * ```cpp
524 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
525 * std::vector types = {dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE};
526 * auto sub = endpoint->getFeed()->createTimeSeriesSubscription(types);
527 * ```
528 *
529 * @tparam EventTypesCollection The class of the collection of event types
530 * @param eventTypes The collection of event types
531 * @return The new subscription
532 */
533 template <typename EventTypesCollection>
534 std::shared_ptr<DXFeedTimeSeriesSubscription> createTimeSeriesSubscription(const EventTypesCollection &eventTypes) {
535 if constexpr (Debugger::isDebug) {
536 // ReSharper disable once CppDFAUnreachableCode
537 auto dbgBegin = std::begin(eventTypes);
538 auto dbgEnd = std::end(eventTypes);
539
540 // ReSharper disable once CppDFAUnreachableCode
541 Debugger::debug(toString() +
542 "::createTimeSeriesSubscription(eventTypes = " + namesToString(dbgBegin, dbgEnd) + ")");
543 }
544
545 auto begin = std::begin(eventTypes);
546 auto end = std::end(eventTypes);
547
548 return createTimeSeriesSubscription(begin, end);
549 }
550
551 /**
552 * Requests the last event for the specified event type and symbol.
553 * This method works only for event types that implement LastingEvent marker "interface".
554 * This method requests the data from the uplink data provider, creates a new event of the specified event type
555 * and completes the resulting promise with this event.
556 *
557 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
558 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
559 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
560 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
561 * If the event is permanently not available (not supported), then the promise completes exceptionally with
562 * JavaException "IllegalArgumentException".
563 *
564 * <p>There is a bulk version of this method that works much faster for a single event type and multiple symbols.
565 * See getLastEventsPromises().
566 *
567 * <p>Note that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
568 * "STREAM_FEED" role (promise completes exceptionally).
569 *
570 * @tparam E The type of event.
571 * @param symbol The symbol.
572 * @return The promise for the result of the request.
573 */
574 template <Derived<LastingEvent> E>
575 std::shared_ptr<Promise<std::shared_ptr<E>>> getLastEventPromise(const SymbolWrapper &symbol) const {
576 return std::make_shared<Promise<std::shared_ptr<E>>>(getLastEventPromiseImpl(E::TYPE, symbol));
577 }
578
579 /**
580 * Requests the last events for the specified event type and a collection of symbols.
581 * This method works only for event types that implement LastingEvent marker "interface".
582 * This method requests the data from the uplink data provider,
583 * creates new events of the specified evet type and completes the resulting promises with these events.
584 *
585 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
586 *
587 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
588 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
589 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
590 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
591 * If the event is permanently not available (not supported), then the promise
592 * completes exceptionally with JavaException "IllegalArgumentException".
593 *
594 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
595 * events) and wait with a single timeout for all of them:
596 *
597 * ```cpp
598 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
599 * std::vector<dxfcpp::SymbolWrapper> symbols{"AAPL&Q", "IBM&Q"};
600 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>(symbols.begin(), symbols.end());
601 *
602 * // combine the list of promises into one with Promises utility method and wait
603 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
604 *
605 * // now iterate the promises to retrieve results
606 * for (const auto& promise : *promises) {
607 * auto quote = promise.getResult(); // InvalidArgumentException if result is nullptr
608 * doSomethingWith(quote);
609 * // std::cout << quote->toString() << std::endl;
610 * }
611 * ```
612 *
613 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
614 * "STREAM_FEED" role (promise completes exceptionally).
615 *
616 * @tparam E The event type.
617 * @tparam SymbolIt The symbols collection's iterator type.
618 * @param begin The beginning of the collection of symbols (SymbolWrapper).
619 * @param end The end of the collection of symbols (SymbolWrapper).
620 * @return The list of promises for the result of the requests, one item in list per symbol.
621 */
622 template <Derived<LastingEvent> E, typename SymbolIt>
623 std::shared_ptr<PromiseList<E>> getLastEventsPromises(SymbolIt begin, SymbolIt end) const {
624 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
625
626 return PromiseList<E>::create(getLastEventsPromisesImpl(E::TYPE, list.get()));
627 }
628
629 /**
630 * Requests the last events for the specified event type and a collection of symbols.
631 * This method works only for event types that implement LastingEvent marker "interface".
632 * This method requests the data from the uplink data provider,
633 * creates new events of the specified evet type and completes the resulting promises with these events.
634 *
635 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
636 *
637 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
638 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
639 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
640 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
641 * If the event is permanently not available (not supported), then the promise
642 * completes exceptionally with JavaException "IllegalArgumentException".
643 *
644 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
645 * events) and wait with a single timeout for all of them:
646 *
647 * ```cpp
648 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
649 * std::vector<dxfcpp::SymbolWrapper> symbols{"AAPL&Q", "IBM&Q"};
650 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>(symbols);
651 *
652 * // combine the list of promises into one with Promises utility method and wait
653 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
654 *
655 * // now iterate the promises to retrieve results
656 * for (const auto& promise : *promises) {
657 * doSomethingWith(promise.getResult()); // InvalidArgumentException if result is nullptr
658 * }
659 * ```
660 *
661 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
662 * "STREAM_FEED" role (promise completes exceptionally).
663 *
664 * @tparam E The event type.
665 * @tparam SymbolsCollection The symbol collection's type.
666 * @param collection The symbol collection.
667 * @return The list of promises for the result of the requests, one item in the list per symbol.
668 */
669 template <Derived<LastingEvent> E, ConvertibleToSymbolWrapperCollection SymbolsCollection>
670 std::shared_ptr<PromiseList<E>> getLastEventsPromises(const SymbolsCollection &collection) const {
671 auto begin = std::begin(collection);
672 auto end = std::end(collection);
673
674 return getLastEventsPromises<E>(begin, end);
675 }
676
677 /**
678 * Requests the last events for the specified event type and a collection of symbols.
679 * This method works only for event types that implement LastingEvent marker "interface".
680 * This method requests the data from the uplink data provider,
681 * creates new events of the specified event type and completes the resulting promises with these events.
682 *
683 * <p>This is a bulk version of DXFeed::getLastEventPromise() method.
684 *
685 * <p>The promise is canceled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
686 * If the event is not available for any transient reason (no subscription, no connection to uplink, etc.),
687 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
688 * Use Promise::await() method to specify timeout while waiting for a promise to complete.
689 * If the event is permanently not available (not supported), then the promise
690 * completes exceptionally with JavaException "IllegalArgumentException".
691 *
692 * <p>Use the following pattern of code to acquire multiple events (either for multiple symbols and/or multiple
693 * events) and wait with a single timeout for all of them:
694 *
695 * ```cpp
696 * const auto endpoint = dxfcpp::DXEndpoint::create()->connect(address);
697 * auto promises = endpoint->getFeed()->getLastEventsPromises<Quote>({"AAPL&Q", "IBM&Q"});
698 *
699 * // combine the list of promises into one with Promises utility method and wait
700 * dxfcpp::Promises::allOf(*promises)->awaitWithoutException(std::chrono::seconds(timeout));
701 *
702 * // now iterate the promises to retrieve results
703 * for (const auto& promise : *promises) {
704 * doSomethingWith(promise.getResult()); // InvalidArgumentException if result is nullptr
705 * }
706 * ```
707 *
708 * <p>Note, that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
709 * "STREAM_FEED" role (promise completes exceptionally).
710 *
711 * @tparam E The event type.
712 * @param collection The symbol collection.
713 * @return The list of promises for the result of the requests, one item in list per symbol.
714 */
715 template <Derived<LastingEvent> E>
716 std::shared_ptr<PromiseList<E>> getLastEventsPromises(std::initializer_list<SymbolWrapper> collection) const {
717 return getLastEventsPromises<E>(collection.begin(), collection.end());
718 }
719
720 /**
721 * Requests a container of indexed events for the specified event type, symbol and source.
722 * This method works only for event types that implement IndexedEvent "interface".
723 * This method requests the data from the uplink data provider, creates a container of events of the specified
724 * event type `E` and completes the resulting promise with this container. The events are ordered by @ref
725 * IndexedEvent::getIndex() "index" in the container.
726 *
727 * <p> This method is designed for retrieval of a snapshot only.
728 * Use IndexedEventModel if you need a container of indexed events that updates in real time.
729 *
730 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
731 * If the events are not available for any transient reason (no subscription, no connection to uplink, etc.),
732 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
733 * Use Promise::await() method to specify timeout while waiting for promise to complete.
734 * If the events are permanently not available (not supported), then the promise
735 * completes exceptionally with JavaException "IllegalArgumentException".
736 *
737 * <p>Note that this method does not work when DXEndpoint was created with
738 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (promise completes exceptionally).
739 *
740 * <h3>Event source.</h3>
741 *
742 * Use the @ref IndexedEventSource::DEFAULT "DEFAULT" value for `source` with events that do not
743 * have multiple sources (like Series). For events with multiple sources (like Order,
744 * AnalyticOrder, OtcMarketsOrder and SpreadOrder), use an event-specific source class (for example, OrderSource).
745 * This method does not support <em>synthetic</em> sources of orders (orders that are automatically
746 * generated from Quote events).
747 *
748 * <p>This method does not accept an instance of IndexedEventSubscriptionSymbol as a `symbol`.
749 * The later class is designed for use with DXFeedSubscription and to observe source-specific subscription
750 * in DXPublisher.
751 *
752 * <h3>Event flags and consistent snapshot</h3>
753 *
754 * This method completes promise only when a consistent snapshot of indexed events has been received from
755 * the data feed. The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
756 * is always zero.
757 *
758 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
759 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
760 * event class for details on how they should be published.
761 *
762 * @tparam E The type of event.
763 * @param symbol The symbol.
764 * @param source The source.
765 * @return The promise for the result of the request.
766 */
767 template <Derived<IndexedEvent> E>
769 getIndexedEventsPromise(const SymbolWrapper &symbol, const IndexedEventSource &source) const {
770 return std::make_shared<Promise<std::vector<std::shared_ptr<E>>>>(
771 getIndexedEventsPromiseImpl(E::TYPE, symbol, source));
772 }
773
774 /**
775 * Returns a vector of indexed events for the specified event type, symbol and source if there is a subscription
776 * for it. This method works only for event types that implement IndexedEvent interface. This method <b>does not</b>
777 * make any remote calls to the uplink data provider. It just retrieves last received events from the local cache of
778 * this feed. The events are stored in the cache only if there is some attached DXFeedSubscription that is
779 * subscribed to the corresponding event type, symbol and source. The subscription can also be permanently defined
780 * using DXEndpoint properties. If there is no subscription, then this method returns an empty vector.
781 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
782 *
783 * The events are ordered by @ref IndexedEvent::getIndex() "index" in the vector.
784 *
785 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
786 * this method returns an empty vector.
787 *
788 * <p>Use @ref DXFeed::getIndexedEventsPromise() "getIndexedEventsPromise" method
789 * if events need to be requested in the absence of subscription.
790 *
791 * <p>Note that this method does not work when DXEndpoint was created with @ref DXEndpoint::Role::STREAM_FEED
792 * "STREAM_FEED" role (always returns an empty vector).
793 *
794 * <h3>Event source.</h3>
795 *
796 * Use the @ref IndexedEventSource::DEFAULT "DEFAULT" value for `source` with events that do not
797 * have multiple sources (like Series). For events with multiple sources (like Order, AnalyticOrder,
798 * OtcMarketsOrder and SpreadOrder), use an event-specific source class (for example, OrderSource).
799 * This method does not support <em>synthetic</em> sources of orders (orders that are automatically generated from
800 * Quote events).
801 *
802 * <p>This method does not accept an instance of IndexedEventSubscriptionSymbol as a `symbol`.
803 * The later class is designed for use with DXFeedSubscription and to observe source-specific subscription
804 * in @DXPublisher.
805 *
806 * <h3>Event flags and consistent snapshot</h3>
807 *
808 * This method returns a vector of events that are currently in the cache without any wait or delay, and it <b>does
809 * not</b> guarantee that a consistent snapshot of events is returned. See IndexedEvent documentation for details.
810 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
811 * is always zero regardless. Use @ref DXFeed::getIndexedEventsPromise() "getIndexedEventsPromise" method
812 * if a consistent snapshot of events needs to be requested.
813 *
814 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
815 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
816 * event class for details on how they should be published.
817 *
818 * @tparam E The type of event.
819 * @param symbol The symbol.
820 * @param source The source.
821 * @return The vector of events or an empty vector if there is no subscription for the specified event
822 * type, symbol and source.
823 */
824 template <Derived<IndexedEvent> E>
825 std::vector<std::shared_ptr<E>> getIndexedEventsIfSubscribed(const SymbolWrapper &symbol,
826 const IndexedEventSource &source) const {
827 return convertEvents<EventType, E>(getIndexedEventsIfSubscribedImpl(E::TYPE, symbol, source));
828 }
829
830 /**
831 * Requests time series of events for the specified event type, symbol and a range of time.
832 *
833 * This method works only for event types that implement TimeSeriesEvent "interface".
834 * This method requests the data from the uplink data provider, creates a vector of events of the specified
835 * event type `E` and completes the resulting promise with this container.
836 *
837 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the container.
838 *
839 * <p> This method is designed for retrieval of a snapshot only.
840 * Use TimeSeriesEventModel if you need a vector of time-series events that updates in real time.
841 *
842 * <p>The range and depth of events that are available with this service is typically constrained by
843 * upstream data provider.
844 *
845 * <p>The promise is cancelled when the underlying DXEndpoint is @ref DXEndpoint::close() "closed".
846 *
847 * If events are not available for any transient reason (no subscription, no connection to uplink, etc.),
848 * then the resulting promise completes when the issue is resolved, which may involve an arbitrarily long wait.
849 * Use EventsPromiseMixin::await() method to specify timeout while waiting for promise to complete.
850 * If events are permanently not available (not supported), then the promise
851 * completes exceptionally with JavaException "IllegalArgumentException".
852 *
853 * <p>Note, that this method does not work when DXEndpoint was created with
854 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (promise completes exceptionally).
855 *
856 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
857 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription
858 * in DXPublisher.
859 *
860 * <h3>Event flags</h3>
861 *
862 * This method completes promise only when a consistent snapshot of time series has been received from
863 * the data feed. The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting
864 * container is always zero.
865 *
866 * <p>Note that the resulting container <em>should not</em> be used with DXPublisher::publishEvents() method,
867 * because the latter expects events in a different order and with an appropriate flags set. See documentation on a
868 * specific event class for details on how they should be published.
869 *
870 * @tparam E The type of event.
871 * @param symbol The symbol.
872 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
873 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
874 * Use `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX` macro to retrieve events without an
875 * upper limit on time.
876 * @return The promise for the result of the request.
877 */
878 template <Derived<TimeSeriesEvent> E>
880 getTimeSeriesPromise(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const {
881 return std::make_shared<Promise<std::vector<std::shared_ptr<E>>>>(
882 getTimeSeriesPromiseImpl(E::TYPE, symbol, fromTime, toTime));
883 }
884
885 /**
886 * Returns time series of events for the specified event type, symbol and a range of time if there is a
887 * subscription for it. This method <b>does not</b> make any remote calls to the uplink data provider. It just
888 * retrieves last received events from the local cache of this feed. The events are stored in the cache only if
889 * there is some attached DXFeedSubscription that is subscribed to the corresponding event type, symbol and time.
890 * The subscription can also be permanently defined using DXEndpoint properties.
891 * If there is no subscription, then this method returns an empty vector.
892 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
893 *
894 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the vector.
895 *
896 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
897 * this method returns an empty vector.
898 *
899 * <p>Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
900 * if events need to be requested in the absence of subscription.
901 *
902 * <p>Note that this method does not work when DXEndpoint was created with
903 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (always returns an empty vector).
904 *
905 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
906 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription in
907 * DXPublisher.
908 *
909 * <h3>Event flags and consistent snapshot</h3>
910 *
911 * This method returns a vector of events that are currently in the cache without any wait or delay,
912 * and it <b>does not</b> guarantee that a consistent snapshot of events is returned.
913 * See IndexedEvent documentation for details.
914 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
915 * is always zero regardless. Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
916 * if a consistent snapshot of events needs to be requested.
917 *
918 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
919 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
920 * event class for details on how they should be published.
921 *
922 * @tparam E The type of event.
923 * @param symbol The symbol.
924 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
925 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
926 * Use `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX` macro to retrieve events without an
927 * upper limit on time.
928 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
929 * and time range.
930 */
931 template <Derived<TimeSeriesEvent> E>
932 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime,
933 std::int64_t toTime) const {
934 return convertEvents<EventType, E>(getTimeSeriesIfSubscribedImpl(E::TYPE, symbol, fromTime, toTime));
935 }
936
937 /**
938 * Returns time series of events for the specified event type, symbol and a range of time if there is a
939 * subscription for it. This method <b>does not</b> make any remote calls to the uplink data provider. It just
940 * retrieves last received events from the local cache of this feed. The events are stored in the cache only if
941 * there is some attached DXFeedSubscription that is subscribed to the corresponding event type, symbol and time.
942 * The subscription can also be permanently defined using DXEndpoint properties.
943 * If there is no subscription, then this method returns an empty vector.
944 * Otherwise, it creates a vector of events of the specified event type `E` and returns it.
945 *
946 * The events are ordered by @ref TimeSeriesEvent::getTime() "time" in the vector.
947 *
948 * <p>If there is a subscription, but the events have not arrived from the uplink data provider,
949 * this method returns an empty vector.
950 *
951 * <p>Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
952 * if events need to be requested in the absence of subscription.
953 *
954 * <p>Note that this method does not work when DXEndpoint was created with
955 * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (always returns an empty vector).
956 *
957 * <p>This method does not accept an instance of TimeSeriesSubscriptionSymbol as a `symbol`.
958 * The later class is designed for use with DXFeedSubscription and to observe time-series subscription in
959 * DXPublisher.
960 *
961 * <h3>Event flags and consistent snapshot</h3>
962 *
963 * This method returns a vector of events that are currently in the cache without any wait or delay,
964 * and it <b>does not</b> guarantee that a consistent snapshot of events is returned.
965 * See IndexedEvent documentation for details.
966 * The @ref IndexedEvent::getEventFlags() "eventFlags" property of the events in the resulting vector
967 * is always zero regardless. Use @ref DXFeed::getTimeSeriesPromise() "getTimeSeriesPromise" method
968 * if a consistent snapshot of events needs to be requested.
969 *
970 * <p>Note that the resulting vector <em>should not</em> be used with DXPublisher::publishEvents() method, because
971 * the latter expects events in a different order and with an appropriate flags set. See documentation on a specific
972 * event class for details on how they should be published.
973 *
974 * @tparam E The type of event.
975 * @param symbol The symbol.
976 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
977 * @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
978 * Use `std::chrono::milliseconds(std::numeric_limits<std::int64_t>::max())`
979 * or `std::chrono::milliseconds(LLONG_MAX)` to retrieve events without an upper limit on time.
980 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
981 * and time range.
982 */
983 template <Derived<TimeSeriesEvent> E>
984 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
985 std::chrono::milliseconds fromTime,
986 std::chrono::milliseconds toTime) const {
987 return getTimeSeriesIfSubscribed<E>(symbol, fromTime.count(), toTime.count());
988 }
989
990 /**
991 * Returns time series of events for the specified event type, symbol and a range of time (without an upper limit
992 * on time) if there is a subscription for it.
993 * @tparam E The type of event.
994 * @param symbol The symbol.
995 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
996 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
997 * and time range.
998 */
999 template <Derived<TimeSeriesEvent> E>
1000 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
1001 std::int64_t fromTime) const {
1002 return getTimeSeriesIfSubscribed<E>(symbol, fromTime, std::numeric_limits<std::int64_t>::max());
1003 }
1004
1005 /**
1006 * Returns time series of events for the specified event type, symbol and a range of time (without an upper limit
1007 * on time) if there is a subscription for it.
1008 * @tparam E The type of event.
1009 * @param symbol The symbol.
1010 * @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
1011 * @return the vector of events or an empty vector if there is no subscription for the specified event type, symbol
1012 * and time range.
1013 */
1014 template <Derived<TimeSeriesEvent> E>
1015 std::vector<std::shared_ptr<E>> getTimeSeriesIfSubscribed(const SymbolWrapper &symbol,
1016 std::chrono::milliseconds fromTime) const {
1017 return getTimeSeriesIfSubscribed<E>(symbol, fromTime.count());
1018 }
1019
1020 std::string toString() const override;
1021};
1022
1024
#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:680
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:713
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:961
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1151
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:740
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:1097
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1012
#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:910
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:1063
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:799
#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:1080
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:696
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:787
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:978
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:1123
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:757
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1146
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:1046
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:893
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:647
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:995
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:927
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:944
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:846
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:822
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:663
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:869
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1156
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:1029
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:842
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:323
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:366
bool supportsProperty(const StringLike &key) const
Checks if a property is supported.
Definition DXEndpoint.cpp:313
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:355
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:285
std::shared_ptr< Builder > withProperty(const StringLike &key, const StringLike &value)
Sets the specified property.
Definition DXEndpoint.cpp:298
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:499
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:511
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:486
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:212
std::shared_ptr< DXEndpoint > password(const StringLike &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:139
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:132
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:158
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:477
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:507
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:503
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:376
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:194
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:221
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:128
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:185
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:459
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:257
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:515
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:167
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:203
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:450
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:176
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:495
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:468
std::shared_ptr< DXEndpoint > connect(const StringLike &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:146
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:65
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:1000
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:469
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:357
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypesCollection &eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:407
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypesCollection &eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:534
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:716
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:984
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:932
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:85
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:880
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:670
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:98
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:1015
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:16
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:623
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:575
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:135
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:224
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:769
void detachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed.
Definition DXFeed.cpp:45
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:825
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:25
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:113
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=default
The default virtual d-tor.
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
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:377
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:397
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:315
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:326
SimpleHandler() noexcept=default
Creates the new handler.
std::size_t addLowPriority(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group) It will be called after the "main" liste...
Definition Handler.hpp:357
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:416
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:388
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:336
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