algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
returns.hpp File Reference

Simple, log and cumulative returns of a price series. More...

#include "./numeric.hpp"
#include <cstddef>
Include dependency graph for returns.hpp:

Go to the source code of this file.

Namespaces

namespace  algotradelib
 The library: broker-neutral types (core), and the modules below.
namespace  algotradelib::analytics
 Returns, rolling statistics, indicators and performance metrics over numeric series.

Functions

math::Vector algotradelib::analytics::returns (math::SeriesView prices)
 Computes simple period returns, p[i] / p[i - 1] - 1.
math::Vector algotradelib::analytics::log_returns (math::SeriesView prices)
 Computes log (continuously compounded) returns, log(p[i] / p[i - 1]).
math::Vector algotradelib::analytics::cumulative_returns (math::SeriesView period_returns)
 Compounds simple period returns into the cumulative return, prod(1 + r[0..i]) - 1.

Detailed Description

Simple, log and cumulative returns of a price series.

Like every series function in analytics, each result is as long as its input (row i describes row i, so it shares the input's TimeIndex), and a value that cannot be computed is missing(), never zero.

Definition in file returns.hpp.