Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies

Functions

template<typename T >
sref< T > tsa::ABS (sref< T > data)
 Returns the absolute value of data. More...
 
sref< double > tsa::ACCUMULATE (sref< double > value, const std::function< bool(double)> &func)
 Computes the sum of all values in data since strategy start for which func returns true. More...
 
sref< double > tsa::ACCUMULATE (sref< double > data, size_t period, const std::function< bool(double)> &func)
 Computes the sum of all values in data over the given period for which func returns true. More...
 
sref< double > tsa::ATAN (sref< double > arg)
 Returns the arc-tangent of arg. More...
 
sref< double > tsa::AVERAGE (sref< double > data, size_t period)
 Returns the average value over the given period. More...
 
sref< double > tsa::CAP (sref< double > value, double cap)
 Caps value at cap. If value is larger than cap, then cap is returned, else value. More...
 
sref< double > tsa::CAP (sref< double > value, sref< double > cap)
 Caps value at cap. If value is larger than cap, then cap is returned, else value. More...
 
sref< double > tsa::COS (sref< double > arg)
 Computes the cosine of arg (measured in radians). More...
 
sref< double > tsa::E (void)
 Returns a value of 'e' as a series of constants (2.718281828459045235).
 
sref< double > tsa::EMA (sref< double > data, size_t period)
 Returns the 'Exponential Moving Average' with the given period. More...
 
sref< double > tsa::EXP (sref< double > power)
 Raises const 'E' to the given power. The inverse of LN(). More...
 
sref< double > tsa::FLOOR (sref< double > value, double floor)
 Floors value at floor. If value is smaller than floor, then floor is returned, else value. More...
 
sref< double > tsa::FLOOR (sref< double > value, sref< double > floor)
 Floors value at floor. If value is smaller than floor, then floor is returned, else value. More...
 
sref< bool > tsa::FP_EQUAL (sref< double > a, sref< double > b, double tolerance=1e-12)
 Returns 'true' if a and b are identical to within the given tolerance. More...
 
sref< double > tsa::HIGHEST (sref< double > data, size_t period)
 Returns the maximum value in data over the given period.
 
sref< double > tsa::INNER_PRODUCT (sref< double > x, sref< double > y, size_t period)
 Returns the 'inner product' of x and y over the given period.
 
sref< double > tsa::LN (sref< double > value)
 Returns the natural logarithm of value. More...
 
sref< double > tsa::LOG10 (sref< double > value)
 Returns the log10 logarithm of value. More...
 
sref< double > tsa::LOWEST (sref< double > data, size_t period)
 Returns the minimum value in data over the given period.
 
sref< double > tsa::MAX (sref< double > data, size_t period)
 Returns the maximum value in data over the given period.
 
sref< double > tsa::MAX (sref< double > a, sref< double > b)
 Returns the larger of a or b. More...
 
sref< double > tsa::MAX (sref< double > data, sref< size_t > dynamic_period, size_t max_period)
 Returns the largest value in data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have. More...
 
sref< double > tsa::MEAN_DEV (sref< double > data, sref< double > custom_mean, size_t period)
 Returns the average deviation between values in and the current value of custom_mean over the given period. More...
 
sref< double > tsa::MEAN_DEV (sref< double > data, size_t period)
 Returns the average deviation between the values in and their average over the given period. More...
 
sref< double > tsa::MEAN_DEV2 (sref< double > data, sref< double > custom_mean, size_t period)
 Returns the average deviation squared between values in and the current value of custom_mean over the given period. More...
 
sref< double > tsa::MEAN_DEV2 (sref< double > data, size_t period)
 Returns the average deviation squared between the values in and their average over the given period. More...
 
sref< double > tsa::MEDIAN (sref< double > data, size_t period)
 Returns the median of data over the given period. More...
 
sref< double > tsa::MIN (sref< double > data, size_t period)
 Returns the minimum value in data over the given period.
 
