Quant Python: Architecting Autonomous Trading Systems

Quant Python: Architecting Autonomous Trading Systems

Day 52 — Volume Matching: Partial Fills Based on Simulated Liquidity

Python Quant's avatar
Python Quant
May 19, 2026
∙ Paid

Real markets do not give you what you ask for. You ask for 500 shares of AAPL and the market might hand you 312 — spread across four price levels, arriving in separate confirmations over the next 80 milliseconds. What your engine does with that gap between “asked” and “received” is what separates a simulation from a trading system.

Today you will build the piece of the engine that handles exactly this: a volume matching engine that walks order book price levels, applies a participation rate cap, emits partial fill events, and drives an order through a proper state machine. You will wire it to the Alpaca paper trading sandbox to validate your simulation against real market behaviour.

By the end of this lesson, your engine will never assume an order is filled until every share is confirmed.


What You Are Building

Before touching code, here is the full picture of what this module does and where it fits.

User's avatar

Continue reading this post for free, courtesy of Python Quant.

Or purchase a paid subscription.
© 2026 Python Quant · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture