Caplin Trader 5.1.0

Class: module:ct-chart/Study

(abstract) module:ct-chart/Study(alias, derivationParams, listener, configOverridesopt)

Provides initial initialisation of the Study. Concrete studies must extend this abstract class and call this constructor (Study.call(this, alias, derivationParams, listener, configOverrides);).

Abstract class that all studies must extend. It provides getters for derivation parameters and study configuration options. It also provides serialisation support and batching functionality that concrete studies should use to send the study series data to its listeners.

The Study class accepts, as its last argument, a map of overrides for configuration options for the descendant study. These options can be overridden in two places. The Study defines the appropriate defaults. The first place where the configuration options can be overridden is in the descendant study's constructor when it calls the parent constructor. The second place is when you create a new instance of a study (either using the module:ct-chart/study/Factory or module:ct-chart/Series#addStudy). A descendant must pass the user's override up to the Study.

Constructor

(abstract) new module:ct-chart/Study(alias, derivationParams, listener, configOverridesopt)

Parameters:
Name Type Attributes Description
alias String

The Study alias.

derivationParams Object

Options that the study will use to determine how to calculate the study series data. This will usually be at least period.

listener Object

A listener object that implements the module:ct-chart/study/StudyListener interface.

configOverrides Object <optional>

The configuration options for the study.

Properties
Name Type Attributes Default Description
batchSize int <optional>
100

How many study series points should be sent to the listener at once.

representationTypes Array <optional>
['spline']

What type of, and how many, series will this study output.

representationNames Array <optional>
['']

The logical name for each outputted study series. This will only be used by studies that output more than one series.

i18nPrefix String <optional>
'ct.analysis.study.'

The i18n key prefix used by the 'getDisplayName'.

isolated boolean <optional>
false

Should the chart component represent this study on a different panel.

serialize boolean <optional>
true

Should this study be serialised.

color String <optional>
null

This configuration option is deprecated, use 'colors' instead. The colour for the study series that should be used by the chart component.

colors Array <optional>
[null]

The list of colours for the study series that should be used by the chart component.

Methods

enqueue(data, idx, arr)

Enqueues processed study data, which is then batch forwarded to the listener.

Performance optimisation for older browsers.

This method is only to be called by the Study by methods #evaluate or #onStudyData.

Parameters:
Name Type Description
data Array

The latest value array from the Study.

idx Number

The current values index within the studies current data set.

arr Array

The data that the Study is currently evaluating.

evaluate(data)

This method will get called by the module:ct-chart/Series every time it receives new chart data. This method should perform its calculations and then pass the calculated data to the listeners onStudyData method. See module:ct-chart/SeriesListener.

Parameters:
Name Type Description
data Array

Chart series data in the Caplin Format.

getAlias() → {String}

Gets the alias name of the study.

The alias name is used to identify the study when deserialising the persisted form.

Returns:

The alias for the Study.

Type
String

getColor() → {String|null}

Deprecated:
Returns:

The colour of the study.

Type
String | null

getColors() → {Array}

Returns a list of colours for each series this study outputs.

Returns:

List of colours for each study series.

Type
Array

getConfigValue(key)

Gets a specific Study configuration option.

Parameters:
Name Type Description
key String

The configuration option key.

Returns:

The configuration option value.

getDerivationParam(key)

Gets a specific Study derivation option.

Parameters:
Name Type Description
key String

The option key.

Returns:

The derivation option value.

getDerivationParams() → {Object}

Gets the derivation options of the study.

Returns:

The options.

Type
Object

getDisplayName(seriesIdxopt) → {String}

Gets the display name of the series, derived from the alias and configuration parameters.

Parameters:
Name Type Attributes Description
seriesIdx Number <optional>

The index of the series.

Returns:

The internationalised display name.

Type
String

getId() → {String}

Get the ID of this study.

The ID is constructed from the study type and derivation options.

Returns:

The ID of this study.

Type
String

getRepresentationNames() → {Array}

Gets the representation names for individual series generated by the study. This exists for studies that return more than one series (such as the Bollinger band).

Returns:

The list of series names within a study.

Type
Array

getRepresentationTypes() → {Array}

Gets the representation types of the data that the study returns (line, spline, ...).

This is used by the module:ct-chart/Chart to determine how to display the study data.

Returns:

Style of the study data.

Type
Array

serialize() → {String}

Returns the serialised state of the study. The serialisation logic is handled by the module:ct-chart/Series so you don't have to call this method manually.

Returns:

The XML representation of the object.

Type
String