Пример #1
0
    def testSecurityMovingAnyTrue(self):
        window = 3

        self.aapl['close'] = self.aapl['close'] > 0.
        self.ibm['close'] = self.ibm['close'] > 0.

        mq = SecurityMovingAnyTrue(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]))
            mq.push(data)
            if i < window:
                start = 0
            else:
                start = i + 1 - window

            if i < 1:
                continue

            value = mq.value
            for name in value.index():
                con = self.dataSet[name]['close'][start:(i + 1)]
                expected = np.any(con)
                calculated = value[name]
                self.assertEqual(
                    expected, calculated, 'at index {0}\n'
                    'expected:   {1}\n'
                    'calculated: {2}'.format(i, expected, calculated))
Пример #2
0
def MANYTRUE(window, x='x'):
    return SecurityMovingAnyTrue(window, x)
Пример #3
0
def MANYTRUE(window, dependency='x'):
    return SecurityMovingAnyTrue(window, dependency)