# file: agent_system/core.py from dataclasses import dataclass from typing import Dict, Set import numpy as np @dataclass class AssetAllocation: weights: Dict[str, float] @dataclass class Force: id: str name: str tags: Set[str] allocation: AssetAllocation returns_history: np.ndarray @dataclass class Portfolio: def __init__(self, cash: float): self.cash = cash # This is the USDT balance self.positions = {} # {Symbol: Quantity} self.total_value = cash def update(self, prices: Dict[str, float]): pos_val = sum(qty * prices.get(sym, 0) for sym, qty in self.positions.items()) self.total_value = self.cash + pos_val