Local Python installation#
This is the recommended method for advanced strategy development. You can checkout the example code and run it on your local computer.
This method uses Git checkout and Poetry package manager for Python.
This is a good option if you are using any of popular IDEs such as
PyCharm
Visual Studio Code with Jupyter Visual Studio Code extension. Choosing a black-on-white theme recommended, because the default charts assume white background.
We give instructions to Visual Studio Code, but PyCharm installation is very similar.
Before starting#
Note
The installation method described here is for advanced Python developers. If you are new to Python we recommend using Visual Studio Dev Container installation method instead. If you think you can set up your own local environment from the scratch, you need to be able to resolve Python version and package compatibility issues, or other issues which may occur.
Note
Before getting started, double check that you are using a compatible Python version. Because of complex data analysis libraries used, the Python version compatibility is picky.
The current supported Python versions are listed in pyproject.toml.
Installation steps#
Git clone the Trading Executor repository from Github.
Install the client and its dependencies using Poetry:
# Assumes you have SSH key set up with your Github account
git clone [email protected]:tradingstrategy-ai/trade-executor.git
cd trade-executor
git submodule update --init --recursive
# Extra dependencies
# - execution: infrastructure to run live strategies
# - web-server: support webhook server of live strategy executors
# - qstrader: still needed to run legacy unit tests
poetry install --all-extras
Configure Visual Studio Code to use Python interpreter from Poetry installation.
First in Poetry shell figure where Poetry installed the Python interpreter:
which python
This gives you the full path of python command like:
/Users/moo/Library/Caches/pypoetry/virtualenvs/tradingstrategy-lMEetNwg-py3.8/bin/python
Then use Visual Studio Code Python: Select Interpreter command from Command palette to configure this interpreter by choosing Enter interpreter path option for the interpreter.
Now you can run Getting started and other example notebooks. Open ipynb file in Visual Studio Code. Then choose Run All on the open notebook.
Local Python environment with git checkout#
This is the recommended method for advanced strategy development. You can checkout the example code and run it on your local computer, using Visual Studio Code, PyCharm or other local Python editor.
Install Jupyter Visual Studio Code extension. Choosing a black-on-white theme recommended, because the default charts assume white background.
Git clone the Trading Strategy client repository from Github.
Install the client and its dependencies using Poetry:
cd client
poetry shell
poetry install
Configure Visual Studio Code to use Python interpreter from Poetry installation.
First in Poetry shell figure where Poetry installed the Python interpreter:
which python
This gives you the full path of python command.
/Users/moo/Library/Caches/pypoetry/virtualenvs/tradingstrategy-lMEetNwg-py3.8/bin/python
Then use Visual Studio Code Python: Select Interpreter command from Command palette to configure this interpreter by choosing Enter interpreter path option for the interpreter.
Now you can run Getting started and other example notebooks. Open ipynb file in Visual Studio Code. Then choose Run All on the open notebook.
Local Jupyter installation#
You run notebooks by installing a local Jupyter notebook installation. This will create a local Jupyter server and open Jupyter notebooks in your web browser.
Take a git checkout.
Install using poetry:
poetry install
Then start Jupyter server at the root folder:
ipython notebook
Navigate to a file you want to edit in your web browser.