dxFeed Graal CXX API v4.2.0
Loading...
Searching...
No Matches
DXFeedTimeSeriesSubscription Class Reference

Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types. More...

#include <DXFeedSubscription.hpp>

+ Inheritance diagram for DXFeedTimeSeriesSubscription:

Public Member Functions

std::string toString () const override
 Returns a string representation of the current object.
 
std::int64_t getFromTime ()
 Returns the earliest timestamp from which time-series of events shall be received.
 
void setFromTime (std::int64_t fromTime)
 Sets the earliest timestamp from which time-series of events shall be received.
 
void setFromTime (std::chrono::milliseconds fromTime)
 Sets the earliest timestamp from which time-series of events shall be received.
 
- Public Member Functions inherited from SharedEntity
template<typename T>
bool is () const noexcept
 Checks that pointer to the current type could be converted to type T* In other words: whether type T belongs to the type hierarchy in which the current type resides.
 
template<typename T>
std::shared_ptr< T > sharedAs () noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T.
 
template<typename T>
std::shared_ptr< T > sharedAs () const noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T.
 
- Public Member Functions inherited from Entity
virtual ~Entity () noexcept=default
 The default virtual d-tor.
 
- Public Member Functions inherited from DXFeedSubscription
void attach (std::shared_ptr< DXFeed > feed)
 Attaches subscription to the specified feed.
 
void detach (std::shared_ptr< DXFeed > feed)
 Detaches subscription from the specified feed.
 
bool isClosed () override
 Returns true if this subscription is closed.
 
void close () const
 Closes this subscription and makes it permanently detached.
 
std::unordered_set< EventTypeEnumgetEventTypes () override
 Returns a set of subscribed event types.
 
bool containsEventType (const EventTypeEnum &eventType) override
 Returns true if this subscription contains the corresponding event type.
 
void clear () const
 Clears the set of subscribed symbols.
 
std::vector< SymbolWrappergetSymbols () const
 Returns a set of subscribed symbols (depending on the actual implementation of subscription).
 
std::vector< SymbolWrappergetDecoratedSymbols () const
 Returns a set of decorated symbols (depending on the actual implementation of subscription).
 
template<typename SymbolIt>
void setSymbols (SymbolIt begin, SymbolIt end) const
 Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using iterators).
 
template<ConvertibleToSymbolWrapperCollection SymbolsCollection>
void setSymbols (SymbolsCollection &&collection) const
 Changes the set of subscribed symbols so that it contains just the symbols from the specified collection.
 
void setSymbols (std::initializer_list< SymbolWrapper > collection) const
 Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (initializer list).
 
void addSymbols (const SymbolWrapper &symbolWrapper) const
 Adds the specified symbol to the set of subscribed symbols.
 
template<typename SymbolIt>
void addSymbols (SymbolIt begin, SymbolIt end) const
 Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
 
template<ConvertibleToSymbolWrapperCollection SymbolsCollection>
void addSymbols (const SymbolsCollection &collection) const
 Adds the specified collection of symbols to the set of subscribed symbols.
 
void addSymbols (std::initializer_list< SymbolWrapper > collection) const
 Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
 
void removeSymbols (const SymbolWrapper &symbolWrapper) const
 Removes the specified symbol from the set of subscribed symbols.
 
template<typename SymbolIt>
void removeSymbols (SymbolIt begin, SymbolIt end) const
 Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
 
template<ConvertibleToSymbolWrapperCollection SymbolsCollection>
void removeSymbols (SymbolsCollection &&collection) const
 Removes the specified collection of symbols from the set of subscribed symbols.
 
void removeSymbols (std::initializer_list< SymbolWrapper > collection) const
 Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
 
TimePeriod getAggregationPeriod () const
 Returns the aggregation period for data for this subscription instance.
 
void setAggregationPeriod (const TimePeriod &aggregationPeriod) const
 Sets the aggregation period for data.
 
void setAggregationPeriod (std::chrono::milliseconds aggregationPeriod) const
 Sets the aggregation period for data.
 
void setAggregationPeriod (std::int64_t aggregationPeriod) const
 Sets the aggregation period for data.
 
template<typename EventListener>
std::size_t addEventListener (EventListener &&listener)
 Adds listener for events.
 
template<typename EventT>
std::size_t addEventListener (std::function< void(const std::vector< std::shared_ptr< EventT > > &)> &&listener)
 Adds typed listener for events.
 
void removeEventListener (std::size_t listenerId)
 Removes listener for events.
 
OnEventHandleronEvent ()
 Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed.
 
std::size_t addChangeListener (std::shared_ptr< ObservableSubscriptionChangeListener > listener) override
 Adds subscription change listener.
 
void removeChangeListener (std::size_t changeListenerId) override
 Removes subscription change listener by id.
 
std::int32_t getEventsBatchLimit () const
 
