Algorithmic Trading Platform

Contracts / Interface

Overview

Current position snapshot produced by PositionManager after each Execution. Represents the live state of a symbol holding including P&L. Defined in src/domain/__init__.py.

Contract

Consumers

  • AuditLog
  • IPositionRepository

Types

NameBaseConstraints / ValuesDescription
PositiondataclassCurrent position snapshot published by PositionManager after each fill.
Referenced By 1

Contracts

Documents

Position Data Contract table repo://graph/nodes/65a3931ea5a60fcbc71fe5feafd3d577/artifacts/position-data-contract.md

Position Data Contract

Current position snapshot produced by PositionManager and published to the EventBus.

Consumed by MonitoringAndReporting and UserInterfaceDashboard.

Source: src/domain/__init__.py@dataclass class Position

Fields

Field Type Required Default Description
symbol str Ticker symbol (e.g. AAPL, MSFT)
qty float Current net position quantity (positive = long, negative = short)
avg_cost float Volume-weighted average cost per share
market_value float Current market value (qty × last_price)
unrealized_pnl float Unrealized profit/loss (market_value - (qty × avg_cost))
realized_pnl float Cumulative realized profit/loss from closed trades
timestamp datetime now() UTC timestamp of snapshot

Consumers

Component Usage
MonitoringAndReporting Aggregates position snapshots for P&L reports and alerts
UserInterfaceDashboard Displays real-time positions and P&L to the trader

Notes

  • Position is a snapshot — a new instance is published after every Execution that changes the position
  • qty == 0 indicates a flat (closed) position
  • unrealized_pnl fluctuates with market price; realized_pnl is locked in on close
  • No position_id field — positions are keyed by symbol

Position Class Diagram diagram repo://graph/nodes/65a3931ea5a60fcbc71fe5feafd3d577/artifacts/position-class-diagram.md

Position Class Diagram