Porting a Multi-Instrument Moving Average Strategy to Python
Summary
The document presents a Python port of a commodity futures moving average strategy originally implemented in JavaScript. It frames the example as a way to study multi-instrument strategy architecture, including per-contract state, position and order management, trading-hour checks, and status reporting. The moving average logic is intentionally simple so the framework could be adapted to other indicators.
The article says the Python and JavaScript versions produced identical backtest results, while the Python run was slightly faster on the server used. It also describes an extension that adds chart plotting. The supplied source is lengthy and partly omitted in the document, and the backtest figures are not accompanied by numerical performance details. The comparison therefore offers an implementation example rather than evidence that the strategy is profitable or that the timing result generalizes. Its main learning value is the design pattern for managing several commodity futures contracts and extending a basic signal framework.
Key ideas
- The example ports a JavaScript commodity futures moving average strategy to Python for multiple instruments.
- The strategy framework manages contract-specific position state, orders, trading availability, and reporting.
- The moving average signal is presented as a simple starting point for adapting the architecture to other indicators.
- The article reports matching backtest results across Python and JavaScript, with a slightly faster Python run in its test environment.
- A charting extension adds plotting functionality, while the text provides no numerical evidence of strategy profitability.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.