Hello, I want to get a list of securities sorted by ROIC, for this I used the coarse-fine universe method in the lab algorithm (with PERatio as example) to test it but when I replace the PERatio by ROIC I have this bug;
Cannot convert object of type Python.Runtime.CLRObject to IComparable
at FineSelectionFunction
def FineSelectionFunction(self, fine):
# sort descending by P/E ratio
sortedByPeRatio = sorted(fine, key=lambda x: x.OperationRatios.ROIC, reverse=True)
# take the top entries from our sorted collection
return [ x.Symbol for x in sortedByPeRatio[:self.__numberOfSymbolsFine] ]
# __numberOfSymbolsFine is defined I use the same params as the example with the PERRatio
Thanks for you help.
Robert Koch
Try "x.OperationRatios.ROIC.Value" or "x.OperationRatios.ROIC.OneYear" or "x.OperationRatios.ROIC.ThreeMonths"
Jérémy VITAL
I style have the same problem.even with your 3 proposals.
Gahl Goziker
Hi Jérémy,
Changing OperationRatios.ROIC
to any of the following:
takes away the runtime error
Cannot convert object of type Python.Runtime.CLRObject to IComparable.
See the attached backtest for reference.
Best,
Gahl Goziker
https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_56f691260a653d8bc7331ffce0d7e344.html
Hector Barrio
Multiperiod fundamentals are difficult to read and not all symbols contain all periods all the time, there may be data gaps or imbalances. For me the best approach has been to check in research what periods are available for needed fundamentals for a sample of the universe and check the sanity of the values:
self = QuantBook() symbol = self.AddEquity("CAT").Symbol start = datetime(2015,1,1) end = datetime(2020,1,1) history = self.GetFundamental(self.Securities.Keys, "OperationRatios.ROIC", start, end)
This will return a dataframe with all the available period selectors, in this case 3M, 6M and 1Y, accesible with .ThreeMonts, .SixMonths and .OneYear.
I find it easier than checking the raw descriptions looking for the periods.
https://raw.githubusercontent.com/QuantConnect/Lean/master/Common/Data/Fundamental/Generated/MultiPeriodValueTypes.cs
Jérémy VITAL
Thanks for your both answer!
Jérémy VITAL
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!