def test_pvi_invalid_data(self): self.close_data.append(1) with self.assertRaises(Exception) as cm: volume_index.positive_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_pvi(self): pvi = volume_index.positive_volume_index(self.close_data, self.volume) print(list(pvi)) np.testing.assert_array_equal(pvi, self.pvi_expected)