Skip to main content

Strategy Parameters

info

System default (reserved) parameters

Self-defined parameters

User could add their custom parameters and access them through self['OPTION_NAME'] in the strategy. You can easily change these parameter values for every run of live trade, backtest or simulation.

For example, if you have the following configuration for a strategy

caution

All arguments are stored and parsed as string str type in your strategy code. So you be sure to parse to appropriate type yourself!

Type

  • Boolean

    A STRING that indicates either true or false

  • Number

    A STRING that represents a float value.

  • String

    A STRING that holds a ASCII string

  • Select

    A STRING that holds a list of ASCII string. Separated by the symbol vertical bar |.

Example

Suppose you use the following configuration

VariableDescriptionTypeDefault Value
MyArgAtrue/falseBooleantrue
MyArgBa float numNumber10.9
MyArgCa ASCII StrStringHello World!
MyArgDa ASCII listSelectOptionA|OptionB|OptionC
note

Only ASCII string is supported currently

Then you're allowed to tweak these variables to be used in your strategy before trading. MyArgD will appear as a list consisting of OptionA, OptionB and OptionC.

image

note

You can access these arguments by self['argName']

def trade(self, information):
CA.log(self['MyArgA']) # true
CA.log(self['MyArgB']) # 10.9
CA.log(self['MyArgC']) # Hello World!
CA.log(self['MyArgD']) # OptionC

CA.log(str(self['MyArgA'].__class__)) # <class 'str'>
CA.log(str(self['MyArgB'].__class__)) # <class 'str'>
CA.log(str(self['MyArgC'].__class__)) # <class 'str'>
CA.log(str(self['MyArgD'].__class__)) # <class 'str'>
All of the types are string in python

So if you want to check MyArgA is true or not, you have to use it like if self['MyArgA'] == 'true' instead of if self['MyArgA].