setParameterDistribution: Function used to create an object that contains the...

Description Usage Arguments Details Value Author(s) Examples

View source: R/parameters.R

Description

Each call to the function will set/update the distribution of ONE parameter in the 'parameter distribution object' that is associated with a specific strategy.

Usage

1
2
setParameterDistribution(paramDist = NULL, strategy, component.type,
  component.label, distribution = NULL, weight, label, psindex = NULL)

Arguments

paramDist

The object in which the parameter list is stored; if this parameter is missing, or object does not exist, the function will return a new object.

strategy

The strategy object

component.type

A character string that specifies the type of the strategy component that contains the parameter, it takes the value in one of 'indicator', 'signal', 'enter', 'exit', 'order', 'chain'.

component.label

The label that uniquely identifies the strategy component that contains the parameter

distribution

Distribution of the parameter, can be any function that returns a vector of value. See detail. (A numerical example: 1:10 or sample(1:20,6)

weight

The weight of each value in the distribution, if missing, the default value of all equal weights will be taken.

label

A string label to apply to the parameter distribution

psindex

A number specify the index within the parameter distribution object, it is used to make change/ repalce a parameter distribution in the object.

Details

Parameter distribution object for one strategy usually won't work for another strategy, because different strategies has different parameter structure. Type of the parameter and the sequence in that type is needed to specify the exact parameter in THAT STRATEGY.

The parameter 'distribution' is a list contains vector of values NAMED WITH THE NAMES OF THE PARAMETERS, the values can be any type (integer, characters, etc) but must match with the legal value of that parameter. For example: distribution=list(nFast=(10:30)) or distribution=list(relationship=c('gt','gte'))

Value

The returned object is a structure contains the distribution of parameters, if the input argument 'paramDist' is provided, the function update the input paramDist object and return the updated one. When specify the distribution of several parameters, usually the first returned object is passed to the next several call of the function as input argument 'paramDist'. See example.

Author(s)

Yu Chen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
#(For complete demo see parameterTestMACD.R)
tPD2<-setParameterDistribution(tPD2, strat, component.type='indicator', component.label='FastSMA', 
     distribution=list(nFast=(10:30)), label='nFast')
tPD2<-setParameterDistribution(tPD2, strat, component.type='indicator', component.label='SlowSMA', 
     distribution=list(nSlow=(20:40)), label='nSlow')
tPD2<-setParameterDistribution(tPD2, strat, component.type='signal', component.label='go.long', 
     distribution=list(relationship=c('gt', 'gte')), label='sig1.gtgte')

## End(Not run)

cloudcell/quantstrat documentation built on May 13, 2019, 8:03 p.m.