sref< double > tsa::MIN (sref< double > a, sref< double > b)
 Returns the smaller of a or b. More...
 
sref< double > tsa::MIN (sref< double > data, sref< size_t > dynamic_period, size_t max_period)
 Returns the smallest value in data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have. More...
 
sref< double > tsa::PHI (void)
 Returns a value of 'phi' as a series of constants (1.61803398874989).
 
sref< double > tsa::PI (void)
 Returns a value of 'pi' as a series of constants (3.14159265358979323846264).
 
sref< double > tsa::POW (sref< double > base, double exponent)
 Returns base raised to the power of exponent. More...
 
sref< double > tsa::POW_DYN (sref< double > base, sref< double > exponent)
 Returns base raised to the power of exponent. More...
 
sref< double > tsa::ROLLING_SUM (sref< double > value)
 Returns the rolling sum of all value items since the start of the strategy. More...
 
sref< double > tsa::SAFE_DIVIDE (sref< double > numerator, sref< double > denominator, double denominator_adjust=1e-9)
 Divides numerator by denominator. If denominator is 0.0, then denominator_adjust is used instead of denominator to avoid division by zero. More...
 
sref< double > tsa::SIN (sref< double > arg)
 Computes the sine of arg (measured in radians). More...
 
sref< double > tsa::SMA (sref< double > data, size_t period)
 Returns the Symmetric Moving Average over the given period. (Alias for AVERAGE()) More...
 
sref< double > tsa::SQRT (sref< double > value)
 Returns the square root of value. More...
 
sref< double > tsa::STDEVP (sref< double > data, size_t period)
 Returns the population standard deviation of data over given period. More...
 
sref< double > tsa::SUM (sref< double > data, size_t period)
 Returns the sum of data over the given period. More...
 
sref< double > tsa::SUM (sref< double > data, sref< size_t > dynamic_period, size_t max_period)
 Returns the sum of data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have. More...
 
sref< double > tsa::SUM_DEV (sref< double > ser, sref< double > mean, size_t period)
 
sref< double > tsa::SUM_DEV (sref< double > data, size_t period)
 Returns the 'sum of deviations from mean' over the given period.
 
sref< double > tsa::SUM_DEV2 (sref< double > data, sref< double > custom_mean, size_t period)
 Returns the 'sum of deviations squared from custom_mean' over the given period.
 
sref< double > tsa::SUM_DEV2 (sref< double > data, size_t period)
 Returns the 'sum of deviations squared from mean' over the given period.
 
sref< double > tsa::SUM_NEG (sref< double > data, size_t period)
 Returns the 'sum of negatives' over the given period. More...
 
sref< double > tsa::SUM_POS (sref< double > data, size_t period)
 Returns the 'sum of positives' over the given period. More...
 
sref< double > tsa::SUM_SQ (sref< double > data, size_t period)
 Returns the 'sum of squares' over the given period. More...
 
sref< double > tsa::SUM_XY (sref< double > x, sref< double > y, size_t period)
 Returns the 'sum of x*y' over the given period.
 
sref< double > tsa::TAN (sref< double > arg)
 Computes the tangent of arg, measured in radians. More...
 
sref< double > tsa::VARP (sref< double > data, size_t period)
 Returns the population variance of data over given period. More...
 

Detailed Description

Function Documentation

template<typename T >
sref<T> tsa::ABS ( sref< T >  data)

Returns the absolute value of data.

Template Parameters
Ttemplate arg.
Parameters
dataThe data.
Returns
A sref<T>
sref< double > tsa::ACCUMULATE ( sref< double >  value,
const std::function< bool(double)> &  func 
)

Computes the sum of all values in data since strategy start for which func returns true.

Parameters
valueThe value.
funcThe function.
Returns
A sref<double>
sref< double > tsa::ACCUMULATE ( sref< double >  data,
size_t  period,
const std::function< bool(double)> &  func 
)

