Install Pylivetrader on Windows

Pylivetrader packages for Windows are hosted on our channel on Anaconda. To get started, follow these steps.

  1. Install the Python 3.7 version of Anaconda if you don’t already have it. You may be prompted to register an Anaconda account after installation.
  2. From your start menu, open Anaconda Prompt.
  3. Navigate into a development folder.

    mkdir alpacahq
    cd alpacahq
  4. Add the conda-forge, Quantopian, and alpacahq channels.

    conda config --add channels conda-forge
    conda config --add channels Quantopian
    conda config --add channels alpacahq
  5. Create a virtual environment with the necessary packages installed.

    conda create -n pylivetraderenv pylivetrader
  6. Activate your new virtual environment.

    source activate pylivetraderenv

Once you follow these steps, you should be able to run pylivetrader from the Anaconda Prompt terminal.

pylivetrader run --backend-config exampleConfig.yaml

You can reactivate this environment at any time by running source activate pylivetraderenv inside the Anaconda prompt.

If you encounter issues with setting your environment up, feel free to ask for help in our community Slack. A link to join is in the sidebar.

Alternative: Install without Anaconda

Note: we recommend trying the conda installation path first, as it does not involve compiling any dependencies.

These steps are from a Windows user who kept track while successfully setting up pylivetrader to run a Quantopian-like algorithm on Alpaca.


This was on Windows 7 and should also apply to Windows 10.

Visual Studio and .NET

Prerequisites are Python 3.6 or higher and some form of C++ compiler, which requires .NET Framework.

C++ compiler install Various options are available to have a compiler available, I installed Visual Studio Community 2017 Preview (free). VS Code at the end of Anaconda might also work, not sure (.NET Framework is still needed for that).

If a C++ compiler were not present, this is the error that would occur on pip install pylivetrader

Running clean for lru-dict
  error: Microsoft Visual C++ 14.0 is required.
Get it with "Microsoft Visual C++ Build Tools":, however instead of Build Tools, I'm opting for Visual Studio Community below.

(Note that link cited in the error message is 404, try instead

Installed .NET Framework (needed for Visual Studio Community)

Installed Visual Studio Community goes to (direct link …)

During the install, I selected these options:

  • Desktop development with C++
  • Python development

Install Python 3.6

  One option is

  I chose Anaconda (Python package) here:

  Anaconda 64-Bit Graphical Installer (631 MB) … installing that to C:\Python36

Corrected Path

In the Windows path, my previous C:\python27 had not been removed. To correct the path (a list of locations Windows looks to, for finding certain things), I did the following:

Start button > Computer > right click > Properties > Advanced system settings > Environment Variables > User > Path … setting that to: C:\Python36;C:\Python36\Library\mingw-w64\bin;C:\Python36\Library\usr\bin;C:\Python36\Library\bin;C:\Python36\Scripts;C:\Program Files\Docker Toolbox

Start button > Computer > right click > Properties > Advanced system settings > Environment Variables > System > Path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Git\cmd

Not certain about that but eventually typing path in the command prompt, the path wound up like this:

System32\Wbem;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Docker Toolbox

To open a command prompt (command window): Start > Run > cmd or Windows key > r > cmd

Install Python modules and pylivetrader

Updated pip (python tool for installing things) python -m pip install --upgrade pip

Installed pylivetrader (link)

pip install pathlib

pip install pylivetrader

Message says: Successfully built lru-dict (because the C++ compiler ok)

Installed pipeline-live (link)

pip install pipeline-live

Set up Keys and Configure

Obtain key from Dashboard

The slider at the top of the page switches between paper trading and live, and results in different keys for the two separate purposes.

The command to start trading includes an option/switch like --backend-config ap.yaml to specify the keys that will be used for live or paper. I chose the live trading yaml file name ap.yaml. My paper trading yaml file is called paper.yaml.

Contents of the yaml files below. These keys are trimmed for the example Comments in the file are the set commands to also set the keys as environment variables. Notice on paper trading, the env variable APCA_API_BASE_URL is different from the yaml file base_url currently.

Keys Live

key_id: AKxxxxxx
secret: FnvMxxxxxx

 # Live
 # set APCA_API_KEY_ID=AKxxxxxx
 # set APCA_API_SECRET_KEY=FnvMxxxxxx

Keys Paper Trading

key_id: KMxxxxxx
secret: Fvtxxxxxx

 # Paper
 # set APCA_API_KEY_ID=KMxxxxxx
 # set APCA_API_SECRET_KEY=Fvtxxxxxx

Make an algorithm. Find an example online.

Start algorithm at any time of day

C:\ap> pylivetrader.exe run -f --backend-config paper.yaml
[2018-09-16 21:31:33.615813] INFO: Algorithm: livetrader start running with backend = alpaca data-frequency = minute

Suggestions or questions?
We're always happy to hear from you. You can contribute to these docs on GitHub, or you can join our Community Slack to get help from other community members and the Alpaca team.