Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
tsa Namespace Reference

Namespace for the 'Trading System API' library. More...

Namespaces

 fast
 namespace for native timeseries database.
 
 functor
 Namespace for functors (stateful function objects). As these objects retain state between bars they have higher performance than regular functions.
 
 net
 
 
 plot
 Namespace for plot types that are used in conjunction with class chart.
 
 postgres
 Namespace for Postgresql database functionality.
 
 sqlite
 namespace for sqlite database functionality
 

Classes

class  any_series_cref
 any series cref. More...
 
class  appendable
 Represents an object to which a record object can be appended. More...
 
class  auto_cast_bool_series_cref
 An automatic cast bool series cref. More...
 
class  auto_cast_variant
 
class  bool_series_cref
 The series cref. More...
 
class  chart
 Class representing a timeseries chart. More...
 
class  color
 Represents a color for use in graphics operations. More...
 
class  color_id
 x More...
 
class  column_defs
 Defines the columnar structure of a table. Each column has a name, data type and field size. Instances of this class may also be used to describe the field structure in records. More...
 
class  component
 Base class for components such as series_base adaptors. More...
 
class  container
 A container. More...
 
class  data_base
 Base class for all other database classes such as: More...
 
class  date
 A date of the Gregorian calendar. More...
 
class  date_series_cref
 A date series cref. More...
 
class  date_time
 Class representing a gregorian-date and time-of-day combination. The time component has microsecond resolution. More...
 
class  datetime_series_cref
 A datetime series cref. More...
 
class  duration
 Represents a duration - the difference between two date_time values. More...
 
class  exception
 Class tsa::exception used by most classes of the Trading System API library. The class inherits from std::exception (standard C++ library). Class tsa::exception extends std::exception by including the file and line number of the code that originated the exception in the exception message. More...
 
class  exchange_parser
 Represents a symbol/exchange combination. More...
 
class  external_table_reader
 Abstract base class for objects that read tables sequentially by loading chunks of data, such as from a relational database. More...
 
class  file_import_rules__obsolete
 Describes the rules by which a file is to be imported. This structure is to be used in conjunction with the database::import_file() member. More...
 
struct  h_line
 A line. More...
 
struct  horizontal_line
 Class that represents a horizontal line to be drawn on a chart. More...
 
class  in_stream
 Record stream class. Represents a standardised interface to all data sources. Instances rely on delegates to provide access to specific data sources. Delegates must derive from class in_stream_adaptor. More...
 
class  in_stream_adaptor
 Parent class for 'in-stream adaptors'. in_stream object rely on adaptors for access to underlying data source. In order to support access to new data sources, new in_stream_adaptor derived classes must be implemented. More...
 
class  instrument
 Class instrument represents a tradeable security such as a stock, option, futures contract, currency, etc. Class instrument combines data-access with functionality for placing orders and managing positions. More...
 
class  json
 A class representing JSON objects. More...
 
struct  library
 Contains the library's copyright notice as well as version information. More...
 
class  manual_ohlcv
 Allows users to manually submit record data for the next bar. This is useful for testing new functionality. More...
 
class  mem_table
 Class mem_table represents a memory based table. mem_table objects can be used in strategies both for input and output. Note that memory requirements can grow rapidly. By default, the size of mem_table objects is limited to 2 million records. This limit can be reset via the size_limit(size_t) member. More...
 
