Hi, using the code below, I'm able to choose securities based on their fundamental data such as PERatios etc., but can only do so by hardcoding a specific value, like a PERatio of above 10. How do I go about making this value dynamic? Such as only wanting to select symbols whose PERatio is above a given benchmark, like say, SPY. 

sortedByDollarVolume = sorted([x for x in fine if x.CompanyReference.CountryId == "USA" \ and x.CompanyReference.PrimaryExchangeID == "NAS" \ and x.CompanyReference.IndustryTemplateCode == "N" \ and (algorithm.Time - x.SecurityReference.IPODate).days > 180 \ and x.ValuationRatios.PERatio > 10], \ key = lambda x: self.dollarVolumeBySymbol[x.Symbol], reverse=True)

So instead of 10, that value would be whatever the PERatio of SPY would be when doing the fine selection.

 

Thank you

Author