feat(portfolio): PortfolioRunner live (data v2, tick, ribilancio giornaliero, ledger)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 16:05:07 +02:00
parent 2b3d3e3ff8
commit a5547fb3d2
3 changed files with 160 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
from src.portfolio.runner import rebalance_allocations
from src.portfolio.ledger import PortfolioLedger
def test_rebalance_resizes_to_total(tmp_path):
L = PortfolioLedger("PX", total_capital=1000.0, data_dir=tmp_path)
class FakeWorker:
def __init__(self, cap): self.capital = cap
workers = {"a": FakeWorker(700.0), "b": FakeWorker(500.0)}
rebalance_allocations(L, workers, {"a": 0.5, "b": 0.5})
assert L.total_capital == 1200.0
assert workers["a"].capital == 600.0 and workers["b"].capital == 600.0