algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::mock::MarketClock Class Reference

The clock a loop waits on over a mock market: waiting moves the market. More...

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

Public Member Functions

 MarketClock (Market &market)
 Builds a clock over a market.
std::chrono::system_clock::time_point now () const noexcept
 Returns the market's time.
std::chrono::steady_clock::time_point monotonic_now () const noexcept
 Returns a reading that moves with the market's time and never backwards.
void wait_for (std::chrono::nanoseconds duration)
 Advances the market by a duration instead of sleeping.

Detailed Description

The clock a loop waits on over a mock market: waiting moves the market.

Give it to runner::PollingLoop, and through a runner::ClockReference to live::bind_journaled, so the loop, its journal and the market read one time.

Definition at line 16 of file clock.hpp.

Constructor & Destructor Documentation

◆ MarketClock()

algotradelib::mock::MarketClock::MarketClock ( Market & market)
inlineexplicit

Builds a clock over a market.

Parameters
marketThe market; borrowed, and must outlive the clock.

Definition at line 22 of file clock.hpp.

Member Function Documentation

◆ monotonic_now()

std::chrono::steady_clock::time_point algotradelib::mock::MarketClock::monotonic_now ( ) const
inlinenoexcept

Returns a reading that moves with the market's time and never backwards.

Returns
The market's time as a steady reading.

Definition at line 36 of file clock.hpp.

◆ now()

std::chrono::system_clock::time_point algotradelib::mock::MarketClock::now ( ) const
inlinenoexcept

Returns the market's time.

Returns
Market::now().

Definition at line 28 of file clock.hpp.

◆ wait_for()

void algotradelib::mock::MarketClock::wait_for ( std::chrono::nanoseconds duration)
inline

Advances the market by a duration instead of sleeping.

Parameters
durationHow long; nothing moves if it is not positive.

Definition at line 46 of file clock.hpp.


The documentation for this class was generated from the following file: