This commit is contained in:
2026-06-17 12:25:21 +02:00
parent ee183e23c5
commit a754e15e32
6 changed files with 97 additions and 63 deletions

View File

@@ -709,6 +709,11 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(
strategy.get_mtm(line, Decimal('10')),
Decimal('250.00'))
strategy.components[0].price_index.get_price.assert_called_once_with(
'2026-03-29',
line.unit,
strategy.currency,
relative_last=True)
@with_transaction()
def test_get_mtm_uses_fixed_pricing_component(self):
@@ -1205,6 +1210,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
def test_get_strategy_mtm_price_applies_component_ratio(self):
'strategy mtm price applies component ratios'
price_index = Mock(get_price=Mock(return_value=Decimal('100')))
strategy = Mock(
scenario=Mock(
valuation_date='2026-03-29',
@@ -1214,7 +1220,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
)
strategy.components = [Mock(
price_source_type='curve',
price_index=Mock(get_price=Mock(return_value=Decimal('100'))),
price_index=price_index,
price_matrix=None,
ratio=Decimal('25'),
)]
@@ -1223,6 +1229,11 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(
valuation_module.Valuation._get_strategy_mtm_price(strategy, line),
Decimal('25.0000'))
price_index.get_price.assert_called_once_with(
'2026-03-29',
line.unit,
strategy.currency,
relative_last=True)
def test_get_strategy_mtm_price_keeps_signed_component_spread(self):
'strategy mtm price keeps signed spread between different components'