Back

Need help on the ROIC

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.

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.


Try "x.OperationRatios.ROIC.Value" or "x.OperationRatios.ROIC.OneYear" or "x.OperationRatios.ROIC.ThreeMonths"

0

I style have  the same problem.even with your 3 proposals.

0

Hi Jérémy,

Changing OperationRatios.ROIC

 to any of the following:

  • OperationRatios.ROIC.OneYear
  • OperationRatios.ROIC.SixMonths
  • OperationRatios.ROIC.ThreeMonths
  • OperationRatios.ROIC.Value

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

0

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

0

Thanks for your both answer!

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