Skip to content
All library documents

Grid Trading: Calculating Average Entry Price as Position Changes

Article Quant course library

Summary

The document introduces a position calculator for a grid strategy that tracks net quantity, average price, and accumulated profit as fully filled orders arrive. Its example illustrates that after buying at several nearby levels and selling part of the position, the average price of the remaining units is calculated from the remaining inventory rather than from every historical purchase. The class updates its state only when an order is completely filled.

Separate branches handle adding to a long or short position, reducing an existing position, closing it, or crossing through zero into the opposite direction. The formulas also use a grid-step adjustment when reducing a position, reflecting the assumed price spacing between grid levels. The excerpt says the broader lesson compares direct grid orders with versions using take-profit and stop-loss rules, but it provides only this calculator, not the complete trading logic. It offers no tests, fee treatment, or evidence that the accounting assumptions match a particular exchange or grid design.

Key ideas

  • The calculator updates position state only after a full order fill.
  • Average price is recalculated when adding to or reducing a position.
  • Closing a position resets its average price, while crossing zero starts a position in the opposite direction.
  • Grid-step adjustments appear in formulas for reducing an opposing position.
  • The excerpt does not provide the complete grid strategy or validate its accounting assumptions.

Tags

From a private course collection; the original is not published.