AlgoTraderAlgoTrader Documentation

Appendix I. Example strategy "EMA" in Python via API

This strategy effectively replicates the Java based EMA strategy (Appendix E, Example Strategy "EMA"). It is written in Python and integrates with the platform using the AlgoTrader API (REST and ActiveMQ based).

This is a demonstration of the concept that by utilizing AlgoTrader API it is possible to write strategies in languages other than Java. In order to run this strategy, AlgoTrader server must be started. Running ema-python-via-api/ in Python afterwards starts the strategy execution. The strategy subscribes to market data on an ActiveMQ topic and submits orders via REST API.

Note that even though this approach allows one to access all AlgoTrader functionality and run a strategy against a running AlgoTrader server, a strategy written this way can't be used for backtesting (Section 3.1, “Simulation Mode”). You can however run this strategy in live trading mode against Section 5.1, “Exchange Simulator”. Backtesting Python strategies works if you write your strategy using AlgoTrader Python Interface, see Appendix G, Example strategy "EMA" in Python.

All the configurations settings for the example strategy are located inside file. Only an installed Python interpreter is required (the example script was tested with Python version 3.6.3)