Project parameters are parameters that are defined in your project's configuration file. These parameters are a replacement for constants in your algorithm and can be optimized using one of LEAN's optimization strategies either locally or in the cloud.

Configure Project Parameters

Follow these steps to make your algorithm use project parameters instead of constant values:

  1. Open your project in your preferred editor.
  2. Open the project's config.json file.
  3. Add the required parameters in the parameters property. All keys and values of this object must be strings. Example:
        "parameters": {
            "ema-fast": "10",
            "ema-medium": "30",
            "ema-slow": "50"
  4. Open your algorithm in the editor.
  5. Call QCAlgorithm.GetParameter(name) in your algorithm to retrieve the value of a parameter and use that instead of constant values.
    namespace QuantConnect.Algorithm.CSharp
        public class ParameterizedAlgorithm : QCAlgorithm
            private ExponentialMovingAverage _fast;
            private ExponentialMovingAverage _medium;
            private ExponentialMovingAverage _slow;
            public override void Initialize()
                SetStartDate(2020, 1, 1);
                var fastPeriod = GetParameter("ema-fast", 10);
                var mediumPeriod = GetParameter("ema-medium", 30);
                var slowPeriod = GetParameter("ema-slow", 50);
                _fast = EMA("SPY", fastPeriod);
                _medium = EMA("SPY", mediumPeriod);
                _slow = EMA("SPY", slowPeriod);
    class ParameterizedAlgorithm(QCAlgorithm):
        def initialize(self) -> None:
            self.set_start_date(2020, 1, 1)
            fast_period = self.get_parameter("ema-fast", 10)
            medium_period = self.get_parameter("ema-medium", 30)
            slow_period = self.get_parameter("ema-slow", 50)
            self._fast = self.ema("SPY", fast_period)
            self._medium = self.ema("SPY", medium_period)
            self._slow = self.ema("SPY", slow_period)

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: