def test_ultosc(self):
     data = msft_data.copy()
     ti = technical_indicator.ULTOSC('MSFT', 1, 2, 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 25.58258795)
     self.assertAlmostEqual(data[ti.value][4], 12.35037988)
 def test_ultosc(self):
     data = msft_data.copy()
     ti = technical_indicator.ULTOSC('MSFT', 1, 2, 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 25.58258795)
     self.assertAlmostEqual(data[ti.value][4], 12.35037988)
 def test_dx(self):
     data = msft_data.copy()
     ti = technical_indicator.DX('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 31.30193905)
     self.assertAlmostEqual(data[ti.value][4], 53.38345864)
     self.assertAlmostEqual(data[ti.value][5], 73.34049986)
 def test_atr(self):
     data = msft_data.copy()
     ti = technical_indicator.ATR('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 0.83666666)
     self.assertAlmostEqual(data[ti.value][4], 0.75444444)
     self.assertAlmostEqual(data[ti.value][5], 0.71629629)
 def test_atr(self):
     data = msft_data.copy()
     ti = technical_indicator.ATR('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 0.83666666)
     self.assertAlmostEqual(data[ti.value][4], 0.75444444)
     self.assertAlmostEqual(data[ti.value][5], 0.71629629)
 def test_ensemble(self):
     data = msft_data.copy()
     ensemble = EnsembleMockObject(data, data)
     ti = technical_indicator.Ensemble(ensemble, 'EnsembleTest')
     ti.results(data)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][0], 1)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][1], 2)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][2], 3)
 def test_neural_network(self):
     data = msft_data.copy()
     network = NeuralNetworkMockObject(data, data)
     ti = technical_indicator.NeuralNetwork(network, 'NNTest')
     ti.results(data)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][0], 1)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][1], 2)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][2], 3)
 def test_ensemble(self):
     data = msft_data.copy()
     ensemble = EnsembleMockObject(data, data)
     ti = technical_indicator.Ensemble(ensemble, 'EnsembleTest')
     ti.results(data)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][0], 1)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][1], 2)
     self.assertEqual(data['ENSEMBLE_EnsembleTest'][2], 3)
 def test_neural_network(self):
     data = msft_data.copy()
     network = NeuralNetworkMockObject(data, data)
     ti = technical_indicator.NeuralNetwork(network, 'NNTest')
     ti.results(data)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][0], 1)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][1], 2)
     self.assertEqual(data['NEURAL_NETWORK_NNTest'][2], 3)
 def test_dx(self):
     data = msft_data.copy()
     ti = technical_indicator.DX('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertAlmostEqual(data[ti.value][3], 31.30193905)
     self.assertAlmostEqual(data[ti.value][4], 53.38345864)
     self.assertAlmostEqual(data[ti.value][5], 73.34049986)
 def test_adx(self):
     data = msft_data.copy()
     ti = technical_indicator.ADX('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][4]))
     self.assertTrue(np.isnan(data[ti.plus_di][2]))
     self.assertTrue(np.isnan(data[ti.minus_di][2]))
     self.assertAlmostEqual(data[ti.value][5], 52.67529919)
     self.assertAlmostEqual(data[ti.plus_di][3], 19.80830670)
     self.assertAlmostEqual(data[ti.minus_di][3], 37.85942492)
 def test_adx(self):
     data = msft_data.copy()
     ti = technical_indicator.ADX('MSFT', 3)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][4]))
     self.assertTrue(np.isnan(data[ti.plus_di][2]))
     self.assertTrue(np.isnan(data[ti.minus_di][2]))
     self.assertAlmostEqual(data[ti.value][5], 52.67529919)
     self.assertAlmostEqual(data[ti.plus_di][3], 19.80830670)
     self.assertAlmostEqual(data[ti.minus_di][3], 37.85942492)
 def test_division(self):
     data = msft_data.copy()
     ti = technical_indicator.Division(msft_close_name, 2)
     ti.results(data)
     sanity = data['DIVISION_MSFT_Close_2'] == data[msft_close_name] / 2
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] / 2
     ti2 = technical_indicator.Division(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['DIVISION_MSFT_Close_2'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_subtraction(self):
     data = msft_data.copy()
     ti = technical_indicator.Subtraction(msft_close_name, 1)
     ti.results(data)
     sanity = data['SUBTRACTION_MSFT_Close_1'] == data[msft_close_name] - 1
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] - 1
     ti2 = technical_indicator.Subtraction(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['SUBTRACTION_MSFT_Close_1'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_addition(self):
     data = msft_data.copy()
     ti = technical_indicator.Addition(msft_close_name, 1)
     ti.results(data)
     sanity = data['ADDITION_MSFT_Close_1'] == data[msft_close_name] + 1
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] + 1
     ti2 = technical_indicator.Addition(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['ADDITION_MSFT_Close_1'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_division(self):
     data = msft_data.copy()
     ti = technical_indicator.Division(msft_close_name, 2)
     ti.results(data)
     sanity = data['DIVISION_MSFT_Close_2'] == data[msft_close_name] / 2
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] / 2
     ti2 = technical_indicator.Division(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['DIVISION_MSFT_Close_2'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_subtraction(self):
     data = msft_data.copy()
     ti = technical_indicator.Subtraction(msft_close_name, 1)
     ti.results(data)
     sanity = data['SUBTRACTION_MSFT_Close_1'] == data[msft_close_name] - 1
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] - 1
     ti2 = technical_indicator.Subtraction(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['SUBTRACTION_MSFT_Close_1'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_multiplication(self):
     data = msft_data.copy()
     ti = technical_indicator.Multiplication(msft_close_name, 2)
     ti.results(data)
     sanity = data['MULTIPLICATION_MSFT_Close_2'] == data[msft_close_name] * 2
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] * 2
     ti2 = technical_indicator.Multiplication(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['MULTIPLICATION_MSFT_Close_2'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_addition(self):
     data = msft_data.copy()
     ti = technical_indicator.Addition(msft_close_name, 1)
     ti.results(data)
     sanity = data['ADDITION_MSFT_Close_1'] == data[msft_close_name] + 1
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] + 1
     ti2 = technical_indicator.Addition(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['ADDITION_MSFT_Close_1'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_multiplication(self):
     data = msft_data.copy()
     ti = technical_indicator.Multiplication(msft_close_name, 2)
     ti.results(data)
     sanity = data[
         'MULTIPLICATION_MSFT_Close_2'] == data[msft_close_name] * 2
     self.assertTrue(sanity.all())
     data['TEST'] = data[msft_close_name] * 2
     ti2 = technical_indicator.Multiplication(msft_close_name, 'TEST')
     ti2.results(data)
     sanity = data['MULTIPLICATION_MSFT_Close_2'] == data['TEST']
     self.assertTrue(sanity.all())
 def test_stochf(self):
     data = msft_data.copy()
     ti = technical_indicator.STOCHF('MSFT', fast_k_period=3, fast_d_period=2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertTrue(np.isnan(data[ti.fastk][2]))
     self.assertTrue(np.isnan(data[ti.fastd][2]))
     self.assertAlmostEqual(data[ti.value][3], 12.97709923)
     self.assertAlmostEqual(data[ti.fastk][3], 12.97709923)
     self.assertAlmostEqual(data[ti.fastd][3], 54.00628011)
     self.assertAlmostEqual(data[ti.value][4], 2.95857988)
     self.assertAlmostEqual(data[ti.fastk][4], 2.95857988)
     self.assertAlmostEqual(data[ti.fastd][4], 7.96783955)
 def test_stoch(self):
     data = msft_data.copy()
     ti = technical_indicator.STOCH('MSFT', fast_k_period=3, slow_k_period=2, slow_d_period=2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][3]))
     self.assertTrue(np.isnan(data[ti.slowk][3]))
     self.assertTrue(np.isnan(data[ti.slowd][3]))
     self.assertAlmostEqual(data[ti.value][4], 7.96783955)
     self.assertAlmostEqual(data[ti.slowk][4], 7.96783955)
     self.assertAlmostEqual(data[ti.slowd][4], 30.9870598)
     self.assertAlmostEqual(data[ti.value][5], 13.4584566)
     self.assertAlmostEqual(data[ti.slowk][5], 13.4584566)
     self.assertAlmostEqual(data[ti.slowd][5], 10.71314808)
 def test_stochf(self):
     data = msft_data.copy()
     ti = technical_indicator.STOCHF('MSFT',
                                     fast_k_period=3,
                                     fast_d_period=2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][2]))
     self.assertTrue(np.isnan(data[ti.fastk][2]))
     self.assertTrue(np.isnan(data[ti.fastd][2]))
     self.assertAlmostEqual(data[ti.value][3], 12.97709923)
     self.assertAlmostEqual(data[ti.fastk][3], 12.97709923)
     self.assertAlmostEqual(data[ti.fastd][3], 54.00628011)
     self.assertAlmostEqual(data[ti.value][4], 2.95857988)
     self.assertAlmostEqual(data[ti.fastk][4], 2.95857988)
     self.assertAlmostEqual(data[ti.fastd][4], 7.96783955)
 def test_stoch(self):
     data = msft_data.copy()
     ti = technical_indicator.STOCH('MSFT',
                                    fast_k_period=3,
                                    slow_k_period=2,
                                    slow_d_period=2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.value][3]))
     self.assertTrue(np.isnan(data[ti.slowk][3]))
     self.assertTrue(np.isnan(data[ti.slowd][3]))
     self.assertAlmostEqual(data[ti.value][4], 7.96783955)
     self.assertAlmostEqual(data[ti.slowk][4], 7.96783955)
     self.assertAlmostEqual(data[ti.slowd][4], 30.9870598)
     self.assertAlmostEqual(data[ti.value][5], 13.4584566)
     self.assertAlmostEqual(data[ti.slowk][5], 13.4584566)
     self.assertAlmostEqual(data[ti.slowd][5], 10.71314808)
 def test_bbands(self):
     data = msft_data.copy()
     ti = technical_indicator.BBANDS('MSFT_Close', 2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.upper][5]))
     self.assertTrue(np.isnan(data[ti.value][5]))
     self.assertTrue(np.isnan(data[ti.middle][5]))
     self.assertTrue(np.isnan(data[ti.lower][5]))
     self.assertAlmostEqual(data[ti.upper][6], 25.2425772)
     self.assertAlmostEqual(data[ti.value][6], 24.9225772)
     self.assertAlmostEqual(data[ti.middle][6], 24.9225772)
     self.assertAlmostEqual(data[ti.lower][6], 24.6025772)
     self.assertAlmostEqual(data[ti.upper][7], 25.11451697)
     self.assertAlmostEqual(data[ti.value][7], 24.90451697)
     self.assertAlmostEqual(data[ti.middle][7], 24.90451697)
     self.assertAlmostEqual(data[ti.lower][7], 24.69451697)
 def test_bbands(self):
     data = msft_data.copy()
     ti = technical_indicator.BBANDS('MSFT_Close', 2)
     ti.results(data)
     self.assertTrue(np.isnan(data[ti.upper][5]))
     self.assertTrue(np.isnan(data[ti.value][5]))
     self.assertTrue(np.isnan(data[ti.middle][5]))
     self.assertTrue(np.isnan(data[ti.lower][5]))
     self.assertAlmostEqual(data[ti.upper][6], 25.2425772)
     self.assertAlmostEqual(data[ti.value][6], 24.9225772)
     self.assertAlmostEqual(data[ti.middle][6], 24.9225772)
     self.assertAlmostEqual(data[ti.lower][6], 24.6025772)
     self.assertAlmostEqual(data[ti.upper][7], 25.11451697)
     self.assertAlmostEqual(data[ti.value][7], 24.90451697)
     self.assertAlmostEqual(data[ti.middle][7], 24.90451697)
     self.assertAlmostEqual(data[ti.lower][7], 24.69451697)