tzutrader
A composable C++ backtesting library for trading strategies (experimental)
Loading...
Searching...
No Matches
tzu::BasicPortfolio Class Reference

#include <portfolios.h>

Inheritance diagram for tzu::BasicPortfolio:
tzu::Portfolio< BasicPortfolio >

Public Member Functions

 BasicPortfolio (double initCash=100000.0, double txCostPct=0.0, double stopLossPct=std::nan(""), double takeProfitPct=std::nan(""))
void update (const Signal &signal)
Public Member Functions inherited from tzu::Portfolio< BasicPortfolio >
void update (const BasicPortfolio &signal)

Friends

std::ostream & operator<< (std::ostream &os, const BasicPortfolio &portfolio)

Detailed Description

BasicPortfolio implements transaction costs and simple stop-loss / take-profit policies. Transaction costs are expressed as a fraction of the transaction value (e.g. 0.001 == 0.1%). This portfolio uses all available cash to buy as many units as possible at each buy signal, and liquidates all positions at each sell signal. Stop-loss and take-profit are checked at each update and positions are liquidated if the price breaches the stop-loss or take-profit thresholds. Stop-loss and take-profit are fractions relative to the acquisition price (e.g. 0.1 == 10%). By default transaction costs are 0 and stop-loss / take-profit are NaN (disabled).

Constructor & Destructor Documentation

◆ BasicPortfolio()

tzu::BasicPortfolio::BasicPortfolio ( double initCash = 100000.0,
double txCostPct = 0.0,
double stopLossPct = std::nan(""),
double takeProfitPct = std::nan("") )
inline

Member Function Documentation

◆ update()

void tzu::BasicPortfolio::update ( const Signal & signal)
inline

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const BasicPortfolio & portfolio )
friend

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