Skip to content
All library documents

Portfolio Handlers for Event-Driven Trading Systems

Article QuantStart

Summary

This article explains the PortfolioHandler component in an event-driven order management system. It separates the Portfolio, which tracks cash and positions, from the handler, which connects portfolio state to strategy signals, position sizing, risk checks, price data, an event queue, and execution. This separation also allows sizing or risk components to construct a theoretical target portfolio before generating the trades needed to reach it.

On a signal, the handler creates a suggested order, passes it through a position sizer and risk manager, then queues approved order events. On a fill, it records the transaction in the portfolio so local state can track broker activity. The article illustrates the flow with basic checks for a fill’s cash impact and for a signal’s resulting order. It explicitly notes that these tests cover only simple cases and that more testing is needed; the described implementation supports market orders at this stage.

Key ideas

  • The Portfolio stores cash and positions, while the PortfolioHandler coordinates trading system components.
  • Signals become suggested orders that are sized and checked by risk management before entering the event queue.
  • Fill events update portfolio positions and cash to keep local records aligned with execution.
  • The examples test basic cash accounting and signal handling, but do not cover the full range of cases.

Tags

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