def test_relative_candles(self): df = DF_TEST[-2:].copy() relative = ta_realative_candles(df) np.testing.assert_array_almost_equal( np.array([0.002469, 0.002021, 0.002533, -0.002829]), relative.values[-1])
def test_multi_channel(self): df = DF_TEST.copy() club = ta_candles_as_culb(df) self.assertGreaterEqual(club["upper"].values.max(), 0) self.assertGreaterEqual(club["lower"].values.max(), 0) np.testing.assert_array_almost_equal( np.array([3.120900e+02, 6.402011e-05, 4.861506e-03, 9.995516e-01]), club.iloc[-1].values, 5)
def test_multi_channel(self): df = DF_TEST.copy() ohlc_values = df[["Open", "High", "Low", "Close"]].iloc[-1].values culb = ta_candles_as_culb(df, volume=None) culb_values = culb.iloc[-1].values self.assertGreaterEqual(culb["upper"].values.max(), 0) self.assertGreaterEqual(culb["lower"].values.max(), 0) self.assertEqual(ohlc_values[1] > ohlc_values[-1], culb_values[-1] < 0) np.testing.assert_array_almost_equal(np.array([3.120900e+02, 6.402011e-05, 4.861506e-03, -4.48435e-04]), culb_values, 5)
def test_one_hot_encoder_vec(self): df = pd.DataFrame({"a": [1, 2, 3, 4, 4, 5]}) encoded = ta_one_hot_encode_discrete(df["a"]) print(repr(encoded)) self.assertListEqual(df.index.tolist(), encoded.index.tolist()) np.testing.assert_array_equal( np.array([[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]), encoded._.values)