$ show PacktPublishing/Learn-Algorithmic-Trading
This repository is the companion code for the Packt book 'Learn Algorithmic Trading'. It contains a collection of Python scripts, data files (pickle, CSV, HDF5), and a FIX protocol simulator organized by book chapters. The code demonstrates algorithmic trading strategies (mean reversion, trend following, pairs trading, turtle trading), technical indicators (EMA, MACD, RSI, Bollinger Bands), machine learning models (KNN, SVM, logistic regression, linear/ridge/lasso), backtesting frameworks (for-loop and event-based), risk management metrics, and a FIX 4.4 simulator with custom FX fields. The repository is primarily educational and not intended for production use. It exhibits significant technical drift: dependencies are not pinned, data sources (Yahoo Finance via pandas_datareader) are deprecated, Python 2.7 compatibility is assumed, and the code relies on very old library versions (pandas 0.14.1/0.15.2). Reproducibility is low due to missing environment definitions and hardcoded paths. However, some components (OrderManager, FIX simulator, risk measures) are well-structured and could be extracted for reuse with minimal adaptation.
The LLM identified 3 files worth highlighting for reuse:
Implements order validation, status tracking, and timeout logic for a trading system. Uses a deque for message passing and supports order cancellation and replacement. The class is self-contained and can be extracted into any trading simulation or live trading system with minimal modification.
A FIX 4.4 server simulator built with QuickFix and Twisted. Handles session-level and application-level messages, including custom fields for FX trading (forward points, fixing references). Demonstrates a reusable pattern for testing FIX connectivity and order flow without a real exchange.
Computes key risk and performance metrics: Sharpe ratio, Sortino ratio, maximum drawdown, average drawdown, and position holding times. The functions are pure and parameterized, making them reusable for any backtest or portfolio analysis.