From cf4e663dcb339547e39cdccb9a6def925a1d0242 Mon Sep 17 00:00:00 2001 From: Caceresenzo Date: Tue, 4 Jun 2024 17:49:37 +0200 Subject: [PATCH] test(holding): fix --- tests/test_holdings.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_holdings.py b/tests/test_holdings.py index a00a30b..719a9fc 100644 --- a/tests/test_holdings.py +++ b/tests/test_holdings.py @@ -6,28 +6,30 @@ class HoldingTest(unittest.TestCase): def test_market_price(self): - holding = bktest.Holding("AAPL", 15, 2) + holding = bktest.Holding("AAPL", 15, 2, None) - self.assertEqual(15*2, holding.market_price) + self.assertEqual(15 * 2, holding.market_price) def test_merge(self): - holding = bktest.Holding("AAPL", 15, 2, False) - order = bktest.Order("AAPL", 30, 4) + holding = bktest.Holding("AAPL", 15, 2, 15 * 2, False) + order = bktest.Order("AAPL", 30, 4, 30 * 4) expected_quantity = holding.quantity + order.quantity - + expected_value = holding.value + order._value + holding.merge(order) self.assertEqual(expected_quantity, holding.quantity) + self.assertEqual(expected_value, holding.value) self.assertEqual(order.price, holding.price) self.assertTrue(holding.up_to_date) def test_str(self): holding = bktest.Holding("AAPL", 15, 2, None) - + self.assertEqual(str(holding), "AAPLx15@2") def test_repr(self): holding = bktest.Holding("AAPL", 15, 2, None) - + self.assertEqual(repr(holding), "AAPLx15")