17 lines
810 B
Python
17 lines
810 B
Python
from idea115_taxalpha_studio_declarative.adapters.custodian_adapter import fetch_mock_custodian_lots
|
|
from idea115_taxalpha_studio_declarative.solver import optimize_harvest
|
|
|
|
|
|
def test_optimize_harvest_realizes_target_loss():
|
|
lots = fetch_mock_custodian_lots()
|
|
# calculate total available loss from mock data: lotA loss = (80-100)*10 = -200 -> loss 200
|
|
# lotC loss = (150-200)*2 = -100 -> loss 100
|
|
# total loss available = 300
|
|
plan, audit = optimize_harvest(lots, target_loss=250)
|
|
# Ensure we realized at least the requested loss
|
|
assert plan.metadata["realized_loss"] >= 250
|
|
# Actions should include the largest-loss lots first (lotA then lotC)
|
|
ids = [a.lot_id for a in plan.actions]
|
|
assert "lotA" in ids
|
|
assert "lotC" in ids or plan.metadata["realized_loss"] >= 300
|