Phase 1: initial codes

This commit is contained in:
2026-05-26 11:04:27 -04:00
parent 03bff49523
commit f49a283059
32 changed files with 4194 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
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]:
...