def testSecurityMovingCountedPositive(self): window = 10 ma1 = SecurityMovingCountedPositive(window, ['close']) for i in range(len(self.aapl['close'])): data = dict(aapl=dict(close=self.aapl['close'][i], open=self.aapl['open'][i]), ibm=dict(close=self.ibm['close'][i], open=self.ibm['open'][i])) ma1.push(data) if i < window: start = 0 else: start = i + 1 - window value = ma1.value for name in value.index(): expected = np.sum(self.dataSet[name]['close'][start:(i + 1)] > 0.0) calculated = value[name] self.assertAlmostEqual(expected, calculated, 12, 'at index {0}\n' 'expected: {1:.12f}\n' 'calculated: {2:.12f}'.format(i, expected, calculated)) with self.assertRaises(ValueError): _ = SecurityMovingCountedPositive(window, ['close', 'open'])
def testSecurityMovingCountedPositive(self): window = 10 ma1 = SecurityMovingCountedPositive(window, ['close']) for i in range(len(self.aapl['close'])): data = {'aapl': {'close': self.aapl['close'][i], 'open': self.aapl['open'][i]}} data['ibm'] = {'close': self.ibm['close'][i], 'open': self.ibm['open'][i]} ma1.push(data) if i < 10: start = 0 else: start = i + 1 - window value = ma1.value for name in value.index: expected = np.sum(self.dataSet[name]['close'][start:(i + 1)] > 0.0) calculated = value[name] self.assertAlmostEqual(expected, calculated, 12, 'at index {0}\n' 'expected: {1:.12f}\n' 'calculated: {2:.12f}'.format(i, expected, calculated)) with self.assertRaises(ValueError): _ = SecurityMovingCountedPositive(window, ['close', 'open'])
def MNPOSITIVE(window, dependency='x'): return SecurityMovingCountedPositive(window, dependency)
def MNPOSITIVE(window, x='x'): return SecurityMovingCountedPositive(window, x)
def NPOSITIVE(window, dependency='x', symbolList=None): return SecurityMovingCountedPositive(window, dependency, symbolList)