pep8 conversion of python algos #1-25 (#7926)

* pep8 conversion of python algos

* address peer-review

* PEP8 updates/fixes

* More fixes

---------

Co-authored-by: Jhonathan Abreu <jdabreu25@gmail.com>
This commit is contained in:
Louis Szeto
2024-04-18 05:02:32 +08:00
committed by GitHub
parent 784e497691
commit ed7f3ebbbf
35 changed files with 735 additions and 727 deletions
@@ -17,28 +17,28 @@ from AlgorithmImports import *
### Algorithm asserting the correct values for the deployment target and algorithm mode.
### </summary>
class AlgorithmModeAndDeploymentTargetAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2013,10, 7)
self.SetEndDate(2013,10,11)
self.SetCash(100000)
def initialize(self):
self.set_start_date(2013,10, 7)
self.set_end_date(2013,10,11)
self.set_cash(100000)
#translate commented code from c# to python
self.Debug(f"Algorithm Mode: {self.AlgorithmMode}. Is Live Mode: {self.LiveMode}. Deployment Target: {self.DeploymentTarget}.")
self.debug(f"Algorithm Mode: {self.algorithm_mode}. Is Live Mode: {self.live_mode}. Deployment Target: {self.deployment_target}.")
if self.AlgorithmMode != AlgorithmMode.Backtesting:
raise Exception(f"Algorithm mode is not backtesting. Actual: {self.AlgorithmMode}")
if self.algorithm_mode != AlgorithmMode.BACKTESTING:
raise Exception(f"Algorithm mode is not backtesting. Actual: {self.algorithm_mode}")
if self.LiveMode:
if self.live_mode:
raise Exception("Algorithm should not be live")
if self.DeploymentTarget != DeploymentTarget.LocalPlatform:
raise Exception(f"Algorithm deployment target is not local. Actual{self.DeploymentTarget}")
if self.deployment_target != DeploymentTarget.LOCAL_PLATFORM:
raise Exception(f"Algorithm deployment target is not local. Actual{self.deployment_target}")
# For a live deployment these checks should pass:
# if self.AlgorithmMode != AlgorithmMode.Live: raise Exception("Algorithm mode is not live")
# if not self.LiveMode: raise Exception("Algorithm should be live")
# if self.algorithm_mode != AlgorithmMode.LIVE: raise Exception("Algorithm mode is not live")
# if not self.live_mode: raise Exception("Algorithm should be live")
# For a cloud deployment these checks should pass:
# if self.DeploymentTarget != DeploymentTarget.CloudPlatform: raise Exception("Algorithm deployment target is not cloud")
# if self.deployment_target != DeploymentTarget.CLOUD_PLATFORM: raise Exception("Algorithm deployment target is not cloud")
self.Quit()
self.quit()