Trading System API
3.0
Library for Simulating and Deploying Trading and Investment Strategies
|
class series is a template class representing a sequence of values. More...
#include <TSASeriesTemplate.h>
Public Member Functions | |
series (const series_core &) | |
Constructor. More... | |
series (const std::string &auto_series_name) | |
Constructor. More... | |
series (void) | |
Default constructor. | |
series (const series< T > &other) | |
Copy Constructor. More... | |
series (size_t capacity) | |
Constructor. Creates an 'unmanaged' series with a fixed capacity and size 0. More... | |
virtual | ~series (void) |
Destructor. | |
size_t | capacity (void) const |
Returns the series capacity. Only available for 'unmanaged' series. Throws an exception if the series is 'managed'. More... | |
void | clear (void) |
Clears the series. WARNING: This only works for 'unmanaged' series. See is_managed(). | |
void | copy (const series &other, size_t max_num_values=~(size_t) 0) |
Copies num_values from the other series, starting at position 0. If num_values is 0, it copies the entire series, which will cause the capacity of self to be reset if it is not sufficient. More... | |
bool | crosses_above (const series< T > &other) const |
Returns true if self crossed above other on the most recent value. More... | |
bool | crosses_above (double threshold) const |
Returns true if self crossed above other on the most recent value. More... | |
bool | crosses_below (const series< T > &other) const |
Returns true if self crossed below other on the most recent value. More... | |
bool | crosses_below (double threshold) const |
Returns true if self crossed below other on the most recent value. More... | |
const T * | data (void) const |
Returns a pointer to the series data. The array length can be determined by calling size(). More... | |
bool | empty (void) const |
Returns true if the series is empty. More... | |
void | fill_to_capacity (T value) |
Clears the series and then fills it to capacity with given value. More... | |
T | get_at (size_t position) const |
Returns the value at given position. More... | |
bool | is_equal (const series< T > &other) const |
Returns true if self has same data as other. More... | |
bool | is_managed (void) const |
Query if this object is managed. More... | |
bool | is_owner (void) const |
Query if this object is owner. More... | |
const series< T > & | name (const std::string &name) const |
Names the given name. More... | |
series_cref< T > | operator() (size_t shift_by) const |
void | operator= (series_cref< T > &) |
void | operator= (const series< T > &other) |
T | operator[] (size_t position) const |
Returns the value at given position. More... | |
void | plot_as (const std::string &name, const tsa::variant &period=0.0, plot_type type=plot_type::line, tsa::color clr=tsa::color::auto_color, unsigned weight=2) const |
Plot as. More... | |
void | plot_as (const std::string &name, const std::vector< tsa::variant > &periods, plot_type type=plot_type::line, tsa::color clr=tsa::color::auto_color, unsigned weight=2) const |
Plot as. More... | |
void | plot_info (const plot_info &pi) const |
const tsa::plot_info & | plot_info (void) const |
void | print (std::ostream &stream, size_t max=1000) |
Prints the series to given stream. At most max items will be printed. The leftmost value printed corresponds to the value at position 0. More... | |
void | print_v (std::ostream &s, size_t max=1000) |
Prints the series to given stream, one data item per line. At most max items will be printed. The leftmost value printed corresponds to the value at position 0. More... | |
void | push (T) |
Adds a new value to the front of the series. The new item will be accessible at position 0. More... | |
void | push (const variant &) |
Adds a new value item to the front of the series. The new item will be accessible at index position 0. More... | |
void | reserve (size_t capacity) |
Sets the serie's capacity to at least as high as the given capacity argument. It is not possible to shrink capacity, although trying to do so will cause no error. More... | |
void | set_size (size_t new_size) |
Sets the size of self to new_size. This is a quick way to 'make space' without the overhead of calling push() for each value. new_size must be smaller or equal to the object's capacity. Values will not be initialized, and the idea is that the values will be initialized by an STL algorithm such as std::transform(). If you need all series values intialized to a particular value, use the fill() member. More... | |
const series< T > | shift (size_t _shift_by) const |
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... | |
size_t | size (void) const |
Returns the number of values stored in the series. More... | |
virtual bool | size_ok (size_t _required_size) const |
Size ok. More... | |
type_t | value_type (void) const |
Returns the data type of the values stored by the series. More... | |
void | verify_size (size_t reqired_size) const |
Compares the series size to required_size. If the series size is shorter then a lookback_exception is thrown. More... | |
Public Member Functions inherited from tsa::pane_format | |
void | copy_pane_format (const pane_format &other) const |
void | pane_auto_pane (bool b) const |
void | pane_dotted_grid (bool b) const |
void | pane_grid_color (const tsa::color &c) const |
void | pane_h_line (const h_line &hl) const |
void | pane_h_line (const tsa::color &c, double y_value, int weight) const |
const std::vector< tsa::h_line > & | pane_h_lines (void) const |
void | pane_show_grid (bool b) const |
void | pane_y_max (double max) const |
const variant & | pane_y_max (void) const |
void | pane_y_min (double min) const |
const variant & | pane_y_min (void) const |
Static Public Member Functions | |
static size_t | default_capacity (void) |
static void | reset_default_capacity (size_t new_capacity) |
Sets the default capacity of new series to new_capacity. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &s, series< T > &ser) |
Prints the series to given stream. More... | |
class series is a template class representing a sequence of values.
tsa::series< T >::series | ( | const series_core & | core | ) |
Constructor.
parameter1 | The first parameter. |
|
inline |
Constructor.
auto_series_name | Name of the automatic series. |
tsa::series< T >::series | ( | const series< T > & | other | ) |
Copy Constructor.
other | The first parameter. |
|
explicit |
Constructor. Creates an 'unmanaged' series with a fixed capacity and size 0.
capacity | The capacity. |
size_t tsa::series< T >::capacity | ( | void | ) | const |
Returns the series capacity. Only available for 'unmanaged' series. Throws an exception if the series is 'managed'.
void tsa::series< T >::copy | ( | const series< T > & | other, |
size_t | max_num_values = ~(size_t)0 |
||
) |
Copies num_values from the other series, starting at position 0. If num_values is 0, it copies the entire series, which will cause the capacity of self to be reset if it is not sufficient.
other | Another instance to copy. |
max_num_values | The maximum number values. |
bool tsa::series< T >::crosses_above | ( | const series< T > & | other | ) | const |
Returns true if self crossed above other on the most recent value.
other | The other. |
bool tsa::series< T >::crosses_above | ( | double | threshold | ) | const |
Returns true if self crossed above other on the most recent value.
threshold | The threshold. |
bool tsa::series< T >::crosses_below | ( | const series< T > & | other | ) | const |
Returns true if self crossed below other on the most recent value.
other | The other. |
bool tsa::series< T >::crosses_below | ( | double | threshold | ) | const |
Returns true if self crossed below other on the most recent value.
threshold | The threshold. |
const T * tsa::series< T >::data | ( | void | ) | const |
Returns a pointer to the series data. The array length can be determined by calling size().
|
inline |
Returns true if the series is empty.
void tsa::series< T >::fill_to_capacity | ( | T | value | ) |
Clears the series and then fills it to capacity with given value.
value | The value. |
T tsa::series< T >::get_at | ( | size_t | position | ) | const |
Returns the value at given position.
position | The position. |
bool tsa::series< T >::is_equal | ( | const series< T > & | other | ) | const |
Returns true if self has same data as other.
other | The other. |
bool tsa::series< T >::is_managed | ( | void | ) | const |
Query if this object is managed.
|
inline |
Query if this object is owner.
const series< T > & tsa::series< T >::name | ( | const std::string & | name | ) | const |
Names the given name.
T | Generic type parameter. |
name | The name. |
T tsa::series< T >::operator[] | ( | size_t | position | ) | const |
Returns the value at given position.
position | The position. |
|
inline |
Plot as.
name | The name. |
period | The period. |
type | The type. |
clr | The colour. |
weight | The weight. |
|
inline |
Plot as.
name | The name. |
periods | The periods. |
type | The type. |
clr | The colour. |
weight | The weight. |
void tsa::series< T >::print | ( | std::ostream & | stream, |
size_t | max = 1000 |
||
) |
Prints the series to given stream. At most max items will be printed. The leftmost value printed corresponds to the value at position 0.
[in,out] | stream | The stream. |
max | The maximum. |
void tsa::series< T >::print_v | ( | std::ostream & | s, |
size_t | max = 1000 |
||
) |
Prints the series to given stream, one data item per line. At most max items will be printed. The leftmost value printed corresponds to the value at position 0.
[in,out] | s | The std::ostream& to process. |
max | The maximum. |
void tsa::series< T >::push | ( | T | _v | ) |
Adds a new value to the front of the series. The new item will be accessible at position 0.
parameter1 | The parameter 1 to push. |
void tsa::series< T >::push | ( | const variant & | _v | ) |
Adds a new value item to the front of the series. The new item will be accessible at index position 0.
parameter1 | The parameter 1 to push. |
void tsa::series< T >::reserve | ( | size_t | capacity | ) |
Sets the serie's capacity to at least as high as the given capacity argument. It is not possible to shrink capacity, although trying to do so will cause no error.
capacity | The capacity. |
|
inlinestatic |
Sets the default capacity of new series to new_capacity.
new_capacity | The new capacity. |
void tsa::series< T >::set_size | ( | size_t | new_size | ) |
Sets the size of self to new_size. This is a quick way to 'make space' without the overhead of calling push() for each value. new_size must be smaller or equal to the object's capacity. Values will not be initialized, and the idea is that the values will be initialized by an STL algorithm such as std::transform(). If you need all series values intialized to a particular value, use the fill() member.
new_size | Size of the new. |
const series< T > tsa::series< T >::shift | ( | size_t | _shift_by | ) | const |
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().
_shift_by | Amount to shift by. |
size_t tsa::series< T >::size | ( | void | ) | const |
Returns the number of values stored in the series.
|
virtual |
Size ok.
_required_size | Size of the required. |
type_t tsa::series< T >::value_type | ( | void | ) | const |
Returns the data type of the values stored by the series.
void tsa::series< T >::verify_size | ( | size_t | reqired_size | ) | const |
Compares the series size to required_size. If the series size is shorter then a lookback_exception is thrown.
reqired_size | Size of the reqired. |
|
related |
Prints the series to given stream.
[in,out] | s | The std::ostream& to process. |
[in,out] | ser | The ser. |