Computes the sum of all values in data over the given period for which func returns true.

Parameters
dataThe data.
periodThe period.
funcThe function.
Returns
A sref<double>
sref< double > tsa::ATAN ( sref< double >  arg)

Returns the arc-tangent of arg.

Parameters
argThe argument.
Returns
A sref<double>
sref< double > tsa::AVERAGE ( sref< double >  data,
size_t  period 
)

Returns the average value over the given period.

Parameters
dataThe data.
periodThe period.
Returns
The average value.
sref< double > tsa::CAP ( sref< double >  value,
double  cap 
)

Caps value at cap. If value is larger than cap, then cap is returned, else value.

Parameters
valueThe value.
capThe capability.
Returns
A sref<double>
sref< double > tsa::CAP ( sref< double >  value,
sref< double >  cap 
)

Caps value at cap. If value is larger than cap, then cap is returned, else value.

Parameters
valueThe value.
capThe capability.
Returns
A sref<double>
sref< double > tsa::COS ( sref< double >  arg)

Computes the cosine of arg (measured in radians).

Parameters
argThe argument.
Returns
A sref<double>
sref< double > tsa::EMA ( sref< double >  data,
size_t  period 
)

Returns the 'Exponential Moving Average' with the given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::EXP ( sref< double >  power)

Raises const 'E' to the given power. The inverse of LN().

Parameters
powerThe power.
Returns
A sref<double>
sref< double > tsa::FLOOR ( sref< double >  value,
double  floor 
)

Floors value at floor. If value is smaller than floor, then floor is returned, else value.

Parameters
valueThe value.
floorThe floor.
Returns
A sref<double>
sref< double > tsa::FLOOR ( sref< double >  value,
sref< double >  floor 
)

Floors value at floor. If value is smaller than floor, then floor is returned, else value.

Parameters
valueThe value.
floorThe floor.
Returns
A sref<double>
sref< bool > tsa::FP_EQUAL ( sref< double >  a,
sref< double >  b,
double  tolerance = 1e-12 
)

Returns 'true' if a and b are identical to within the given tolerance.

Parameters
aSeries a.
bSeries b.
toleranceThe tolerance.
Returns
A sref<bool>
sref< double > tsa::LN ( sref< double >  value)

Returns the natural logarithm of value.

Parameters
valueThe value.
Returns
A sref<double>
sref< double > tsa::LOG10 ( sref< double >  value)

Returns the log10 logarithm of value.

Parameters
valueThe value.
Returns
A sref<double>
sref< double > tsa::MAX ( sref< double >  a,
sref< double >  b 
)

Returns the larger of a or b.

Parameters
aSeries a.
bSeries b.
Returns
The maximum value.
sref< double > tsa::MAX ( sref< double >  data,
sref< size_t >  dynamic_period,
size_t  max_period 
)

Returns the largest value in data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have.

Parameters
dataThe data.
dynamic_periodThe dynamic period.
max_periodThe maximum period.
Returns
The maximum value.
sref< double > tsa::MEAN_DEV ( sref< double >  data,
sref< double >  custom_mean,
size_t  period 
)

Returns the average deviation between values in and the current value of custom_mean over the given period.

Parameters
dataThe data.
custom_meanThe custom mean.
periodThe period.
Returns
A sref<double>
sref< double > tsa::MEAN_DEV ( sref< double >  data,
size_t  period 
)

Returns the average deviation between the values in and their average over the given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::MEAN_DEV2 ( sref< double >  data,
sref< double >  custom_mean,
size_t  period 
)

Returns the average deviation squared between values in and the current value of custom_mean over the given period.

Parameters
dataThe data.
custom_meanThe custom mean.
periodThe period.
Returns
A sref<double>
sref< double > tsa::MEAN_DEV2 ( sref< double >  data,
size_t  period 
)

Returns the average deviation squared between the values in and their average over the given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::MEDIAN ( sref< double >  data,
size_t  period 
)

