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

A control file an operator writes to stop a running loop with a given intent. More...

#include <algotradelib/src/runner/stop.hpp>

Public Member Functions

 FileStopChannel (std::string path={})
 Constructs a channel.
bool enabled () const noexcept
 Tests whether a path was configured.
const std::string & path () const noexcept
 Returns the watched path.
std::optional< StopIntent > poll ()
 Reads the file's first word.
const std::string & unrecognized () const noexcept
 Returns the word the last poll did not recognize.

Detailed Description

A control file an operator writes to stop a running loop with a given intent.

echo withdraw > /var/run/atl/stop

The first word of the file names the intent; a missing file is normal. Checked once per loop iteration.

Warning
The file is never deleted. A word left in it stops the next process too, from its first iteration (a withdraw or flatten acting on the whole account before anything trades). Remove it before trading again.

Definition at line 229 of file stop.hpp.

Constructor & Destructor Documentation

◆ FileStopChannel()

algotradelib::runner::FileStopChannel::FileStopChannel ( std::string path = {})
inlineexplicit

Constructs a channel.

Parameters
pathThe file to watch; empty disables the channel.

Definition at line 235 of file stop.hpp.

Member Function Documentation

◆ enabled()

bool algotradelib::runner::FileStopChannel::enabled ( ) const
inlinenoexcept

Tests whether a path was configured.

Returns
true if the channel is enabled.

Definition at line 241 of file stop.hpp.

◆ path()

const std::string & algotradelib::runner::FileStopChannel::path ( ) const
inlinenoexcept

Returns the watched path.

Returns
The path.

Definition at line 247 of file stop.hpp.

Referenced by FileStopChannel().

◆ poll()

std::optional< StopIntent > algotradelib::runner::FileStopChannel::poll ( )
inline

Reads the file's first word.

Returns
The intent it names, or std::nullopt if the channel is disabled, the file is missing or empty, or the word names no intent (then unrecognized() returns the word).

Definition at line 254 of file stop.hpp.

◆ unrecognized()

const std::string & algotradelib::runner::FileStopChannel::unrecognized ( ) const
inlinenoexcept

Returns the word the last poll did not recognize.

Returns
The word, or empty if the last read was understood or found nothing.

Definition at line 289 of file stop.hpp.


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