Fix GetLastKnownPrices resolution usage (#6165)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled

- GetLastKnownPrices will no longer guess which resolution to use but
  rely on other methods implementation/
- Updating basic template future algorithms to warmup contracts and
  assert it
- Minor improvements for FunSecurityInitializer and FuncSecuritySeeder
This commit is contained in:
Martin-Molinero
2022-01-21 18:00:53 -03:00
committed by GitHub
parent 30d7fb042b
commit b1a1277eca
3 changed files with 45 additions and 10 deletions
@@ -43,6 +43,8 @@ class BasicTemplateFuturesAlgorithm(QCAlgorithm):
benchmark = self.AddEquity("SPY")
self.SetBenchmark(benchmark.Symbol)
seeder = FuncSecuritySeeder(self.GetLastKnownPrices)
self.SetSecurityInitializer(lambda security: seeder.SeedSecurity(security))
def OnData(self,slice):
if not self.Portfolio.Invested:
@@ -70,3 +72,8 @@ class BasicTemplateFuturesAlgorithm(QCAlgorithm):
maintenanceOvernight = buyingPowerModel.MaintenanceOvernightMarginRequirement
initialIntraday = buyingPowerModel.InitialIntradayMarginRequirement
maintenanceIntraday = buyingPowerModel.MaintenanceIntradayMarginRequirement
def OnSecuritiesChanged(self, changes):
for addedSecurity in changes.AddedSecurities:
if addedSecurity.Symbol.SecurityType == SecurityType.Future and not addedSecurity.Symbol.IsCanonical() and not addedSecurity.HasData:
raise Exception(f"Future contracts did not work up as expected: {addedSecurity.Symbol}")