def testDependencyCalculation(self): h1 = {'aapl': 'close', 'ibm': 'close'} h2 = {'goog': 'open'} h3 = {'aapl': 'pe', 'ibm': 'pe', 'goog': 'pe'} h4 = {'qqq': Factors.PE} expected = {'close': ['aapl', 'ibm'], 'pe': ['goog', 'aapl', 'ibm', 'qqq'], 'open': ['goog']} calculated = dict(dependencyCalculator(h1, h2, h3, h4)) for name in expected: self.assertEqual(set(expected[name]), set(calculated[name]))
def testDependencyCalculation(self): h1 = SecurityMovingMax(5, 'close', ['AAPL', 'IBM']) h2 = SecurityMovingAverage(6, 'open', ['GOOG']) h3 = SecurityMovingAverage(4, h1) h4 = SecurityMovingAverage(3, 'pe', ['AAPL', 'IBM', 'GOOG']) h5 = SecurityMovingAverage(3, Factors.PE, ['QQQ']) expected = {'close': ['aapl', 'ibm'], 'pe': ['goog', 'aapl', 'ibm', 'qqq'], 'open': ['goog']} calculated = dict(dependencyCalculator(h1, h2, h3, h4, h5)) for name in expected: self.assertEqual(set(expected[name]), set(calculated[name]))