dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
MarketDepthModel< O >::Builder Struct Referencefinal

A builder class for creating an instance of MarketDepthModel. More...

#include <MarketDepthModel.hpp>

Inheritance diagram for MarketDepthModel< O >::Builder:

Public Member Functions

std::shared_ptr< Builder > withFeed (std::shared_ptr< DXFeed > feed)
 Sets the DXFeed for the model being created.
std::shared_ptr< Builder > withSymbol (const SymbolWrapper &symbol)
 Sets the subscription symbol for the model being created.
std::shared_ptr< Builder > withListener (std::shared_ptr< MarketDepthModelListener< O > > listener)
 Sets the listener for transaction notifications.
std::shared_ptr< Builder > withListener (std::function< void(const std::vector< std::shared_ptr< O > > &, const std::vector< std::shared_ptr< O > > &)> onEventsReceived)
 Creates and sets the listener for transaction notifications.
template<typename EventSourceIt>
std::shared_ptr< Builder > withSources (EventSourceIt begin, EventSourceIt end)
 Sets the sources from which to subscribe for indexed events.
template<ConvertibleToEventSourceWrapperCollection EventSourceCollection>
std::shared_ptr< Builder > withSources (EventSourceCollection &&sources)
 Sets the sources from which to subscribe for indexed events.
std::shared_ptr< Builder > withSources (std::initializer_list< EventSourceWrapper > sources)
 Sets the sources from which to subscribe for indexed events.
std::shared_ptr< Builder > withDepthLimit (std::size_t depthLimit)
 Sets the depth limit.
std::shared_ptr< Builder > withAggregationPeriod (std::int64_t aggregationPeriodMillis)
 Sets the aggregation period.
std::shared_ptr< Builder > withAggregationPeriod (std::chrono::milliseconds aggregationPeriod)
 Sets the aggregation period.
std::shared_ptr< Builder > withCrossedBookWarning (bool enabled, std::chrono::milliseconds period=std::chrono::minutes{1})
 Enables or disables the warning on a crossed book (see Crossed book).
std::shared_ptr< MarketDepthModel > build ()
 Builds an instance of MarketDepthModel based on the provided parameters.
Public Member Functions inherited from SharedEntity
template<typename T>
bool is () const noexcept
 Checks that the object is of type T: its dynamic type is T or derived from T.
template<typename T>
std::shared_ptr< T > sharedAs () noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr.
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 or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr.
virtual std::string toString () const
 Returns a string representation of the current object.
Public Member Functions inherited from Entity
virtual ~Entity () noexcept
 The default virtual d-tor.

Friends

struct MarketDepthModel

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.
Static Public Member Functions inherited from RequireMakeShared< Builder >
static auto createShared (Args &&...args)
 Creates a smart pointer to an object.

Detailed Description

template<Derived< OrderBase > O>
struct MarketDepthModel< O >::Builder

A builder class for creating an instance of MarketDepthModel.

Member Function Documentation

◆ build()

template<Derived< OrderBase > O>
std::shared_ptr< MarketDepthModel > MarketDepthModel< O >::Builder::build ( )
inline

Builds an instance of MarketDepthModel based on the provided parameters.

Returns
The created MarketDepthModel.

◆ withAggregationPeriod() [1/2]

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withAggregationPeriod ( std::chrono::milliseconds aggregationPeriod)
inline

Sets the aggregation period.

Parameters
aggregationPeriodThe aggregation period.
Returns
The builder instance.

References withAggregationPeriod().

Referenced by withAggregationPeriod().

◆ withAggregationPeriod() [2/2]

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withAggregationPeriod ( std::int64_t aggregationPeriodMillis)
inline

Sets the aggregation period.

Parameters
aggregationPeriodMillisThe aggregation period in milliseconds.
Returns
The builder instance.

◆ withCrossedBookWarning()

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withCrossedBookWarning ( bool enabled,
std::chrono::milliseconds period = std::chrono::minutes{1} )
inline

Enables or disables the warning on a crossed book (see Crossed book).

When the check is enabled, the model compares the best buy order with the best sell order of the whole book after each transaction, whatever the depth limit. If the price of the best buy order is above the price of the best sell order, the model reports a warning with ErrorManager::reportWarning() (the component MarketDepthModel): the symbol, the source and the price of both orders. Equal prices are not reported. The first crossing is reported at once, the next ones at most once per period, with the number of the transactions with a crossed book since the previous warning.

Remarks
The check is disabled by default.
Parameters
enabledtrue to enable the check.
periodThe minimum time between two warnings of this model (1 minute by default); 0 reports every crossing.
Returns
The builder instance.

◆ withDepthLimit()

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withDepthLimit ( std::size_t depthLimit)
inline

Sets the depth limit.

Parameters
depthLimitThe depth limit.
Returns
The builder instance.

◆ withFeed()

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withFeed ( std::shared_ptr< DXFeed > feed)
inline

Sets the DXFeed for the model being created.

The feed cannot be attached after the model has been built.

Parameters
feedThe DXFeed.
Returns
The builder instance.

◆ withListener() [1/2]

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withListener ( std::function< void(const std::vector< std::shared_ptr< O > > &, const std::vector< std::shared_ptr< O > > &)> onEventsReceived)
inline

Creates and sets the listener for transaction notifications.

The listener cannot be changed or added once the model has been built.

Parameters
onEventsReceivedThe callback.
Returns
The builder instance.

◆ withListener() [2/2]

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withListener ( std::shared_ptr< MarketDepthModelListener< O > > listener)
inline

Sets the listener for transaction notifications.

The listener cannot be changed or added once the model has been built.

Parameters
listenerThe transaction listener.
Returns
The builder instance.

◆ withSources() [1/3]

template<Derived< OrderBase > O>
template<ConvertibleToEventSourceWrapperCollection EventSourceCollection>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withSources ( EventSourceCollection && sources)
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

Remarks
The default value for this source is an empty set, which means that this model subscribes to all available sources.
Template Parameters
EventSourceCollectionA type of the collection of sources (std::vector<EventSourceWrapper>, std::set<OrderSource>, etc.)
Parameters
sourcesThe specified sources.
Returns
The builder instance.

◆ withSources() [2/3]

template<Derived< OrderBase > O>
template<typename EventSourceIt>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withSources ( EventSourceIt begin,
EventSourceIt end )
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

Remarks
The default value for this source is an empty set, which means that this model subscribes to all available sources.
Template Parameters
EventSourceItThe source collection iterator type.
Parameters
beginThe beginning of the collection of sources.
endThe end of the collection of sources.
Returns
The builder instance.

◆ withSources() [3/3]

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withSources ( std::initializer_list< EventSourceWrapper > sources)
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

Remarks
The default value for this source is an empty set, which means that this model subscribes to all available sources.
Parameters
sourcesThe specified sources.
Returns
The builder instance.

◆ withSymbol()

template<Derived< OrderBase > O>
std::shared_ptr< Builder > MarketDepthModel< O >::Builder::withSymbol ( const SymbolWrapper & symbol)
inline

Sets the subscription symbol for the model being created.

The symbol cannot be added or changed after the model has been built.

Parameters
symbolThe subscription symbol.
Returns
The builder instance.