Issue calling UniverseSelectionModel from different file (constructor issue)

Back

Hi,

As I am working with the backtesting engine I am trying to set up the FineFundamentalUniverse in a seperate .py file. I am not successful in calling it from the main.py file and I get an Error Message "During the algorithm initialization, the following exception has occurred: TypeError : no constructor matches given arguments"

It would be great if I can understand how to set up the FineFundamental Universe in a separate file. I can dset up Portfolio construction classes in separate file but for some reason not with the FineFundamental model.

Thanks,

G

Main.py

from universe_selection_model import MyUniverseModel

class TestAlgo(QCAlgorithm):

def Initialize(self):

self.SetStartDate(2018, 5, 28)
self.SetEndDate(2018, 6, 9)
self.SetWarmUp(10)
self.SetCash(10000)

# Universe selection settings
self.UniverseSettings.Resolution = Resolution.Daily
self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Adjusted
self.UniverseSettings.ExtendedMarketHours = False

self.SetUniverseSelection(MyUniverseModel())

# Other initialization code

universe_selection_model.py

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm.Framework")

from QuantConnect.Data.UniverseSelection import *
from QuantConnect.Algorithm.Framework import *
from QuantConnect.Algorithm.Framework.Selection import FineFundamentalUniverseSelectionModel

class MyUniverseModel(FineFundamentalUniverseSelectionModel):

def __init__(self):
super().__init__(coarseSelector=self.SelectCoarse, fineSelector=self.SelectFine)

def SelectCoarse(self, coarse):
# code for the coarse filter

def SelectFine(self, fine):
# code for the fine filter
x

 

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.


Hi Goofball,

The FineFundamentalUniverseSelectionModel class is not designed to be extended.
Instead, MyUniverseModel can extend FundamentalUniverseSelectionMode.

Please see the attached backtest for reference.

Best,
Gahl Goziker

1


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