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

Enumerations

Functions

size_t tsa::bars_since (const series< bool > &series, size_t period)
 Returns the number of bars since a value in series was 'true' (non-zero), in given period. If no values was true, the function returns tsa::NPOS. You must compare the return value against tsa::NPOS to ensure validity. More...
 
size_t tsa::bars_since_highest (const series< double > &series, size_t period)
 Returns the number of bars since maximum value in series over given period.
 
size_t tsa::bars_since_lowest (const series< double > &series, size_t period)
 Returns the number of bars since the minimum value in series over given period.
 
size_t tsa::bars_since_max (const series< double > &series, size_t period)
 Returns the number of bars since maximum value in series over given period.
 
size_t tsa::bars_since_min (const series< double > &series, size_t period)
 Returns the number of bars since the minimum value in series over given period.
 
size_t tsa::bars_since_nth (const series< bool > &series, size_t period, size_t n_count)
 Returns the number of bars since the n'th value in series was 'true' (non-zero), in given period. A argument of 3 for n_count would return the number of bars since the 3rd 'true' value, counting backwards from the current value. If no values was 'true', the function returns tsa::NPOS. You must compare the return value against tsa::NPOS to ensure validity. More...
 
bool tsa::crosses_above (const series< double > &series_a, const series< double > &series_b)
 Returns true when series_a crosses above series_b.
 
bool tsa::crosses_above (const series< double > &series, double threshold)
 Returns true when series crosses above threshold value.
 
bool tsa::crosses_below (const series< double > &series_a, const series< double > &series_b)
 Returns true when series_a crosses below series_b.
 
bool tsa::crosses_below (const series< double > &series, double threshold)
 Returns true when series crosses below threshold value.
 
bool tsa::float64_comparison (double a, double b, double tolerance=1e-12)
 Returns true if a is within tolerance or b, where tolerance is a fraction of the largest of the two numbers. More...
 
bool tsa::is_defined (const variant &v)
 Returns true if the given variant v is 'defined;. See variant::defined().
 
bool tsa::is_multiple_of (double value, double tick_size, double tolerance=1e-12)
 Returns true if value is an exact multiple of min_tick, to within a given tolerance, where the tolerance is interpreted as a fraction of value. This means the larger the value, the larger is the tolerance. More...
 
void tsa::populate_with_change_ratios (series< double > &target, series< double > &source, size_t period)
 Populates the target series with changes from one value to the next of the source series for the given period. The function throws an exception if it encounters 0.0 or negative numbers. This function first empties the target series. IMPORTANT: The target series must NOT be 'managed'. See series<t>::is_managed(). The target series will contain 1 item less than the source series. More...
 
void tsa::populate_with_changes (series< double > &target, const series< double > &source, size_t period)
 Populates the target series with changes from one value to the next of the source series for the given period. This function first empties the target series. IMPORTANT: The target series must NOT be 'managed'. See series<t>::is_managed(). The target series will contain 1 item less than the source series. More...
 
template<typename T >
const series< T > tsa::shift_by (const series< T > &in_series, size_t shift_by)
 Returns a series that is a 'shifted' version of the given in_series argument. The returned series will be shifted by shift places to the right. For a shift value of 3, the current value in the returned series will correspond to the value 3 bars ago in in_series. This function does not allow shifting to the left (into the future). For shifting series 'into the future', see in_stream::set_forward_shift(). More...
 
double tsa::tick_round (double price, double tick_size, tick_round_flag_t flag=closest)
 Rounds a given price to the nearest multiple of min_tick. By default if rounds to the closest multiple. Note that that order prices are automatically rounded by the system if the contract::tick() member is called. Automatic rounding can be disabled via the contract::tick() member's second parameter. More...
 
bool tsa::turns_neg (const series< double > &series)
 Returns true when seris crosses below 0.0.
 
bool tsa::turns_pos (const series< double > &series)
 Returns true when series crosses above 0.0.
 

Detailed Description

Enumeration Type Documentation

Rounding flag for tick_round() function.

Enumerator
closest 

Default rounding. Rounds up if above the mid point, else down.

up 

Rounds up to next higher multiple of minimum-tick.

down 

Rounds down to next lower multiple of minimum-tick.

Function Documentation

size_t tsa::bars_since ( const series< bool > &  series,
size_t  period 
)

Returns the number of bars since a value in series was 'true' (non-zero), in given period. If no values was true, the function returns tsa::NPOS. You must compare the return value against tsa::NPOS to ensure validity.

Parameters
seriesThe series.
periodThe period.
Returns
A size_t.
size_t tsa::bars_since_nth ( const series< bool > &  series,
size_t  period,
size_t  n_count 
)

Returns the number of bars since the n'th value in series was 'true' (non-zero), in given period. A argument of 3 for n_count would return the number of bars since the 3rd 'true' value, counting backwards from the current value. If no values was 'true', the function returns tsa::NPOS. You must compare the return value against tsa::NPOS to ensure validity.

Parameters
seriesThe series.
periodThe period.
n_countNumber of.
Returns
A size_t.
bool tsa::float64_comparison ( double  a,
double  b,
double  tolerance = 1e-12 
)

Returns true if a is within tolerance or b, where tolerance is a fraction of the largest of the two numbers.

Parameters
aThe double to process.
bThe double to process.
toleranceThe tolerance.
Returns
true if it succeeds, false if it fails.
bool tsa::is_multiple_of ( double  value,
double  tick_size,
double  tolerance = 1e-12 
)

Returns true if value is an exact multiple of min_tick, to within a given tolerance, where the tolerance is interpreted as a fraction of value. This means the larger the value, the larger is the tolerance.

Parameters
valueThe value.
tick_sizeThe minimum tick.
toleranceThe tolerance.
Returns
true if multiple of, false if not.
void tsa::populate_with_change_ratios ( series< double > &  target,
series< double > &  source,
size_t  period 
)

Populates the target series with changes from one value to the next of the source series for the given period. The function throws an exception if it encounters 0.0 or negative numbers. This function first empties the target series. IMPORTANT: The target series must NOT be 'managed'. See series<t>::is_managed(). The target series will contain 1 item less than the source series.

Parameters
[in,out]targetTarget for the.
[in,out]sourceSource for the.
periodThe period.
void tsa::populate_with_changes ( series< double > &  target,
const series< double > &  source,
size_t  period 
)

Populates the target series with changes from one value to the next of the source series for the given period. This function first empties the target series. IMPORTANT: The target series must NOT be 'managed'. See series<t>::is_managed(). The target series will contain 1 item less than the source series.

Parameters
[in,out]targetTarget for the.
sourceSource for the.
periodThe period.
template<typename T >
const series<T> tsa::shift_by ( const series< T > &  in_series,
size_t  shift_by 
)

Returns a series that is a 'shifted' version of the given in_series argument. The returned series will be shifted by shift places to the right. For a shift value of 3, the current value in the returned series will correspond to the value 3 bars ago in in_series. This function does not allow shifting to the left (into the future). For shifting series 'into the future', see in_stream::set_forward_shift().

Template Parameters
TGeneric type parameter.
Parameters
in_seriesThe in series.
shift_byAmount to shift by.
Returns
A series<T>
double tsa::tick_round ( double  price,
double  tick_size,
tick_round_flag_t  flag = closest 
)

Rounds a given price to the nearest multiple of min_tick. By default if rounds to the closest multiple. Note that that order prices are automatically rounded by the system if the contract::tick() member is called. Automatic rounding can be disabled via the contract::tick() member's second parameter.

Parameters
priceThe price.
tick_sizeThe minimum tick.
flagThe flag.
Returns
A double.