Why Trading Strategy Parameters May Be Defined as Class Variables
Summary
A brief forum exchange explains why a trading strategy framework may define parameters as class variables. Doing so lets the strategy engine and user interface inspect parameter metadata before creating a strategy instance, which supports passing values during initialization. If those values were instance variables, they would not be available until after instantiation.
The response cautions that class-level strategy parameters should be immutable basic values such as booleans, integers, floats, or strings. Mutable objects such as lists and dictionaries can be shared between instances and risk unintended state changes. The discussion addresses parameter declaration and Python object behavior, rather than trading logic; it offers no framework-specific details beyond the stated rationale or examples of how parameters are consumed.
Key ideas
- Class-level parameters allow a strategy engine or interface to inspect them before creating an instance.
- This makes it possible to provide parameter values during strategy initialization.
- Mutable class-level objects can be shared across instances and create unexpected state changes.
- The response recommends using immutable primitive values for class-level parameters.
- The discussion does not describe a trading strategy or performance results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.