Support parameters change in real-time for live algorithms
Expected Behavior
User is able to change parameters for an algorithm running on live mode and that may be handled by the algorithm to change it's state. For example, this can be EMA period: user changes it and the corresponding indicator is reset and warmed up from historical data, without the need to re-deploy algorithm. Also, maybe automatically log parameter values on deployment and when they change, to keep track of their actual values used in the algorithm.
Actual Behavior
Currently user has to re-deploy algorithm in order to update parameters.
Potential Solution
Not sure about implementation details, but for the user side QCAlgorithm class should probably have some callback, like def on_parameter_change(self, new_value, old_value), where it can pick up new parameter value and update algorithm state accordingly.
Checklist
- [+] I have completely filled out this template
- [+] I have confirmed that this issue exists on the current
masterbranch - [+] I have confirmed that this is not a duplicate issue by searching issues
Hey @yul! Believe you can achieve similar functionality with the new command system, please take a look at https://www.quantconnect.com/docs/v2/writing-algorithms/live-trading/commands
Hey @yul! Believe you can achieve similar functionality with the new command system, please take a look at https://www.quantconnect.com/docs/v2/writing-algorithms/live-trading/commands
I understand it can only be triggered via API, while I can do that, my clients who are not developers, but still want to use algorithms I develop would not be able to do that. And link generation would require sending notification, which looks like an awkward way to control an algorithm. I think it would be easier if user could just change parameter of the live instance.
Hi @yul, You can write a 30-line Python script to trigger command events that would be as easy as using parameters in the IDE, see Send Commands by API.
print(create_command(<project_id>, {'ema_fast': 10, 'sma_slow': 50}))
print(create_command(<project_id>, {'ema_fast': 5, 'sma_slow': 100}))