Returns the median of data over the given period.

Returns the median over the given period.

Parameters
dataThe data.
periodThe period.
Returns
The median value.
sref< double > tsa::MIN ( sref< double >  a,
sref< double >  b 
)

Returns the smaller of a or b.

Parameters
aSeries a.
bSeries b.
Returns
The maximum value.
sref< double > tsa::MIN ( sref< double >  data,
sref< size_t >  dynamic_period,
size_t  max_period 
)

Returns the smallest value in data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have.

Parameters
dataThe data.
dynamic_periodThe dynamic period.
max_periodThe maximum period.
Returns
The minimum value.
sref< double > tsa::POW ( sref< double >  base,
double  exponent 
)

Returns base raised to the power of exponent.

Parameters
baseThe base.
expThe exponent.
Returns
A sref<double>
sref< double > tsa::POW_DYN ( sref< double >  base,
sref< double >  exponent 
)

Returns base raised to the power of exponent.

Parameters
baseThe base.
exponentThe exponent.
Returns
A sref<double>
sref< double > tsa::ROLLING_SUM ( sref< double >  value)

Returns the rolling sum of all value items since the start of the strategy.

Parameters
valueThe value.
Returns
A sref<double>
sref< double > tsa::SAFE_DIVIDE ( sref< double >  numerator,
sref< double >  denominator,
double  denominator_adjust = 1e-9 
)

Divides numerator by denominator. If denominator is 0.0, then denominator_adjust is used instead of denominator to avoid division by zero.

Parameters
numeratorThe numerator.
denominatorThe denominator.
denominator_adjustThe denominator adjust.
Returns
A sref<double>
sref< double > tsa::SIN ( sref< double >  arg)

Computes the sine of arg (measured in radians).

Parameters
argThe argument.
Returns
A sref<double>
sref< double > tsa::SMA ( sref< double >  data,
size_t  period 
)

Returns the Symmetric Moving Average over the given period. (Alias for AVERAGE())

Parameters
serThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::SQRT ( sref< double >  value)

Returns the square root of value.

Parameters
valueThe value.
Returns
A sref<double>
sref< double > tsa::STDEVP ( sref< double >  data,
size_t  period 
)

Returns the population standard deviation of data over given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::SUM ( sref< double >  data,
size_t  period 
)

Returns the sum of data over the given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>
sref< double > tsa::SUM ( sref< double >  data,
sref< size_t >  dynamic_period,
size_t  max_period 
)

Returns the sum of data over the given dynamic_period. max_period is the maximum value that dynamic_period is allowed to have.

Parameters
dataThe data.
dynamic_periodThe dynamic period.
max_periodThe maximum period.
Returns
A sref<double>
sref< double > tsa::SUM_DEV ( sref< double >  data,
sref< double >  custom_mean,
size_t  period 
)

Returns the 'sum of deviations from custom_mean' over the given period. Only the current value of custom_mean is used.

sref< double > tsa::SUM_NEG ( sref< double >  data,
size_t  period 
)

Returns the 'sum of negatives' over the given period.

Parameters
dataThe data.
periodThe period.
Returns
The total number of negative.
sref< double > tsa::SUM_POS ( sref< double >  data,
size_t  period 
)

Returns the 'sum of positives' over the given period.

Parameters
dataThe data.
periodThe period.
Returns
The total number of position.
sref< double > tsa::SUM_SQ ( sref< double >  data,
size_t  period 
)

Returns the 'sum of squares' over the given period.

Parameters
dataThe data.
periodThe period.
Returns
The total number of sq.
sref< double > tsa::TAN ( sref< double >  arg)

Computes the tangent of arg, measured in radians.

Parameters
argThe argument.
Returns
A sref<double>
sref< double > tsa::VARP ( sref< double >  data,
size_t  period 
)

Returns the population variance of data over given period.

Parameters
dataThe data.
periodThe period.
Returns
A sref<double>