void setEventsBatchLimit (std::int32_t eventsBatchLimit) const
 Sets maximum number of events in the single notification of OnEventHandler.
 

Static Public Member Functions

static std::shared_ptr< DXFeedTimeSeriesSubscriptioncreate (std::initializer_list< EventTypeEnum > eventTypes)
 Creates detached subscription for the given collection of event types.
 
- Static Public Member Functions inherited from RequireMakeShared< DXFeedTimeSeriesSubscription >
static auto createShared (Args &&...args)
 Creates smart pointer to object.
 
- Static Public Member Functions inherited from DXFeedSubscription
static std::shared_ptr< DXFeedSubscriptioncreate (const EventTypeEnum &eventType)
 Creates detached subscription for a single event type.
 
template<typename EventTypeIt>
static std::shared_ptr< DXFeedSubscriptioncreate (EventTypeIt begin, EventTypeIt end)
 Creates detached subscription for the given collection of event types.
 
static std::shared_ptr< DXFeedSubscriptioncreate (std::initializer_list< EventTypeEnum > eventTypes)
 Creates detached subscription for the given collection of event types.
 
template<typename EventTypesCollection>
static std::shared_ptr< DXFeedSubscriptioncreate (EventTypesCollection &&eventTypes)
 Creates detached subscription for the given collection of event types.
 
- Static Public Member Functions inherited from RequireMakeShared< DXFeedSubscription >
static auto createShared (Args &&...args)
 Creates smart pointer to object.
 

Additional Inherited Members

- Public Types inherited from SharedEntity
using Ptr = std::shared_ptr<SharedEntity>
 The alias to a type of shared pointer to the SharedEntity object.
 
- Public Types inherited from DXFeedSubscription
using Ptr = std::shared_ptr<DXFeedSubscription>
 The alias to a type of shared pointer to the DXFeedSubscription object.
 
using Unique = std::unique_ptr<DXFeedSubscription>
 The alias to a type of unique pointer to the DXFeedSubscription object.
 
- Static Public Attributes inherited from DXFeedSubscription
static const std::int32_t OPTIMAL_BATCH_LIMIT = 0
 The optimal events' batch limit for single notification in OnEventHandler.
 
static const std::int32_t MAX_BATCH_LIMIT = std::numeric_limits<std::int32_t>::max()
 The maximum events' batch limit for single notification in OnEventHandler.
 

Detailed Description

Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types.

This class decorates symbols that are passed to xxxSymbols methods in DXFeedSubscription by wrapping them into TimeSeriesSubscriptionSymbol instances with the current value of fromTime property. While getSymbols method returns original (undecorated) symbols, any installed ObservableSubscriptionChangeListener will see decorated ones.

Only events that implement TimeSeriesEvent interface can be subscribed to with DXFeedTimeSeriesSubscription.

From time

The value of fromTime property defines the time-span of events that are subscribed to. Only events that satisfy event.getEventTime() >= thisSubscription->getFromTime() are looked for.

The value fromTime is initially set to std::numeric_limits<std::int64_t>::max() with a special meaning that no events will be received until fromTime is changed with setFromTime method.

Threads and locks

This class is thread-safe and can be used concurrently from multiple threads without external synchronization.

Member Function Documentation

◆ create()

static std::shared_ptr< DXFeedTimeSeriesSubscription > DXFeedTimeSeriesSubscription::create ( std::initializer_list< EventTypeEnum > eventTypes)
static

Creates detached subscription for the given collection of event types.

Example:

auto sub = dxfcpp::DXFeedSubscription::create({dxfcpp::Underlying::TYPE, dxfcpp::TimeAndSale::TYPE});
Parameters
eventTypesThe event type collection.
Returns
The new detached subscription for the given collection of event types.

◆ getFromTime()

std::int64_t DXFeedTimeSeriesSubscription::getFromTime ( )

Returns the earliest timestamp from which time-series of events shall be received.

The timestamp is in milliseconds from midnight, January 1, 1970 UTC.

Returns
the earliest timestamp from which time-series of events shall be received.

◆ setFromTime() [1/2]

void DXFeedTimeSeriesSubscription::setFromTime ( std::chrono::milliseconds fromTime)

Sets the earliest timestamp from which time-series of events shall be received.

The timestamp is in milliseconds from midnight, January 1, 1970 UTC.

Parameters
fromTimethe timestamp.

◆ setFromTime() [2/2]

void DXFeedTimeSeriesSubscription::setFromTime ( std::int64_t fromTime)

Sets the earliest timestamp from which time-series of events shall be received.

The timestamp is in milliseconds from midnight, January 1, 1970 UTC.

Parameters
fromTimethe timestamp.

◆ toString()

std::string DXFeedTimeSeriesSubscription::toString ( ) const
overridevirtual

Returns a string representation of the current object.

Returns
a string representation

Reimplemented from SharedEntity.