from abc import ABC, abstractmethod from dataclasses import dataclass, field from typing import Optional @dataclass class Position: symbol: str shares: float avg_cost: float market_value: float = 0.0 current_price: float = 0.0 pnl: float = 0.0 pnl_pct: float = 0.0 description: str = "" @dataclass class AccountBalance: total_equity: float = 0.0 cash: float = 0.0 buying_power: float = 0.0 day_pnl: float = 0.0 day_pnl_pct: float = 0.0 @dataclass class Order: order_id: str symbol: str side: str # buy / sell quantity: float price: float status: str order_type: str placed_at: str = "" class BaseBroker(ABC): name: str = "base" @abstractmethod def connect(self) -> bool: ... @abstractmethod def is_connected(self) -> bool: ... @abstractmethod def get_positions(self) -> list[Position]: ... @abstractmethod def get_balance(self) -> AccountBalance: ... @abstractmethod def get_orders(self, limit: int = 25) -> list[Order]: ...