Alpaca Proxy Agent - clarification for users


After reading and , I followed the instructions and attempted to setup the alpaca proxy agent, without success, for quite some time. The author is obviously quite talented and capable, but simple users may need some additional information to get the service working.

On a linux machine with alpaca-trade-api, websockets, and additional python requirements properly setup (including docker), follow the instructions from the author.

The easiest way to use the service, without taking into account security, is to pull and run the docker image:

docker pull shlomik/alpaca-proxy-agent
docker run -p 8765:8765 -e USE_POLYGON=false shlomik/alpaca-proxy-agent

This starts up a docker container as root.

Find the container name or id of the running alpaca proxy agent:

docker container ps -a

This will give you a “CONTAINER_ID” or “NAMES” parameter to use.

Here is an example output from above command:

d9e967616212 shlomik/alpaca-proxy-agent “/bin/sh -c 'python …” 35 minutes ago Up 35 minutes>8765/tcp awesome_mcnulty

I used this command to find the IP address of the alpaca proxy agent docker container:

docker inspect --format=’{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ d9e967616212

This command will return an IP address - for example: (Copy this address)

Probably the easiest way to test the proxy agent is to edit the author’s, which is found in the alpaca-trade-api-python/examples subdirectory.

Edit the example websocket example, enter your ALPACA_API_KEY and ALPACA_SECRET_KEY parameters, and change the data_url to the docker container IP address and proxy port number. It’s also important to change 'https" to “http”, as the proxy agent does not use secure socket layers (SSL). Here’s an example of how the changes appear:

import os


if name == ‘main’:
import logging

logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
conn = StreamConn(
        # data_url=URL(''),     **<--- comment this out.**

Next export the environment variable “DATA_PROXY_WS” or place it in your shell configuration file (.bashrc for example). Be sure to source the .bashrc file after editing or open a new IDE.

export DATA_PROXY_WS=“ws://”

That’s it - make sure the docker container is running and execute the example websocket in a separate shell:


You should see some authentication and logging information in the proxy server shell.

I have not tested the polygon websocket connection yet, but hopefully it will execute without issue. You should be able to run multiple instances of streaming clients, as advertised by the author’s intent.

Hope this helps other simple users, like myself.

Best Regards,

Joe O.

Hi Joe
I’m the author of the project.
Thanks for this post - it definitely adds more information for other users.
This project is still young so I hope as it grows it will become more and more simple to use.

Just one remark about the IP address - are you sure that this is not the docker internal IP address?
most of the cases the IP will be just:
so a user will need to do:

conn = StreamConn(

and set env variable:

export DATA_PROXY_WS="ws://"

btw, I plan on writing a third part that will show different examples on how to use it (use it with different SDKs, use it with alpaca-bactrader-api, use it with pylivetrader)



Thanks very much for responding - very useful project.

I spent a lot of time trying to get this to work. It turns out the fundamental problem was not changing “https” to “http” for the proxy data address in my websocket clients.

The local IP address of works great for the proxy - thanks very much. The proxy seems to work by cloning the github repository and executing “python”, without using docker - is this also true?


Joe O.

yes, you could definitely run it locally with cloning the repo. less convenient, but works exactly the same

@Joe_O1 & @Shlomik

I’d like to implement exactly the Alpaca Articles you have outlined above:

These articles are from 2020 and predates API V2 release date, before I go down this rabbit hole, I wanted to double check that this is still supported.

If there is more recent articles or instructions, any help would be greatly appreciated.
Thank you so much!