Transformer Pipeline Module API Reference  6.2.11.309924
Calculations

Functions

 calc.high (var incoming, var normal, var trade, var tradetime)
 Calculate the high value. More...
 
 calc.low (var incoming, var normal, var trade, var tradetime)
 Calculate the low value. More...
 
 calc.previous (var update, var normal, var fieldname, var formatname, var value, var tim)
 Add the previous price into the normalised packet. More...
 
 calc.change (var update, var normal, var price)
 Add the change since the last value. More...
 
 calc.percentchange (var update, var normal, var price)
 Add the percentage change since the last value. More...
 
 calc.accumulate (var symbol, var name, var value)
 Implementation of an accumulator. More...
 
 calc.exec (var symbolname, var value, var exprname)
 Execute expressions based on a Data Dictionary algorithm. More...
 

Detailed Description

This package provides facilities for simple data processing. All functions use the DataDictionary facility to lookup the field names.

Function Documentation

calc.accumulate ( var  symbol,
var  name,
var  value 
)

Implementation of an accumulator.

Parameters
symbol- Symbol this accumulator corresponds to
name- Name of the accumulator
value- Value to add to the accumulator
Returns
New value of the accumulator
calc.change ( var  update,
var  normal,
var  price 
)

Add the change since the last value.

Parameters
update- The incoming update
normal- The outgoing normalised data
price- The last trade price
Returns
nothing

This function uses the following database keys for the symbol:

PreviousPrice

This function uses the following database keys for the data dictionary:

PreviousPriceField
PriceFormat
PriceChangeField

calc.exec ( var  symbolname,
var  value,
var  exprname 
)

Execute expressions based on a Data Dictionary algorithm.

Parameters
symbolname- Symbolname that this value is associated with
value- The value to be processed
exprname- Name of the expression in the data dictionary
Returns
The derived value
Note
The expression held in exprname must use "value" as it's variable name

For example, if there's the config database option "PriceMultiplier", defined as follows:

add-pipeline
....
add-info "PriceMultipler" "return value * 10"
end-pipeline

Then the following code snippet will perform that calculation defined in the option.

require("calc")
local symbolname = "/TEST"
local old_value = 1.7
local new_value = calc.exec(symbolname, old_value, "PriceMultiplier")
Note
Although flexible, calling calculations in this manner can be slow.
calc.high ( var  incoming,
var  normal,
var  trade,
var  tradetime 
)

Calculate the high value.

Parameters
incoming- Update packet that we have received
normal- Normalised packet that we can add fields to
trade- Trade price
tradetime- The tradetime
Returns
The new high value if one
Return values
nil- No new high value
Note
This function works on parameters that have already been normalised

This function uses the following database keys on the symbol:

HighPriceTime
HighPrice
IncomingTimeFormat

This function uses the following data dictionary keys:

HighPriceField
HighPriceTimeField

calc.low ( var  incoming,
var  normal,
var  trade,
var  tradetime 
)

Calculate the low value.

Parameters
incoming- Update packet that we have received
normal- Normalised packet that we can add fields to
trade- Trade price
tradetime- The tradetime
Returns
The new high value if one
Return values
nil- No new high value
Note
This function works on parameters that have already been normalised

This function uses the following database keys on the symbol:

LowPriceTime
LowPrice

This function uses the following data dictionary keys:

LowPriceField
LowPriceTimeField

calc.percentchange ( var  update,
var  normal,
var  price 
)

Add the percentage change since the last value.

Parameters
update- The incoming update
normal- The outgoing normalised data
price- The last trade price
Returns
nothing

This function uses the following database keys for the symbol:

PreviousPrice

This function uses the following database keys for the data dictionary:

PreviousPriceField
PriceFormat
PricePercentChangeField

calc.previous ( var  update,
var  normal,
var  fieldname,
var  formatname,
var  value,
var  tim 
)

Add the previous price into the normalised packet.

Parameters
update- The incoming update
normal- The outgoing normalised data
fieldname- Fieldname of current_value
formatname- Name of the format to apply to the previous value
value- Current value
tim- The associated time
Returns
nothing

This function uses the following database keys for the symbol:

Previous[fieldname]
Previous[fieldname]Time

This function uses the following database keys for the data dictionary:

Previous[fieldname]Field
Previous[fieldname]TimeField


Generated on Sat Aug 26 2017 12:36:33 for Transformer Pipeline Module API Reference