from QuantConnect import *
from QuantConnect.Indicators import *
from QuantConnect.Algorithm import *
from QuantConnect.Algorithm.Framework import *
from QuantConnect.Algorithm.Framework.Alphas import *
from Alphas.RsiAlphaModel import RsiAlphaModel
from Portfolio.MeanVarianceOptimizationPortfolioConstructionModel import MeanVarianceOptimizationPortfolioConstructionModel
from Execution.ImmediateExecutionModel import ImmediateExecutionModel
from Risk.MaximumSectorExposureRiskManagementModel import MaximumSectorExposureRiskManagementModel
from clr import AddReference
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Algorithm.Framework")
AddReference("QuantConnect.Indicators")
import datetime
from alpha import *
from collections import deque
class BasicTemplateFrameworkAlgorithm(QCAlgorithmFramework):
def Initialize(self):
# Set requested data resolution
self.UniverseSettings.Resolution = Resolution.Daily
self.SetStartDate(2014, 7, 18) #Set Start Date
self.SetEndDate(2019, 1, 18) #Set End Date
self.SetCash(100000) #Set Strategy Cash
#self.SetUniverseSelection(FineFundamentalUniverseSelectionModel(self.CoarseSelectionFunction, self.FineSelectionFunction, None, None)) #QC500UniverseSelectionModel
self.SetUniverseSelection(QC500UniverseSelectionModel())
#self.SetAlpha(MyAplhaTest(14, Resolution.Daily))
self.SetAlpha(RsiAlphaModel(15, Resolution.Daily))
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) #MeanVarianceOptimizationPortfolioConstructionModel, EqualWeightingPortfolioConstructionModel
self.SetExecution(ImmediateExecutionModel())
self.SetRiskManagement(MaximumSectorExposureRiskManagementModel())
# sort the data by daily dollar volume and take the top 'NumberOfSymbols'
def OnOrderEvent(self, orderEvent):
if orderEvent.Status == OrderStatus.Filled:
#self.Debug("Purchased Stock: {0}".format(orderEvent.Symbol))
pass
Hi,
trying to run a framework algorithm. The default setup works till certain point (selection, trading, etc), then I get an error (Sequence contains no elements).
Jack Simonson
Hi Artur,
This is a known issue and our engineering team is working on a solution. We've opened an issue in GitHub that you can view here and track the progress. Hopefully, we'll have a solution soon.
Artur Sokolovsky
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!