MCPcopy
hub / github.com/microsoft/qlib / test_Abs

Method test_Abs

tests/ops/test_elem_operator.py:19–28  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

17 self.mock_df = MOCK_DF[MOCK_DF["symbol"] == self.instrument]
18
19 def test_Abs(self):
20 field = "Abs($close-Ref($close, 1))"
21 result = ExpressionD.expression(self.instrument, field, self.start_time, self.end_time, self.freq)
22 self.assertGreaterEqual(result.min(), 0)
23 result = result.to_numpy()
24 prev_close = self.mock_df["close"].shift(1)
25 close = self.mock_df["close"]
26 change = prev_close - close
27 golden = change.abs().to_numpy()
28 self.assertIsNone(np.testing.assert_allclose(result, golden))
29
30 def test_Sign(self):
31 field = "Sign($close-Ref($close, 1))"

Callers

nothing calls this directly

Calls 3

shiftMethod · 0.80
expressionMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected