Back

Framework Algorithm - Template created from the wizard generates a runtime error

Not sure if I am misunderstanding the framework algorithm wizard. The one where we can select what looks like some pre-built modules:

https://i.imgur.com/eVMnuWz.png

I created a simple framework and then ran it immediately for testing and it returned this error.


Runtime Error: Trying to retrieve an element from a collection using a key that does not exist in that collection throws a KeyError exception. To prevent the exception, ensure that the GGP R735QTJ8XC9X key exist in the collection and/or that collection is not empty. KeyError : 'the label [GGP R735QTJ8XC9X] is not in the [index]' (Open Stacktrace)

Here is the code it generated:

from Selection.QC500UniverseSelectionModel import QC500UniverseSelectionModel

from Alphas.RsiAlphaModel import RsiAlphaModel

from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel

from Execution.VolumeWeightedAveragePriceExecutionModel import VolumeWeightedAveragePriceExecutionModel

from Risk.MaximumSectorExposureRiskManagementModel import MaximumSectorExposureRiskManagementModel


class BasicTemplateFrameworkAlgorithm(QCAlgorithmFramework):

def Initialize(self):

# Set requested data resolution
self.UniverseSettings.Resolution = Resolution.Minute

self.SetStartDate(2018, 3, 16) #Set Start Date
self.SetEndDate(2018, 9, 16) #Set End Date
self.SetCash(100000) #Set Strategy Cash

self.SetUniverseSelection(QC500UniverseSelectionModel())

self.SetAlpha(RsiAlphaModel(60, Resolution.Minute))

self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())

self.SetExecution(VolumeWeightedAveragePriceExecutionModel())

self.SetRiskManagement(MaximumSectorExposureRiskManagementModel())



def OnOrderEvent(self, orderEvent):
if orderEvent.Status == OrderStatus.Filled:
# self.Debug("Purchased Stock: {0}".format(orderEvent.Symbol))
pass

I assume it should run correct? Or am I missing something? 

As always, thanks!

Update Backtest







You can remove the library import it will work.

1

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.


Thanks for reporting the issue @ThatBlokeDave. It looks like a bug in the platform which we'll review and search for a fix shortly. For now removing the import statements for the RSI Alpha as Jing suggested reverts it to use the backend C# types which work as Jing demonstrated.

We write duplicate C# and Python versions of every alpha for educational and test purposes but in 99% of cases they behave identically. We'll investigate and see why they might not be the same here. 

1

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.


Ok - Thanks to both of you for the info and support. Appreciated. 

0

Update Backtest





0

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.


Loading...

This discussion is closed