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

Named technical indicators: z-score, Bollinger bands, RSI, ATR, MACD, and trailing covariance, correlation and beta. More...

#include "./rolling.hpp"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <stdexcept>
Include dependency graph for indicators.hpp:

Go to the source code of this file.

Classes

struct  algotradelib::analytics::BollingerBands
 The three lines of Bollinger bands, each as long as the input. More...
struct  algotradelib::analytics::MacdLines
 The three lines of a MACD, each as long as the input. More...

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::zscore (math::SeriesView values, std::size_t window, std::size_t min_observed)
 Computes how many trailing sample standard deviations each value lies from its trailing mean.
math::Vector algotradelib::analytics::zscore (math::SeriesView values, std::size_t window)
 Computes the trailing z-score, requiring every row of the window.
BollingerBands algotradelib::analytics::bollinger (math::SeriesView values, std::size_t window, Scalar multiplier, std::size_t min_observed)
 Computes Bollinger bands: the trailing mean and bands multiplier sample standard deviations either side of it.
BollingerBands algotradelib::analytics::bollinger (math::SeriesView values, std::size_t window=20, Scalar multiplier=Scalar{2})
 Computes Bollinger bands, requiring every row of the window.
math::Vector algotradelib::analytics::rsi (math::SeriesView prices, std::size_t period=14)
 Computes Wilder's relative strength index.
math::Vector algotradelib::analytics::true_range (math::SeriesView highs, math::SeriesView lows, math::SeriesView closes)
 Computes each bar's true range, max(high - low, |high - prev close|, |low - prev close|).
math::Vector algotradelib::analytics::atr (math::SeriesView highs, math::SeriesView lows, math::SeriesView closes, std::size_t period=14)
 Computes the average true range with Wilder's smoothing.
MacdLines algotradelib::analytics::macd (math::SeriesView values, std::size_t fast=12, std::size_t slow=26, std::size_t signal_span=9)
 Computes the MACD (moving-average convergence/divergence) lines.
math::Vector algotradelib::analytics::rolling_cov (math::SeriesView left, math::SeriesView right, std::size_t window, std::size_t min_observed)
 Computes the trailing sample covariance of two series (divisor count - 1).
math::Vector algotradelib::analytics::rolling_cov (math::SeriesView left, math::SeriesView right, std::size_t window)
 Computes the trailing sample covariance, requiring both series on every row of the window.
math::Vector algotradelib::analytics::rolling_corr (math::SeriesView left, math::SeriesView right, std::size_t window, std::size_t min_observed)
 Computes the trailing Pearson correlation of two series.
math::Vector algotradelib::analytics::rolling_corr (math::SeriesView left, math::SeriesView right, std::size_t window)
 Computes the trailing correlation, requiring both series on every row of the window.
math::Vector algotradelib::analytics::beta (math::SeriesView asset, math::SeriesView market, std::size_t window, std::size_t min_observed)
 Computes the trailing beta of an asset against a market, cov(asset, market) / var(market).
math::Vector algotradelib::analytics::beta (math::SeriesView asset, math::SeriesView market, std::size_t window)
 Computes the trailing beta, requiring both series on every row of the window.

Detailed Description

Named technical indicators: z-score, Bollinger bands, RSI, ATR, MACD, and trailing covariance, correlation and beta.

They follow the conventions of rolling.hpp: the result is as long as the input, a value that cannot be computed is missing(), and nothing is reported before the window holds enough observations. Where an indicator has a conventional parameterization (Wilder's smoothing for RSI and ATR, spans for MACD), its documentation says which one it follows.

Definition in file indicators.hpp.