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

Functions

sref< std::string > tsa::CONST (const char *value)
 Returns a contant series of type 'string' with given value. More...
 
template<typename T >
sref< T > tsa::CONST (T value)
 Returns a contant series reference of given value and type T. More...
 
sref< bool > tsa::CROSSES_ABOVE (const series< double > &a, const series< double > &b)
 Returns true if series a crosses above series b. More...
 
sref< bool > tsa::CROSSES_BELOW (const series< double > &a, const series< double > &b)
 Returns true if series a crosses below series b. More...
 
template<typename T >
sref< T > tsa::GET (T &arg_ref)
 Translates the scalar value referred to by arg_ref (normally referring to a strategy member) into a DSL series for use in DLS. Use this GET() function in conjunction with SET() to interact with non-DSL variables. More...
 
template<typename T >
scalar_assigner< T > tsa::SET (T &var_ref)
 
template<typename T >
sref< T > tsa::SHIFT (const series< T > &series, size_t shift_by)
 Shifts the series by shift_by positions. This is the equivalent of using series<T>::operator(). More...
 
template<typename T >
sref< T > tsa::SHIFT (const sref< T > &series, size_t shift_by)
 Shifts the series by shift_by positions. This is the equivalent of using series_cref<T>::operator(). More...
 
template<typename T >
sref< T > tsa::TRANSFORM_SERIES (sref< T > data, size_t period, const std::function< T(const T *, size_t)> &transform_function)
 Returns a transformation of the values in data over the given period, by applying transform_function, which is usually a lambda function. The pointer to the front of data, together with period are passed as argument to the transform_function. More...
 
template<typename T0 , typename T1 >
sref< T0 > tsa::TRANSFORM_SERIES (sref< T0 > data0, sref< T1 > data1, size_t period, const std::function< T0(const T0 *, const T1 *, size_t)> &transform_function)
 Returns a transformation of the values in data0 and data1 over the given period, by applying transform_function, which is usually a lambda function. The pointer to the front of data0 and data1, together with period are passed as argument to the transform_function, which is usually a lambda function. The following code calculates a sum over a dynamic period. More...
 
sref< bool > tsa::X_ABOVE (const series< double > &a, const series< double > &b)
 alias for CROSSES_ABOVE.
 
sref< bool > tsa::X_BELOW (const series< double > &a, const series< double > &b)
 alias for CROSSES_bELOW.
 

Detailed Description

Function Documentation

sref< std::string > tsa::CONST ( const char *  value)

Returns a contant series of type 'string' with given value.

Parameters
valueThe string value.
Returns
A sref<std::string>
template<typename T >
sref<T> tsa::CONST ( value)

Returns a contant series reference of given value and type T.

Template Parameters
TGeneric type parameter.
Parameters
valueThe value.
Returns
A sref<T>
sref< bool > tsa::CROSSES_ABOVE ( const series< double > &  a,
const series< double > &  b 
)

Returns true if series a crosses above series b.

Parameters
aseries a.
bseries b.
Returns
A sref<bool>
sref< bool > tsa::CROSSES_BELOW ( const series< double > &  a,
const series< double > &  b 
)

Returns true if series a crosses below series b.

Parameters
aseries a.
bseries b.
Returns
A sref<bool>
template<typename T >
sref<T> tsa::GET ( T &  arg_ref)

Translates the scalar value referred to by arg_ref (normally referring to a strategy member) into a DSL series for use in DLS. Use this GET() function in conjunction with SET() to interact with non-DSL variables.

Template Parameters
TTemplate argument.
Parameters
[in,out]arg_refThe argument reference.
Returns
A sref<T>
template<typename T >
sref<T> tsa::SHIFT ( const series< T > &  series,
size_t  shift_by 
)

Shifts the series by shift_by positions. This is the equivalent of using series<T>::operator().

Template Parameters
Ttemplate argument.
Parameters
seriesThe series.
shift_byAmount to shift by.
Returns
A sref<T>
template<typename T >
sref<T> tsa::SHIFT ( const sref< T > &  series,
size_t  shift_by 
)

Shifts the series by shift_by positions. This is the equivalent of using series_cref<T>::operator().

Template Parameters
Ttemplate argument.
Parameters
seriesThe series.
shift_byAmount to shift by.
Returns
A sref<T>
template<typename T >
sref<T> tsa::TRANSFORM_SERIES ( sref< T >  data,
size_t  period,
const std::function< T(const T *, size_t)> &  transform_function 
)

Returns a transformation of the values in data over the given period, by applying transform_function, which is usually a lambda function. The pointer to the front of data, together with period are passed as argument to the transform_function.

auto sum = TRANSFORM_SERIES<double>(mkt.close, 10,
[](const double* data, size_t period)
{
double sum = 0.0;
for (size_t c = 0;c < period; c++) {
sum += data[c];
}
return sum;
});

.

Template Parameters
TTemplate arg.
Parameters
dataThe data.
periodThe period.
transform_functionThe transform function.
Returns
A sref<T>
template<typename T0 , typename T1 >
sref<T0> tsa::TRANSFORM_SERIES ( sref< T0 >  data0,
sref< T1 >  data1,
size_t  period,
const std::function< T0(const T0 *, const T1 *, size_t)> &  transform_function 
)

Returns a transformation of the values in data0 and data1 over the given period, by applying transform_function, which is usually a lambda function. The pointer to the front of data0 and data1, together with period are passed as argument to the transform_function, which is usually a lambda function. The following code calculates a sum over a dynamic period.

auto dyn_sum = TRANSFORM_SERIES<double, size_t>(mkt.close, dyn_period, 20,
[](const double* data, const size_t* dyn_period, size_t max_period)
{
double sum = 0.0;
size_t adj_period = dyn_period[0];
if (adj_period == 0)
adj_period = 1;
if (adj_period > max_period)
adj_period = max_period;
for (size_t c = 0; c<adj_period; c++) {
sum += data[c];
}
return sum;
})

.

Template Parameters
T0Template arg 1.
T1Template arg 2.
Parameters
data0The data0.
data1The data1.
periodThe period.
transform_functionThe transform function.
Returns
A sref<T0>