struct  metric
 structure defining all the metric names. For example, you can pass metric::trade_count as metric_name argument to the strategy::metric( More...
 
class  metrics
 Strategy performance metrics. More...
 
class  metrics_container
 Base class for classes that can produce metrics. More...
 
class  metrics_source
 Base class for classes that can produce metrics. More...
 
class  numeric_series_cref
 A numeric series cref. More...
 
class  object
 Parent class for many library classes. More...
 
class  order
 Class order is the library's internal order representation. Users are not intended to interact with this class directly and its member functions are not documented. Use class order_ref to interact with orders. More...
 
class  order_ref
 Represents a reference to an internally managed order object. Working with class order directly is not required as class order_ref exposes all necessary functionality for working with trading orders. Class order itself is undocumented. More...
 
class  out_stream
 Class out_stream is used to write strategy output to various targets such as files, charts and series_base tables. More...
 
class  out_stream_adaptor
 Abstract base class for delegates of class out_stream. More...
 
class  pane_format
 A pane format. More...
 
class  pane_proxy
 Proxy class for class chart::pane. To be used for setting pane properties. An instance of this class is returned by chart::get_pane(size_t). More...
 
struct  plot_info
 Information about the plot. More...
 
struct  r_tuple
 Return tuple of LinearRegression function. More...
 
class  random_walk_stream
 
class  record
 Class representing a database record. More...
 
struct  reject_info
 Structure containing informations about rejects. More...
 
class  series
 class series is a template class representing a sequence of values. More...
 
class  series_bounds_error
 Exception class thrown by series when insufficient data. More...
 
class  series_cref
 The series cref. More...
 
class  series_tuple
 The series tuple. More...
 
class  strategy
 Class strategy represents a trading or investment strategy. More...
 
class  string_series_cref
 A string series cref. More...
 
class  string_splitter
 Support class for splitting 'record' strings into 'fields' using separator characters such as ','. More...
 
class  swing_finder
 Swing finder. More...
 
class  symbol_parser
 Parses symbol:expiry combinations. More...
 
class  table
 Supports 'write', 'update', 'delete', and 'read' operations on series_base tables. More...
 
class  table_copy_params
 A class representing the rules to use when copying database tables (usually between databases). More...
 
class  time_point_stream
 Parent class to classes generating a strategy scheduling sequences. (see strategy::schedule_with()) More...
 
class  time_point_stream__platform
 A platform time point stream. More...
 
class  time_point_stream_daily
 Class to dynamically generate daily intervals for strategy scheduling purposes. Instances should be declared as a strategy member and passed to strategy::schedule_with() as part of strategy::on_start(). More...
 
class  timer
 A timer. More...
 
struct  trade_info
 Information on closed out trades. More...
 
struct  trade_leg
 A trade leg. More...
 
class  transaction
 Represents a transaction that occurred on an exchange or as part of a simulation when an order is filled or partially filled. More...
 
struct  trend_line
 Class that represents a trendline to be drawn on a chart. More...
 
class  variant
 variant objects can represent values of different types. More...
 

Typedefs

typedef int64_t identifier_t
 type for ID's
 
typedef int64_t position_t
 
typedef int64_t quantity_t
 
typedef _value_types_type type_t
 Defines type_t as an alias of enum _value_types_type.
 

Enumerations

Functions

void __dsl_print (const std::string &msg, const any_series_cref &value)
 
template<typename T >
sref< T > ABS (sref< T > data)
 Returns the absolute value of data. More...
 
sref< double > 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 > 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 > AD (sref< double > &open, sref< double > &highs, sref< double > &lows, sref< double > &closes, sref< double > vol)
 
sref< double > AD (sref< double > &highs, sref< double > &lows, sref< double > &closes, sref< double > &vol)
 
sref< double > ADX (sref< double > highs, sref< double > lows, sref< double > closes, size_t period, size_t period_smooth)
 Average Directional Index by Welles Wilder. More...
 
sref< double > ATAN (sref< double > arg)
 Returns the arc-tangent of arg. More...
 
double average (const series< double > &data, size_t period)
 Returns the the average value of data with given period.
 
sref< double > AVERAGE (sref< double > data, size_t period)
 Returns the average value over the given period. More...
 
sref< double > AVERAGE (const container &c)
 Returns the average of the current values of all series in given container c.
 
double average_variable (const series< double > &data, size_t var_period, size_t max_period)
 Returns the the average value of data with a variable period, where the period is capped at max_period.
 
double average_weighted (const series< double > &data, size_t period)
 Returns the weighted average value of data over given period.
 
series_tuple< double > BANDPASSFILTER (sref< double > data, size_t period, double bandwidth)
 Returns Bandpass Filter. More...
 
sref< int64_t > BAR_COUNT (void)
 Returns the strategy's current bar-count. Returns the same value as strategy::bar_count().
 
size_t 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 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 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 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 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 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...
 
series_tuple< double > BB (sref< double > highs, sref< double > lows, sref< double > closes, size_t period, double stdev=2.0)
 Bollinger Bands are volatility bands located a given standard deviation above and below the moving average. They were developed by John Bollinger. More...
 
series_tuple< double > BEAR_POWER (sref< double > highs, sref< double > lows, sref< double > closes, size_t period=13)
 Returns the 'Bear Power' as developed by Alexander Elder. More...
 
series_tuple< double > BULL_POWER (sref< double > highs, sref< double > lows, sref< double > closes, size_t period=13)
 Returns the 'Bull Power' as developed by Alexander Elder. More...
 
sref< double > BUTTERWORTHMA (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Butterworth MA, 2 poles. More...
 
sref< double > BUTTERWORTHMA (sref< double > data, size_t period, size_t max_period)
 Returns Static Butterworth MA, 2 poles. More...
 
sref< double > BUTTERWORTHMA_3P (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Butterworth MA, 3 poles. More...
 
sref< double > BUTTERWORTHMA_3P (sref< double > data, size_t period, size_t max_period)
 Returns Static Butterworth MA, 3 poles. More...
 
double cap (double number, double max)
 Returns the lower of number or max.
 
sref< double > 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 > CAP (sref< double > value, sref< double > cap)
 Caps value at cap. If value is larger than cap, then cap is returned, else value. More...
 
double cap_floor (double number, double min, double max)
 Returns number if number is between max and min, else max if above, or min if below.
 
sref< double > CCI (sref< double > highs, sref< double > lows, sref< double > closes, size_t period)
 Returns the Commodity Channel Index (CCI) as developed by Donald Lambert. It represents the difference of the current price and an average over the given period adjusted by the average deviation from the average over the given period. More...
 
sref< double > CGO (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Center of Gravity Oscillator (CGO), dynamic period. More...
 
sref< double > CGO (sref< double > data, size_t period, size_t max_period)
 Returns Center of Gravity Oscillator (CGO), static period. More...
 
sref< double > CGO_ADAPTIVE (sref< double > data, double alpha)
 Returns Adapptive Center of Gravity Oscillator (CGO). More...
 
sref< double > CHAIKIN_ADL (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > volumes)
 'Chaiking Accumulation Distribution'. Measures the cummulative 'Money Flow Volume' (CHAIKIN_MFV()) into and out of a security. More...
 
sref< double > CHAIKIN_MF (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > volumes, size_t period)
 'Chaikin Money Flow'. Represents the 'Money Flow Volume' (CHAIKING_MFV()) over a given period of time. More...
 
sref< double > CHAIKIN_MFV (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > volumes)
 'Chaikin Money Flow Volume'. Measures the amount of money flowing into and out of a traded security on a given price bar. More...
 
sref< double > CHAIKIN_OSC (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > volumes, size_t period)
 Returns the 'Chaikin Oscilator'. More...
 
sref< double > CHAIKIN_VOLAT (sref< double > highs, sref< double > lows, size_t period)
 Returns the 'Chaikin Volatility'. More...
 
sref< std::stringCONST (const char *value)
 Returns a contant series of type 'string' with given value. More...
 
template<typename T >
sref< T > CONST (T value)
 Returns a contant series reference of given value and type T. More...
 
double const_e (void)
 Returns the value of E as 2.718281828459045235.
 
double const_phi (void)
 Returns the value of Phi (Golden Ratio) as 1.61803398874989.
 
double const_pi (void)
 defines the value of Pi as 3.14159265358979323846264.
 
template<typename T >
sref< T > CONST_SERIES (const std::vector< T > &values)
 Returns a series that is constant by copying the data vector values. The series never changes and cannot be changed. More...
 
sref< double > CORRELATION (sref< double > series_a, sref< double > series_b, size_t period)
 Returns the Correlation between two series. More...
 
double correlation (const series< double > &x, const series< double > &y, size_t period)
 Returns the correlation coefficient of series and series over given period.
 
sref< double > COS (sref< double > arg)
 Computes the cosine of arg (measured in radians). More...
 
bool crosses_above (const series< double > &series_a, const series< double > &series_b)
 Returns true when series_a crosses above series_b.
 
bool crosses_above (const series< double > &series, double threshold)
 Returns true when series crosses above threshold value.
 
sref< bool > CROSSES_ABOVE (const series< double > &a, const series< double > &b)
 Returns true if series a crosses above series b. More...
 
bool crosses_below (const series< double > &series_a, const series< double > &series_b)
 Returns true when series_a crosses below series_b.
 
bool crosses_below (const series< double > &series, double threshold)
 Returns true when series crosses below threshold value.
 
sref< bool > CROSSES_BELOW (const series< double > &a, const series< double > &b)
 Returns true if series a crosses below series b. More...
 
sref< double > CYBERCYCLE (sref< double > data, double alpha)
 Returns Cyber Cycle. More...
 
sref< double > CYBERCYCLE_ADAPTIVE (sref< double > data, double alpha)
 Returns Adaptive Cyber Cycle. More...
 
sref< double > CYBERCYCLE_P (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Cyber Cycle with period. More...
 
sref< double > CYBERCYCLE_P (sref< double > data, size_t period, size_t max_period)
 Returns Static Cyber Cycle with period. More...
 
sref< double > DCMA (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic DCMA. More...
 
sref< double > DCMA (sref< double > data, size_t period, size_t max_period)
 Returns Static DCMA. More...
 
sref< double > DECYCLEROSC (sref< double > data, size_t hp_period1, size_t hp_period2)
 Returns Decycler Oscillator (CAT). More...
 
double degrees (double radians)
 Converts radians to degrees.
 
sref< double > DI_DN (sref< double > highs, sref< double > lows, sref< double > closes, size_t period)
 
sref< double > DI_UP (sref< double > highs, sref< double > lows, sref< double > closes, size_t period)
 
sref< double > DM_DN (sref< double > highs, sref< double > lows, size_t period)
 
sref< double > DM_DN_RAW (sref< double > highs, sref< double > low)
 
sref< double > DM_UP (sref< double > highs, sref< double > lows, size_t period)
 
sref< double > DM_UP_RAW (sref< double > highs, sref< double > low)
 
sref< double > DMI (sref< double > highs, sref< double > lows, sref< double > closes, size_t period)
 
sref< size_t > DOMINANTCYCLEPERIOD_AC (sref< double > close)
 Returns Autocorrelation Dominant Cycle Period. More...
 
sref< size_t > DOMINANTCYCLEPERIOD_HILBERT (sref< double > data)
 Returns Dominant Cycle Period using the Hilbert Transform. More...
 
sref< size_t > DOMINANTCYCLEPERIOD_HOMODYNE (sref< double > data)
 Returns Dominant Cycle Period using Homodyne Discriminator. More...
 
sref< double > E (void)
 Returns a value of 'e' as a series of constants (2.718281828459045235).
 
sref< double > EASE_OF_MOV (sref< double > highs, sref< double > lows, sref< double > vol, size_t smooth_period)
 Ease of Movement. More...
 
sref< double > EASE_OF_MOV_RAW (sref< double > highs, sref< double > lows, sref< double > vol)
 Ease of Movement (Raw) More...
 
sref< double > EMA (sref< double > data, size_t period)
 Returns the 'Exponential Moving Average' with the given period. More...
 
sref< double > EMA_WILDER (sref< double > data, size_t period)
 Exponential moving average by Welles Wilder. Differs from regular EMA(). More...
 
sref< double > EXP (sref< double > power)
 Raises const 'E' to the given power. The inverse of LN(). More...
 
sref< double > FISHERCGO (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Fisher Center of Gravity Oscillator (FCGO). More...
 
sref< double > FISHERCGO (sref< double > data, size_t period, size_t max_period)
 Returns Fisher Center of Gravity Oscillator (FCGO). More...
 
sref< double > FISHERRVI (sref< double > op, sref< double > hi, sref< double > lo, sref< double > cl, sref< size_t > period, size_t max_period)
 Returns Dynamic Fisher Relative Vigour Index (FISHERRVI). More...
 
sref< double > FISHERRVI (sref< double > op, sref< double > hi, sref< double > lo, sref< double > cl, size_t period, size_t max_period)
 Returns Static Fisher Relative Vigour Index (FISHERRVI). More...
 
sref< double > FISHERTRANSFORM (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Fisher Transform. More...
 
sref< double > FISHERTRANSFORM (sref< double > data, size_t period, size_t max_period)
 Returns Static Fisher Transform. More...
 
bool 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...
 
double floor (double number, double min)
 Returns the higher of number or min.
 
sref< double > 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 > 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< double > FORCE_INDEX (sref< double > closes, sref< double > volumes, size_t period)
 Returns the 'Force Index'. It represents a smoothing of the value returned by RAW_FORCE_INDEX(). More...
 
sref< double > FORCE_INDEX_RAW (sref< double > closes, sref< double > volumes)
 Returns the 'Raw Force Index'. It represents the price change from the previous bar multiplied by volume, to provide a measure of 'force'. Developed by Alexander Elder. More...
 
sref< bool > 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...
 
double gaussian (double stdev)
 Returns a random double with given stdev and mean of 0.0.
 
sref< double > GAUSSIAN (double std_dev)
 Returns a 'gaussian' random value; A 'unit gaussian' multiplied by the given std_dev.
 
template<typename T >
sref< T > 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...
 
double highest (const series< double > &series, size_t period)
 Returns the highest value found in series over given .
 
sref< double > HIGHEST (sref< double > data, size_t period)
 Returns the maximum value in data over the given period.
 
series_tuple< double > HILBERT_OSC (sref< double > data)
 Returns Ehlers' Hilbet Oscillator. More...
 
sref< double > IFISHERCYBERCYCLE (sref< double > data, double alpha)
 Returns Inverse Fisher Cyber Cycle. More...
 
sref< double > IFISHERCYBERCYCLE_P (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Inverse Fisher Cyber Cycle with period. More...
 
sref< double > IFISHERCYBERCYCLE_P (sref< double > data, size_t period, size_t max_period)
 Returns Static Inverse Fisher Cyber Cycle with period. More...
 
sref< double > INNER_PRODUCT (sref< double > x, sref< double > y, size_t period)
 Returns the 'inner product' of x and y over the given period.
 
template<typename T >
sref< T > invoke_function (const std::function< T(void)> &member_func)
 Generic way of invoking an object member function from DSL. The following function returns the strategy's current timestamp: More...
 
bool is_defined (const variant &v)
 Returns true if the given variant v is 'defined;. See variant::defined().
 
bool 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...
 
sref< double > ITREND_RST (sref< double > data)
 Returns Instantaneous Trendline. More...
 
sref< double > KALMANMA (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Kalman MA. More...
 
sref< double > KALMANMA (sref< double > data, size_t period, size_t max_period)
 Returns Static Kalman MA. More...
 
sref< double > LAGUERREMA (sref< double > data, double gamma)
 Returns Laguerre MA. More...
 
sref< double > LAGUERRERSI (sref< double > data, double gamma)
 Returns Laguerre RSI. More...
 
r_tuple linear_regression (const series< double > &series, size_t period)
 Returns various regression measures of series against time over given period.
 
sref< double > LN (sref< double > value)
 Returns the natural logarithm of value. More...
 
sref< double > LOG10 (sref< double > value)
 Returns the log10 logarithm of value. More...
 
double lowest (const series< double > &series, size_t period)
 Returns the smallest value found in series over given .
 
sref< double > LOWEST (sref< double > data, size_t period)
 Returns the minimum value in data over the given period.
 
series_tuple< double > MACD (sref< double > closes, size_t short_period=12, size_t long_period=26, size_t signal_period=9)
 Moving Average Convergence Divergence (MACD) as developed by Thomas Aspray. It measures the difference between two moving averages. The indicator is often shown as a histogram which is the difference between the MACD and a signal line (moving average of MACD). More...
 
series_tuple< double > MAMA_FAMA (sref< double > data, double fast_limit, double slow_limit)
 Returns Ehlers' MAMA and FAMA. More...
 
sref< double > MASS_INDEX (sref< double > closes, size_t avg_period=9, size_t avg_of_avg_period=9, size_t ratio_sum_period=25)
 Mass Index. A measure of range expansion developed by Donald Dorsey. More...
 
double max (const series< double > &series, size_t period)
 Returns the highest value found in series over given .
 
sref< double > MAX (sref< double > data, size_t period)
 Returns the maximum value in data over the given period.
 
sref< double > MAX (sref< double > a, sref< double > b)
 Returns the larger of a or b. More...
 
sref< double > MAX (const container &c)
 Returns the maximum current values of all series in given container c.
 
sref< double > 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...
 
date_time max (const date_time &left, const date_time &right)
 Determines the larger (later) of the two time-points. Will return a value even if both time-points are identical. More...
 
sref< double > MEAN (const container &c)
 Alias for AVERAGE(const container& c).
 
sref< double > 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 > 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 > 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 > 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 > MEDIAN (sref< double > data, size_t period)
 Returns the median of data over the given period. More...
 
sref< double > MFI (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > vol, size_t period=14)
 Money Flow Index. More...
 
double min (const series< double > &series, size_t period)
 Returns the smallest value found in series over given .
 
sref< double > MIN (sref< double > data, size_t period)
 Returns the minimum value in data over the given period.
 
sref< double > MIN (sref< double > a, sref< double > b)
 Returns the smaller of a or b. More...
 
sref< double > MIN (const container &c)
 Returns the minimum current values of all series in given container c.
 
sref< double > 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...
 
date_time min (const date_time &left, const date_time &right)
 Determines the smaller (earlier) of the two time-points. Will return a value even if both time-points are identical. More...
 
double momentum (const series< double > &cl, size_t period)
 Returns the difference between the current value of the series and the value period bars ago. More...
 
sref< double > NET_PROFIT (void)
 Returns the strategy's current 'net profit'.
 
sref< bool > operator! (auto_cast_bool_series_cref x)
 Unary 'logical not' operator.
 
sref< bool > operator!= (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
bool operator!= (const order_ref &lhs, const order_ref &rhs)
 comparison operator
 
sref< double > operator% (numeric_series_cref a, numeric_series_cref b)
 Floating point modulo.
 
sref< bool > operator&& (auto_cast_bool_series_cref a, auto_cast_bool_series_cref b)
 Logical-and. Casts a and b to boolean before checking if both are true.
 
sref< double > operator* (numeric_series_cref a, numeric_series_cref b)
 Multiplies a by b.
 
sref< double > operator+ (numeric_series_cref a, numeric_series_cref b)
 Adds a and b.
 
date operator+ (const date &date, const duration &num_days)
 Adds num_days to self. The microsecond property of the given timespan must be zero or an exception is thrown. More...
 
sref< double > operator- (numeric_series_cref a, numeric_series_cref b)
 Subtracts b from a.
 
sref< double > operator- (numeric_series_cref)
 Unary minus operator.
 
date operator- (const date &Left, const duration &numDays)
 Subtracts num_days from self. The microsecond property of the given timespan must be zero or an exception is thrown. More...
 
sref< double > operator/ (numeric_series_cref a, numeric_series_cref b)
 Divides a by b.
 
sref< bool > operator< (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
std::ostream & operator<< (std::ostream &stream, const transaction &t)
 Writes human readable transaction information to stream. More...
 
std::ostream & operator<< (std::ostream &stream, const duration &ts)
 Writes ts to stream as a string.
 
sref< bool > operator<= (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
sref< bool > operator== (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
bool operator== (const order_ref &lhs, const order_ref &rhs)
 comparison operator
 
sref< bool > operator> (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
sref< bool > operator>= (numeric_series_cref a, numeric_series_cref b)
 comparison.
 
log_type_t operator| (log_type_t lhs, log_type_t rhs)
 Allows multiple LogType values to be combined. More...
 
open_db_flag_type operator| (open_db_flag_type left_flag, open_db_flag_type right_flag)
 Allows multiple fast::database constructor flags to be combined. More...
 
sref< bool > operator|| (auto_cast_bool_series_cref a, auto_cast_bool_series_cref b)
 Logical-or. Casts a and b to boolean before checking if either is true.
 
sref< double > PHI (void)
 Returns a value of 'phi' as a series of constants (1.61803398874989).
 
sref< double > PI (void)
 Returns a value of 'pi' as a series of constants (3.14159265358979323846264).
 
void 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 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...
 
sref< double > POW (sref< double > base, double exponent)
 Returns base raised to the power of exponent. More...
 
sref< double > POW_DYN (sref< double > base, sref< double > exponent)
 Returns base raised to the power of exponent. More...
 
double radians (double degrees)
 Converts degrees to radians.
 
double rand (double low=0.0, double high=1.0)
 Returns a random double between low and high (inclusive)
 
sref< double > RAND (double low=0.0, double high=1.0)
 Returns a (uniformly distributed) random value between low and high.
 
bool rand_bool (double probability_of_true=0.5)
 Returns a random boolean value with a given probability_of_true.
 
sref< bool > RAND_BOOL (double true_probability=0.5)
 Returns a random boolean value with a given true_probability.
 
int rand_int (int low, int high)
 Returns a random integer between low and high (inclusive)
 
sref< int > RAND_INT (int low, int high)
 Returns a (uniformly distributed) random integer between low and high.
 
std::string rand_string (size_t min_len=10, size_t max_len=10)
 Returns a random character string with a length between min_len to max_len.
 
sref< std::stringRAND_STRING (size_t min_len=15, size_t max_len=15)
 Returns a random string of random length between min_len and max_len.
 
double rate_of_change (const series< double > &series, size_t period)
 Returns the 'ROC' which is the percentage difference between the current value of the series and the value period bars ago. More...
 
sref< double > REGRESSION_LINE (sref< double > x, sref< double > y, size_t period)
 Regression 'line end point' of x against y, over given period. More...
 
sref< double > REGRESSION_LINE (sref< double > data, size_t period)
 Regression 'line end point' of data against linear time, over given period. More...
 
sref< double > REGRESSION_RSQUARE (sref< double > x, sref< double > y, size_t period)
 Regression 'r-square' of x against y, over given period. More...
 
sref< double > REGRESSION_RSQUARE (sref< double > data, size_t period)
 Regression 'r-square' of data against linear time, over given period. More...
 
sref< double > REGRESSION_SLOPE (sref< double > x, sref< double > y, size_t period)
 Regression 'slope' of x against y, over given period. More...
 
sref< double > REGRESSION_SLOPE (sref< double > data, size_t period)
 Regression 'slope' of data against linear time, over given period. More...
 
sref< double > REGRESSION_Y_INTERCEPT (sref< double > x, sref< double > y, size_t period)
 Regression 'y intercept' of x against y, over given period. More...
 
sref< double > REGRESSION_Y_INTERCEPT (sref< double > data, size_t period)
 Regression 'y-intercept' of data against linear time, over given period. More...
 
double relative_strenght (const series< double > &series_a, const series< double > &series_b, size_t period)
 Returns the 'relative strength', which is a measure of how series_a out-performed or under-performed series_b over the given period. More...
 
sref< double > ROLLING_SUM (sref< double > value)
 Returns the rolling sum of all value items since the start of the strategy. More...
 
sref< double > ROOFINGFILTER (sref< double > data, size_t lp_period, size_t hp_period)
 Returns Roofing Filter. More...
 
sref< double > RSI (sref< double > data, size_t period)
 Relative Strength Index. More...
 
sref< double > RSI_MOD (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Modified RSI. More...
 
sref< double > RSI_MOD (sref< double > data, size_t period, size_t max_period)
 Returns Static Modified RSI. More...
 
sref< double > RVI (sref< double > op, sref< double > hi, sref< double > lo, sref< double > cl, sref< size_t > period, size_t max_period)
 Returns Dynamic Relative Vigour Index (RVI). More...
 
sref< double > RVI (sref< double > op, sref< double > hi, sref< double > lo, sref< double > cl, size_t period, size_t max_period)
 Returns Static Relative Vigour Index (RVI). More...
 
sref< double > RVI_ADAPTIVE (sref< double > op, sref< double > hi, sref< double > lo, sref< double > cl, double alpha)
 Returns Adaptive Relative Vigour Index (RVI). More...
 
double safe_divide (double numerator, double denominator, double denominator_adjust=10e-9)
 This function avoids 'division by zero' errors by adding denominator_adjust to denominator when it is equal to 0.0.
 
sref< double > 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 > SAM (sref< double > data, double alpha, size_t cutoff)
 Returns Smoothed Adative Momentum (SAM). More...
 
template<typename T >
scalar_assigner< T > SET (T &var_ref)
 
template<typename T >
sref< T > 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 > 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 >
const series< T > 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...
 
sref< double > SIN (sref< double > arg)
 Computes the sine of arg (measured in radians). More...
 
series_tuple< double > SINEWAVE_RST (sref< double > data)
 Returns Ehlers' Sinewave. More...
 
sref< double > SMA (sref< double > data, size_t period)
 Returns the Symmetric Moving Average over the given period. (Alias for AVERAGE()) More...
 
sref< double > SNR_HILBERT (sref< double > high, sref< double > low, size_t period)
 Returns Static SNR (HILBERT). More...
 
sref< double > SNR_RST (sref< double > high, sref< double > low)
 Returns Signal to Noise Ratio (SNR). More...
 
double sqrt (double arg)
 Returns the square root of the given argument. Throws an exception if given arg is smaller than 0.0.
 
sref< double > SQRT (sref< double > value)
 Returns the square root of value. More...
 
double square (double arg)
 Returns a square of the given argument. Same as std::pow(arg,2).
 
sref< double > SRSI (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic SRSI. More...
 
sref< double > SRSI (sref< double > data, size_t period, size_t max_period)
 Returns Static SRSI. More...
 
double stdev (const series< double > &data, size_t period)
 Returns the population standard deviation in data over period.
 
sref< double > STDEVP (sref< double > data, size_t period)
 Returns the population standard deviation of data over given period. More...
 
series_tuple< double > STOCH (sref< double > highs, sref< double > lows, sref< double > closes, size_t period, size_t k_smooth_period=3, size_t d_smooth_period=3)
 Returns the 'smoothed' Stochastic K and D where K is a smoothed version of the Stochastic-Oscillator (STOCH_OSC()) and D is a smoothed version on K. More...
 
sref< double > STOCH_OSC (sref< double > highs, sref< double > lows, sref< double > closes, size_t period)
 Returns the Stochastic Oscillator (raw Stochastic) as developed by George C. Lane. It measures the current price in relation to the given period's price range. More...
 
sref< double > STOCHASTIC_MOD (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Modified Stochastic. More...
 
sref< double > STOCHASTIC_MOD (sref< double > data, size_t period, size_t max_period)
 Returns Static Modified Stochastic. More...
 
sref< double > SUM (sref< double > data, size_t period)
 Returns the sum of data over the given period. More...
 
sref< double > 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 > SUM (const container &c)
 Returns the sum of the current values of all series in given container c.
 
sref< double > SUM_DEV (sref< double > ser, sref< double > mean, size_t period)
 
sref< double > SUM_DEV (sref< double > data, size_t period)
 Returns the 'sum of deviations from mean' over the given period.
 
sref< double > 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 > SUM_DEV2 (sref< double > data, size_t period)
 Returns the 'sum of deviations squared from mean' over the given period.
 
sref< double > SUM_NEG (sref< double > data, size_t period)
 Returns the 'sum of negatives' over the given period. More...
 
sref< double > SUM_POS (sref< double > data, size_t period)
 Returns the 'sum of positives' over the given period. More...
 
sref< double > SUM_SQ (sref< double > data, size_t period)
 Returns the 'sum of squares' over the given period. More...
 
sref< double > SUM_XY (sref< double > x, sref< double > y, size_t period)
 Returns the 'sum of x*y' over the given period.
 
sref< double > SUPERSMOOTHERMA (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Supersmoother MA. More...
 
sref< double > SUPERSMOOTHERMA (sref< double > data, size_t period, size_t max_period)
 Returns Static Supersmoother MA. More...
 
sref< double > SUPERSMOOTHERMA_3P (sref< double > data, sref< size_t > period, size_t max_period)
 Returns Dynamic Supersmoother MA, 3 poles. More...
 
sref< double > SUPERSMOOTHERMA_3P (sref< double > data, size_t period, size_t max_period)
 Returns Static Supersmoother MA, 3 poles. More...
 
sref< double > TAN (sref< double > arg)
 Computes the tangent of arg, measured in radians. More...
 
double 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...
 
sref< date_timeTIMESTAMP (void)
 Returns the strategy's current timestamp (The timestamp of the current bar).
 
sref< bool > TO_BOOL (any_series_cref x)
 Casts x to type 'bool'.
 
sref< dateTO_DATE (string_series_cref x)
 Casts x to type 'tsa::date'.
 
sref< date_timeTO_DATE_TIME (string_series_cref x)
 Casts x to type 'tsa::date_time'.
 
sref< double > TO_DOUBLE (numeric_series_cref x)
 Casts x to type 'double'.
 
sref< double > TO_DOUBLE (bool_series_cref x)
 Casts x to type 'double'.
 
sref< double > TO_DOUBLE (string_series_cref x)
 Casts x to type 'double'.
 
sref< int > TO_INT (numeric_series_cref x)
 Casts x to type 'int'.
 
sref< int > TO_INT (bool_series_cref x)
 Casts x to type 'int'.
 
sref< int > TO_INT (string_series_cref x)
 Casts x to type 'int'.
 
sref< int64_t > TO_LONG (numeric_series_cref x)
 Casts x to type 'long'.
 
sref< int64_t > TO_LONG (bool_series_cref x)
 Casts x to type 'long'.
 
sref< int64_t > TO_LONG (string_series_cref x)
 Casts x to type 'long'.
 
std::string to_string (type_t type)
 Converts type to a string. More...
 
sref< std::stringTO_STRING (any_series_cref x)
 Casts x to type 'std::string'.
 
sref< double > TP (sref< double > highs, sref< double > lows, sref< double > closes)
 Alias for TYPICAL_PRICE(). More...
 
template<typename T >
sref< T > 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 > 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...
 
series_tuple< double > TRIX (sref< double > closes, size_t smooth_1_period=15, size_t smooth_2_period=15, size_t smooth_3_period=15, size_t signal_period=9)
 TRIX. Represents the percent-rate-of-change of a triple exponentially smoothed average. Developed by Jack Hutson. More...
 
double true_range (const series< double > &hi, const series< double > &lo, const series< double > &cl)
 Returns the 'true range' where the 'range' is the difference between the bar's high and low price, and the 'true range' is the range adjusted to include any overnight gaps. More...
 
sref< double > TRUE_RANGE (sref< double > highs, sref< double > lows, sref< double > closes)
 Returns the 'true range'. More...
 
int64_t trunc (double value)
 Returns the integer portion of value.
 
sref< double > TSI (sref< double > series, size_t smooth_1_period=25, size_t smooth_2_period=13)
 'True Strenght Indicator'. A momentum oscillator developed by William Blau. More...
 
bool turns_neg (const series< double > &series)
 Returns true when seris crosses below 0.0.
 
bool turns_pos (const series< double > &series)
 Returns true when series crosses above 0.0.
 
sref< double > TWIGGS_MF (sref< double > highs, sref< double > lows, sref< double > closes, sref< double > vol, size_t period=14)
 Twiggs Money Flow. More...
 
sref< double > TYPICAL_PRICE (sref< double > highs, sref< double > lows, sref< double > closes)
 Returns the 'typical price'. ((hi + lo + cl) / 3.0). More...
 
double typical_price (double high, double low, double close)
 Returns the 'typical price', which is the average of a bar's high,low,close prices. (high + low + close) / 3.0. More...
 
sref< double > ULCER_INDEX (sref< double > closes, size_t period=14)
 Ulcer Index. More...
 
sref< double > ULTIMATE_OSC (sref< double > highs, sref< double > lows, sref< double > closes, size_t short_period=7, size_t medium_period=14, size_t long_period=28)
 'Ultimate Oscillator'. Developed by Larry Williams.It is a momentum indicators designed to capture the momentum across multiple timeframes. More...
 
double unit_gaussian (void)
 Returns a random double with a standard deviation of 1.0 and a mean of 0.0.
 
sref< double > UNIT_GAUSSIAN (void)
 Returns a 'unit gaussian'; A random value with a standard deviation of 1.0 and a mean of 0.0.
 
double variance (const series< double > &data, size_t period)
 Returns the population variance in data over period.
 
sref< double > VARP (sref< double > data, size_t period)
 Returns the population variance of data over given period. More...
 
void verify_non_zero (size_t value)
 
void verify_non_zero (double value)
 
sref< size_t > VERIFY_PERIOD (sref< size_t > period, size_t max_period)
 Used to verify and potentially correct a value for dynamic period in DSL functions. The returned value is capped at max_period, and set to 2 if smaller than 2. More...
 
sref< double > VOLATILITY (sref< double > data, size_t period, size_t num_intervals_in_year)
 Returns the annualized volatility over the given period. More...
 
double volatility (const series< double > &series, size_t period)
 This function calculates a measure of volatility by analyzing the price changes between bars over the given period. This value is then 'annualized'. For the 'annualization' to be accurate, the function must be given the correct numberOfIntervalsInYear. For 'daily' price series, the default numberOfIntervalsInYear of 252 can be used, which corresponds to the number of trading days (in the United States) per year. More...
 
sref< double > VOLATILITY_ALT (sref< double > data, size_t period)
 Alternative Volatility calculated as: STDEVP(close, period) / AVERAGE(close, period);. More...
 
sref< double > WILLIAMS_R (sref< double > highs, sref< double > lows, sref< double > closes, size_t period=14)
 Returns the 'Williams R' indicator as developed by Larry Williams. It represents the inverse of the stochastic indicator STOCH(). More...
 
double WMA (const series< double > &data, size_t period)
 Returns the weighted average value of data over given period.
 
sref< bool > X_ABOVE (const series< double > &a, const series< double > &b)
 alias for CROSSES_ABOVE.
 
sref< bool > X_BELOW (const series< double > &a, const series< double > &b)
 alias for CROSSES_bELOW.
 

Variables

const size_t max_size_limit = std::numeric_limits<size_t>::max()
 The maximum value for size_t.
 
const size_t print_no_limit = std::numeric_limits<size_t>::max()
 flag to print without limiting the number of lines printed.
 

Detailed Description

Namespace for the 'Trading System API' library.

Enumeration Type Documentation

Data type enumeration used throughout the library. Intended to be used via type_t.

Enumerator
float32 

32 bit floating point

uint32 

32 bit unsigned integer

int32 

32 bit integer

int64 

64 bit integer

float64 

64 bit floating point

boolean 

boolean true or false

datetime 

DateTime.

date 

Date.

void_ptr 

void*

object_ptr 

Deprecated!

string 

String.

BLOB 

future use

Values that represent append flag types.

Enumerator
error_on_duplicate_timestamp 

Throw an exception when a duplicate timestamp is encountered. This is normally the default behaviour.

fix_timestamp 

Set this flag to force the system to automatically fix duplicate timstamps, by setting the new records timestamp to one microsecond larger than the last record in the table.

Transaction cost allocation enumeration.

Enumerator
per_transaction 

Commission and slippage are booked per transaction.

per_unit 

Commission and slippage are booked per unit.

Log type enumeration. Multiple log types can be combined by using operator|.

Enumerator
no_logs 

No Logs. (Disables logging - the default setting)

trades 

Trade Log.

transactions 

Transaction Log.

bars 

Bar Log.

orders 

Order Log.

drawdowns 

Drawdown Log.

all_reports 

Enables all logs.

Values that represent missing table flag types.

Enumerator
silent_on_missing 
throw_on_missing 
enum tsa::perf_metric_type
strong

Values that represent performance metric types.

Enumerator
trade_count 

The total number of trades.

loser_count 

The total number of losing trades.

winner_count 

The total number of winning trades.

percent_profitable 

The percent of trades profitable.

avg_net_trade_pl 

The average net trade profit / loss (cash amount)

avg_gross_trade_pl 

The average gross trade profit / loss (cash amount).

avg_winner 

The average net profit (cash amount) of winning trades.

avg_loser 

The average net profit (cash amount) of losing trades.

max_loser 

The size of the largest losing trade (cash amount).

max_winner 

The size of the largest winning trade (cash amount).

max_consec_winners 

The maximum number of consecutive winning trades.

max_consec_losers 

The maximum number of consecutive losing trades.

max_pos_excursion 

The largest positive (advantageous) trade profit before trade was closed out.

max_neg_excursion 

The largest negative (adverse) trade profit before trade was closed out.

avg_pos_excursion 

The average positive (advantageous) trade profit before trade was closed out.

avg_neg_excursion 

The average negative (adverse) trade profit before trade was closed out.

stddev_trade_pl 

The standard deviation of trade net-profit/loss.

total_winner_bar_count 

The number of bars of all winning trades.

total_loser_bar_count 

The number of bars of all losing trades.

avg_winner_bar_count 

The length in bars of the average winning trade.

avg_loser_bar_count 

The length in bars of the average losing trade.

avg_trade_bar_count 

The average trade length in bars.

num_bars_in_trade 

The total number of bars on which the strategy had exposure (position not 'flat').

total_num_bars_processed 

The total number of bars processed by the strategy.

percent_bars_in_trade 

The percentage of bars during which the strategy had exposure (position not 'flat').

net_profit 

The strategy 'net profit' (after slippage + commission).

gross_profit 

The strategy 'gross profit' (before slippage + commission).

winners_net 

The net profit generated by winning trades.

losers_net 

The net loss generated by losing trades.

total_commission 

The total 'commission' booked for trades.

total_slippage 

The total 'slippage' booked for trades. Trades resulting from 'limit orders' have no slippage.

total_transaction_cost 

The total 'transaction cost' for all trades.

profit_factor 

The ratio of 'total winners net' / 'total losers net'.

avg_gain_to_avg_loss_ratio 

The ratio of the 'average winning trade' / 'average losing trade'.

max_closed_out_runup 

The highest cummulative gain of sequential winning trades.

max_closed_out_rundown 

The highest cummulative loss of sequential losing trades.

max_trade_transaction_count 

The maximum number of transactions for any one trade.

max_trade_position_size 

The maximum position size of any one trade.

avg_trade_transaction_count 

The average number of transactions per trade.

avg_trade_position_size 

The average 'maximum position size' of all trades.

avg_trade_commission 

The average commission per trade.

avg_trade_slippage 

The average slippage per trade.

avg_trade_cost 

The average cost (slippage + commission) per trade.

avg_slippage_per_unit 

The average slippage 'per unit' traded.

avg_cost_per_unit 

The average 'per unit' transaction cost (slippage + commission).

percent_units_without_slippage 

The percent of units filled without 'slippage', via 'limit-orders'.

avg_net_profit_per_unit 

The average net profit/loss per unit.

avg_gross_profit_per_unit 

The average gross profit/loss per unit.

last_trade_is_open 

flag if the last trade was open before the strategy evaluation/simulation was stopped.

max_account_balance 

Not in use.

min_account_balance 

Not in use.

current_drawdown 

The value of the current drawdown.

max_drawdown 

The value of the largest drawdown.

max_drawdown_length 

The length in bars of the longest drawdown.

avg_drawdown_length 

The average drawdown length in bars.

avg_drawdown 

The value of the average drawdown in the currency in which the securities are traded.

num_drawdowns 

The total number of drawdowns.

in_drawdown 

Not in use.

num_transactions 

The total number of transactions.

num_transactions_at_market 

The total number of transactions resulting from 'market orders'.

num_transactions_on_stop 

The total number of transactions resulting from 'stop orders'.

num_transactions_at_limit 

The total number of transactions resulting from 'limit orders'.

avg_transaction_size 

The average transaction size in units.

num_units_traded 

The total number of units traded (not 'round trip').

num_units_traded_without_slippage 

The number of units traded without slippage. (Limit orders do not have slippage).

num_units_traded_at_market 

The number of units traded using 'market orders'.

num_units_traded_on_stop 

The number of units traded using 'stop orders'.

num_units_traded_at_limit 

The number of units traded using 'limit orders'.

start_capital 
drawdown_multiplier 
sharpe_ratio 
sortino_ratio 
enum tsa::plot_type
strong

Values that represent plot types.

Enumerator
line 
area 
bar 

flag for opening output streams

Enumerator
replace 

Replace existing target if it already exists.

no_replace 

Raise error if target already exists.

Replace / no-replace flag used by various objects.

Enumerator
no_replace_existing 
replace_existing 

Return value for seek operations on series tables.

Enumerator
ok 

The cursor is at the seek timestamp or on next lower timestamp if the seek timestamp was not found.

request_below_table_range 

The seek timestamp is earlier than the first record in the table.

request_above_table_range 

The seek timestamp is higher than the last record in the table.

Values that represent strategy state ts.

Enumerator
undefined 
created 
initializing 
preparing_managed_code 
running 
finalized 

Trade aggregation types used by reporting functionality.

Enumerator
long_only 

Long trades only.

short_only 

Short trades only.

all_trades 

All trades.

Function Documentation

template<typename T >
sref<T> tsa::CONST_SERIES ( const std::vector< T > &  values)

Returns a series that is constant by copying the data vector values. The series never changes and cannot be changed.

Template Parameters
TTemplate argument.
Parameters
valuesThe series values.
Returns
A sref<T>
log_type_t tsa::operator| ( log_type_t  lhs,
log_type_t  rhs 
)

Allows multiple LogType values to be combined.

Parameters
lhsLog-type.
rhsLog-type.
Returns
Combined Log-Type flag.
std::string tsa::to_string ( type_t  type)

Converts type to a string.

Parameters
typeThe type.
Returns
type as a std::string.
void tsa::verify_non_zero ( size_t  value)

Throws an exception if value is zero. To check DSL function arguments.

Parameters
valueThe value.
void tsa::verify_non_zero ( double  value)

Throws an exception if value is zero. To check DSL function arguments.

Parameters
valueThe value.
sref< size_t > tsa::VERIFY_PERIOD ( sref< size_t >  period,
size_t  max_period 
)

Used to verify and potentially correct a value for dynamic period in DSL functions. The returned value is capped at max_period, and set to 2 if smaller than 2.

Parameters
periodThe period.
max_periodThe maximum period.
Returns
A sref<size_t>