Support for Python Strategies was introduced in release 6.0.0. In this article, we will describe in detail all steps necessary to run the example Python Strategy in AlgoTrader. As a starting point, we will take AlgoTrader installed using Windows Installer:
https://algotrader-installer.s3.us-east-1.amazonaws.com/latest.html
As an example, we will run an ema-python strategy from the Examples project.
Open IDEA for AlgoTrader and search in run configs EmbeddedStrategyStarter-ema-python:
Here you can check all VM opinions that are required by ema strategy like aggregating bars and loading sample data (e.g. strategy name) to DB.
The most important option is spring profiles, here pythonIntegration profile is enabled. It activates PythonStrategyService that serves to enable communication between AlgoTrader and strategies written in Python. After starting AlgoTrader using this starter, AlgoTrader Server and java part of Python strategy will be started. PythonStrategyService invoked by pythonIntegration spring profile will print information to the console that AlgoTrader is up and it is waiting for Python strategy to connect at the end of this process:
Now when AlgoTrader is ready we just need to run Python strategy script, for this, open PyCharm for AlgoTrader and run ema-python-strategy.py. It can be done using a preconfigured venv python interpreter that is installed with AT or your own interpreter:
The virtual environment should be enough for trial test purposes although for running AT on different interpreter it's necessary to install AT python package. More details about it can be found in our documentation:
http://doc.algotrader.com/html/Installation.html#Python_installation
Python packages are available for the clients on our nexus:
https://repo.algotrader.ch/nexus/service/rest/repository/browse/python/algotrader-com/
After starting the python script AlgoTrader UI will pop out. Now both AT server and Strategy are up and running.
Comments
0 comments
Please sign in to leave a comment.