def setUpClass(cls): p = data.Prices(open=np.array([1.0, 2.0, 3.0, 1.0]), high=np.array([2.0, 3.0, 4.0, 2.0]), low=np.array([0.0, 1.0, 2.0, 0.0]), close=np.array([2.0, 3.0, 1.0, 2.0]), volume=np.array([10.0, 10.0, 10.0, 10.0])) cls.prices = {"TST": data.prices_to_relative(p)}
def test_prices_to_relative(self): t = data.Prices(open=np.array([1.0]), high=np.array([3.0]), low=np.array([0.5]), close=np.array([2.0]), volume=np.array([10])) rel = data.prices_to_relative(t) np.testing.assert_equal(rel.open, t.open) np.testing.assert_equal(rel.volume, t.volume) np.testing.assert_equal(rel.high, np.array([2.0])) # 200% growth np.testing.assert_equal(rel.low, np.array([-.5])) # 50% fall np.testing.assert_equal(rel.close, np.array([1.0])) # 100% growth