Hi there:)

I need some help adding fundamentals and technical indicators in the same algorithm. Ive been trying for a couple days now and have made no headway. I know i need a universe, but i was wondering if there was any way i could get the PE Ratio for a certain predetermined list of stocks, and then buy them if the PE RATIO is good and the MACD crosses.

 

Sorry, glitchy computer wont let me add a backtest … here's the code:

 

 

Thanks for any help ! :)

 

#region imports
from AlgorithmImports import *
#endregion
class VerticalQuantumInterceptor(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2019, 7, 12)# Set Start Date
        self.SetEndDate(2019, 7, 16)
        self.SetCash(100000)  # Set Strategy Cash
        
        resolution = Resolution.Daily
        
        self.UniverseSettings.Resolution = resolution
        
        self.symbols = [self.AddEquity(x, resolution).Symbol
            for x in ["X", "F", "JPM"]]
        
        self.AddUniverse(self.CoarseSelection, self.FineSelection)
    
        self.macd = self.MACD(self.symbols, 12, 26, 9, Resolution.Daily)
    
    def CoarseSelection(self, coarse):
        return self.symbols
    
    def FineSelection(self, fine):
        return [x.Symbol for x in fine]
        fine = [x for x in fine if x.ValuationRatios.PBRatio > 0]
        sortedPBRatio = sorted(fine, key=lambda x: x.ValuationRatios.PBRatio)
        
        return self.symbols
    
    
    def OnData(self, data):
        if self.Portfolio[self.symbols].Quantity == 0:
            if x.ValuationRatios.PBRatio < 1:
                if self.macd.Current.Value > self.macd.Signal.Current.Value:
                   self.SetHoldings(self.symbols, .1)