tzutrader
A composable C++ backtesting library for trading strategies (experimental)
Loading...
Searching...
No Matches
runners.h
Go to the documentation of this file.
1
#ifndef RUNNERS_H
2
#define RUNNERS_H
3
4
#include "
strategies.h
"
5
#include "
portfolios.h
"
6
#include "
streamers.h
"
7
8
namespace
tzu
{
9
10
template
<
class
T>
11
class
Runner
{
12
public
:
13
void
run
() {
14
static_cast<
T*
>
(
this
)->
run
();
15
}
16
};
17
31
template
<
typename
Portfolio,
typename
Strat,
typename
Streamer>
32
class
BasicRunner
:
public
Runner
<BasicRunner<Portfolio, Strat, Streamer>> {
33
Portfolio
portfolio;
34
Strat strat;
35
Streamer streamer;
36
public
:
37
BasicRunner
(
Portfolio
& portfolio, Strat& strat, Streamer& streamer)
38
: portfolio(portfolio), strat(strat), streamer(streamer) {}
39
void
run
(
bool
verbose =
false
) {
40
for
(
const
auto
& row : streamer) {
41
auto
sig = strat.update(row);
42
portfolio.update(sig);
43
if
(verbose) std::cout << portfolio << std::endl;
44
}
45
if
(!verbose)
46
std::cout << portfolio << std::endl;
47
}
48
};
49
50
}
// namespace tzu
51
52
#endif
// RUNNERS_H
tzu::BasicRunner::BasicRunner
BasicRunner(Portfolio &portfolio, Strat &strat, Streamer &streamer)
Definition
runners.h:37
tzu::BasicRunner::run
void run(bool verbose=false)
Definition
runners.h:39
tzu::Portfolio
Definition
portfolios.h:15
tzu::Runner
Definition
runners.h:11
tzu::Runner::run
void run()
Definition
runners.h:13
tzu
Definition
defs.h:20
portfolios.h
strategies.h
streamers.h
include
tzu
runners.h
Generated by
1.16.1