Skip to content
All library documents

Designing Equity Position Accounting for a Trading Portfolio

Article QuantStart

Summary

The document explains the Position component in an early event-driven trading system. A position records buys and sells, average prices, commissions, cost basis, net exposure, and realized and unrealized profit and loss. The broader design separates this accounting from the portfolio, position-sizing logic, risk checks, and order handling, so those parts can be developed and tested independently.

For valuation, the example estimates market value using the midpoint of the quoted bid and ask, then compares that value with cost basis to calculate unrealized PnL. The article describes unit tests for trade updates and reports that example outputs agree with values calculated in brokerage software. Its scope is limited: the system is described as an early, pre-release project, the example position logic targets equities, and the author notes that additional edge-case testing and support for other asset types would be needed. Specific sizing and risk rules are left to users or later modules.

Key ideas

  • A Position object can track trade legs, commissions, cost basis, exposure, and profit and loss.
  • Separating position accounting from sizing, risk review, and order handling makes the portfolio system more modular.
  • The example estimates current position value from the midpoint of bid and ask quotes.
  • Brokerage-calculated values are used as a reference for unit-testing the example calculations.
  • The described implementation is early-stage and initially focused on equity instruments.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.