algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
example-live-loop.cpp File Reference

A live runner loop with no broker, no credentials and no network. More...

#include <algotradelib/runner>
#include <algotradelib/vanilla>
#include <chrono>
#include <iostream>
#include <string>
#include <vector>
Include dependency graph for example-live-loop.cpp:

Go to the source code of this file.

Functions

int main ()
 Runs the polling loop end to end with no broker, no credentials and no network.

Detailed Description

A live runner loop with no broker, no credentials and no network.

Runs the real runner::PollingLoop – the same class a live session drives – against a source that makes its data up. That is possible because the loop is parameterized on where data comes from, exactly as the runner is parameterized on where orders go, so everything about cadence, stopping and the safety gates is exercisable with nothing on the wire.

It is also a template for a broker this library does not support. ScriptedSource below is a complete source in one short class: anything that can answer "any new bars?" can drive this loop, and the strategy above it does not change. Swap the body for your own HTTP calls and the rest of the stack – reconciliation, the guards, the indeterminacy rules, the stop intents – comes along.

Deliberately uses ManualClock, so the whole run finishes instantly rather than sleeping through a cadence. A real program passes nothing and gets SteadyClock.

Definition in file example-live-loop.cpp.

Function Documentation

◆ main()

int main ( )

Runs the polling loop end to end with no broker, no credentials and no network.

Returns
0 on success.

Definition at line 197 of file example-live-loop.cpp.