Skip to main content

Strategy Parameters

Reserved parameters​

Reserved parameters cannot be used for other purposes.

VariableDescriptionTypeDefault Value
exchange_feeset exchange fee for backtests and simulations. (default: 0.1%)Number0.001
spreadset spread for backtests and simulations.Number0
leverageset leverage for live trades.Number1
IS_DEBUGset True to enable IS_DEBUG mode for backtests.Booleanfalse

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, candles):
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'>

if self['MyArgB']:
self.MyArgB = float(self['MyArgB'])
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].