algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::mock::DataFeed< T > Class Template Reference

The mock vendor: records the caller gives, each released once the clock reaches the time it was published. More...

#include <algotradelib/src/brokers/mock/data.hpp>

Public Types

using Entry = std::pair<std::chrono::system_clock::time_point, T>
 A record and when it was published.

Public Member Functions

 DataFeed (std::vector< Entry > entries)
 Builds a feed over records in any order; records published at one instant keep their order.
std::optional< std::vector< T > > operator() (std::chrono::system_clock::time_point now)
 Returns the records published at or before now and not returned before, in time order.
std::size_t remaining () const noexcept
 Returns how many records are still to be released.

Detailed Description

template<typename T>
class algotradelib::mock::DataFeed< T >

The mock vendor: records the caller gives, each released once the clock reaches the time it was published.

It is a data poll as runner::PollingLoop::set_data_poll takes one: on the mock market's clock (mock::MarketClock) one clock moves the market and the feed, and the loop stamps each record with the reading at which it received it.

mock::DataFeed<Record> feed({{published_at, record}, ...});
loop.set_data_poll(feed); // a copy; std::ref(feed) to keep reading `remaining()`
The mock vendor: records the caller gives, each released once the clock reaches the time it was publi...
Definition data.hpp:29
Template Parameters
TThe record type, the strategy's data_type.

Definition at line 29 of file data.hpp.

Member Typedef Documentation

◆ Entry

template<typename T>
using algotradelib::mock::DataFeed< T >::Entry = std::pair<std::chrono::system_clock::time_point, T>

A record and when it was published.

Definition at line 32 of file data.hpp.

Constructor & Destructor Documentation

◆ DataFeed()

template<typename T>
algotradelib::mock::DataFeed< T >::DataFeed ( std::vector< Entry > entries)
inlineexplicit

Builds a feed over records in any order; records published at one instant keep their order.

Parameters
entriesThe records with their publication times.

Definition at line 38 of file data.hpp.

Member Function Documentation

◆ operator()()

template<typename T>
std::optional< std::vector< T > > algotradelib::mock::DataFeed< T >::operator() ( std::chrono::system_clock::time_point now)
inline

Returns the records published at or before now and not returned before, in time order.

Parameters
nowThe clock reading.
Returns
The records; empty when nothing is new. Never std::nullopt: the mock never fails a read.

Definition at line 49 of file data.hpp.

◆ remaining()

template<typename T>
std::size_t algotradelib::mock::DataFeed< T >::remaining ( ) const
inlinenoexcept

Returns how many records are still to be released.

Returns
The count.

Definition at line 62 of file data.hpp.


The documentation for this class was generated from the following file:
  • algotradelib/src/brokers/mock/data.hpp