Two ways to install pylivetrader on Windows.
The first section uses Anaconda environments.
Or jump to

Install Pylivetrader on Windows

Using Anaconda Environment

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.

Setup of pylivetrader on Windows

without conda environments

Anaconda is used here to place files but then conda is not used, just standard Python like pip.

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

Python, using Anaconda setup

I recommend Python 3.6 for now, to avoid potential problems. This is it, in Anaconda:
Anaconda3-5.2.0-Windows-x86_64.exe 631.3M 2018-05-30 13:04:18 62244c0382b8142743622fdc3526eda7
    Install as Just Me or All Users
    to C:\Python36 (short simple paths make easier reading, copy/paste and everything else along the way)

    Check the boxes: Add to path and Register as default

    Install VSCode at the end too, it can be useful (although it won’t break in to breakpoints on dependent files).

Open a new cmd prompt and verify path. I added some newlines here for clarity, showing my path as an example:

C:\> path
    C:\Program Files\Microsoft VS Code\bin;

Visual C++ 2015 Build Tools

This is a key step that resolves the lru-dict compile snag.
I found the answer here:
    … in this link (in an answer) and it works. The link is unusual, and includes the period at the end:

Keys: Use keyz.cmd (see the contents of the cmd file below)

Obtain keys from (paper)
Paste your key and secret key into the file below.
Run that at cmd prompt.
Keys are now set for the current cmd window and all others going forward,
  and any processes that rely on them.


On the Start menu, open ‘Visual C++ 2015 MSBuild Command Prompt’ so the compiler will be found.

Run these:

    python.exe -m pip install --upgrade pip
    pip install zipline
    pip install pylivetrader
    pip install pipeline-live
    pip install pipdeptree
    pipdeptree -p pylivetrader

In that last command, there are likely to be some conflicts, depending on one’s own environment.
For example, mine:

    C:\> pipdeptree -p pylivetrader
    Warning!!! Possibly conflicting dependencies found:
    * intervaltree==3.0.2
     - sortedcontainers [required: >=2.0,<3.0, installed: 1.5.10]
    * distributed==1.21.8
     - msgpack [required: Any, installed: ?]

Those are easy to resolve. I did so as follows. Just use the double-quote pattern for versions:

    pip install msgpack
    pip install "sortedcontainers>=2.0"

Try also:

    pipdeptree -p zipline

Now all set. Everything is clean.

Run an example to make sure it works:

Grab the example at
    … using the Raw button.

Save that as
Open a new cmd window, command prompt (console window).
cd to the directory where you saved that file. I use C:\ap
[The stock market doesn’t need to be open to test this]

Type at the prompt:

pylivetrader run

This output indicates it is fine:

[2019-05-08 01:16:42.080187] INFO: Algorithm: livetrader start running with backend = alpaca data-frequency = minute
[2019-05-08 01:16:52.327810] INFO: algo:
Algorithm initialized variables:
 context.MaxCandidates 100
 LowVar 6
 HighVar 40    

That was a starter algorithm by Alapaca, you can ask around in and might find alternatives.


These are some other programs I use a lot on Windows for development:

Make sure the 32-bit version even on x64, for TextFX and Python support.
There’s also a portable version out there if you search the web for it.

TextFX Characters
    Plugins Admin > ‘textfx’ > Install
Settings > Preferences > Language > Python > Tab characters > Replace by 4 spaces


Search & Replace

Paintshop Pro 4.14

(contact me, it is old. just the essentials)
For saving screen captures.
On start, one time:
    The first time, run it as administrator, right click the icon and dig for that option.
    (otherwise will say it can’t update the registry [with its settings])
    Clear initial dialogs.
    Move toolbars all to the same line by dragging just off to the side of buttons, a tiny area available for that.

Another program I’ve been tinkering with, and would be very good for development purposes, except for one thing.
This can break into breakpoints set in dependent files too (unlike VS Code), not just the algo.
However there’s no known way for it to initiate debugging with pylivetrader.exe in use, currently.

keyz.cmd file content

:: Sets Alpaca keys, the environment variables, 
::   for both the current `cmd` window and/or other applications going forward.
:: To obtain keys, visit
:: I call this file keyz.cmd to be able to just type `keyz` at the prompt after changes
::   because the word `keys` in Windows is already taken.

@echo off

:: Set keys for the current window

:: Set them also for other windows and processes going forward

:: Displaying what was just set.
set apca

:: Or for copy/paste manually ...
:: setx APCA_API_KEY_ID     'PK85___YOUR_KEY___6PVN'
:: setx APCA_API_SECRET_KEY '6waXwdMaTX___YOUR_KEY___nc1UQqkNlC'
:: setx APCA_API_BASE_URL   ''

ap_files.cmd (Another script I use and recommend to make things easier)

:: I run a little `ap_files.cmd` file like this to copy some of the latest files used by pylivetrader to one place.
:: Then with (Search & Replace) 
::   I can quickly & easily look thru them all for whatever reason.
:: When the need arises to find something, it saves a ton of time.
:: Search & Replace is one of my main tools used most often, digging thru algorithms for bits code.
:: mkdir will fail if already exists causing no problem.

cd %USERPROFILE%\documents
mkdir ap\site-packages
cd %USERPROFILE%\documents\ap\site-packages

xcopy /ifdryshck c:\python36\Lib\site-packages\alpaca_trade_api     alpaca_trade_api
xcopy /ifdryshck c:\python36\Lib\site-packages\iexfinance           iexfinance
xcopy /ifdryshck c:\python36\Lib\site-packages\pipeline_live        pipeline_live
xcopy /ifdryshck c:\python36\Lib\site-packages\pylivetrader         pylivetrader
xcopy /ifdryshck c:\python36\Lib\site-packages\requests             requests
xcopy /ifdryshck c:\python36\Lib\site-packages\trading_calendars    trading_calendars
xcopy /ifdryshck c:\python36\Lib\site-packages\urllib3              urllib3
xcopy /ifdryshck c:\python36\Lib\site-packages\logbook              logbook
xcopy /ifdryshck c:\python36\Lib\site-packages\zipline              zipline

:: Another step, once those are copied, I delete all of the .pyc files.
:: They are pre-compiled cache versions of .py files for faster startup, not needed there.
del /s /q *.pyc

:: Also deleting test files & directories.
:: Files
del /s /q test*
:: Directories. (Sad that this line needed to be so complex)
for /f %i in ('dir /a:d /s /b *test*') do rd /s /q %i

_Section written by GHa – on

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 Forum or Community Slack to get help from other community members and the Alpaca team.