def test_nvi_invalid_data(self): self.close_data.append(1) with self.assertRaises(Exception) as cm: volume_index.negative_volume_index(self.close_data, self.volume) expected = ( "Error: mismatched data lengths, check to ensure that all input data is the same length and valid" ) self.assertEqual(str(cm.exception), expected)
def next_calculation(self, candle): if self.get_datawindow() is not None: self.value['positive_volume_index'] = indicator.positive_volume_index( self.get_close(), self.get_volume() )[-1] self.value['negative_volume_index'] = indicator.negative_volume_index( self.get_close(), self.get_volume() )[-1]
def test_nvi(self): nvi = volume_index.negative_volume_index(self.close_data, self.volume) np.testing.assert_array_equal(nvi, self.nvi_expected)