Skip to content
All library documents

Double EMA Crossover Strategy with Position Reconciliation

Code Quant course library

Summary

This document implements a directional crossover strategy using fast and slow exponential moving averages on hourly bars. It calculates the averages from closing prices, discards the latest bar if it has not yet closed, and signals a long position when the fast average crosses above the slow one or a short position when it crosses below. Trade quantity is estimated from a fixed notional amount and rounded to a minimum size.

On incoming ticks, the strategy submits limit orders at the latest price when its signal requires reversing or opening a position. It persists its intended position and includes a reconciliation routine that compares that target with the exchange position, cancels open orders, and submits orders to close the gap. The example gives implementation logic but no backtest or live performance evidence. It leaves practical risks unresolved, including signal lag, repeated tick handling, order fills, and position sizing beyond a fixed notional amount.

Key ideas

  • The strategy uses a fast and slow exponential moving average crossover to set long or short direction.
  • It excludes an hourly bar whose scheduled close time has not yet arrived.
  • Order size is based on a fixed notional value divided by the current close, subject to a minimum quantity.
  • Tick handling submits limit orders to establish or reverse the target position.
  • Position reconciliation compares the stored strategy target with exchange holdings and adjusts for discrepancies.

Tags

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