Skip to content

Commit 4027699

Browse files
author
Shlomi Kushchi
authored
Merge pull request #312 from alpacahq/add_support_for_alpaca_proxy_agent
Add support for the alapca-proxy-agent project
2 parents 43181bb + f80b73e commit 4027699

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ The Alpaca SDK will check the environment for a number of variables that can be
6868
| APCA_RETRY_MAX=3 | 3 | The number of subsequent API calls to retry on timeouts |
6969
| APCA_RETRY_WAIT=3 | 3 | seconds to wait between each retry attempt |
7070
| APCA_RETRY_CODES=429,504 | 429,504 | comma-separated HTTP status code for which retry is attempted |
71-
| POLYGON_WS_URL | wss://socket.polygon.io/stocks | Endpoint for streaming polygon data. You likely don't need to change this unless you want to proxy it for example |
71+
| POLYGON_WS_URL | wss://socket.polygon.io/stocks | Endpoint for streaming polygon data. You likely don't need to change this unless you want to proxy it for example |
7272
| POLYGON_KEY_ID | | Your Polygon key, if it's not the same as your Alpaca API key. Most users will not need to set this to access Polygon. |
73+
| DATA_PROXY_WS | | When using the alpaca-proxy-agent you need to set this environment variable as described ![here](https://github.com/shlomikushchi/alpaca-proxy-agent) |
7374

7475
## REST
7576

alpaca_trade_api/stream2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ def __init__(
206206
self._base_url)
207207

208208
if self._data_stream == 'polygon':
209+
# DATA_PROXY_WS is used for the alpaca-proxy-agent.
210+
# this is how we set the polygon ws to go through the proxy agent
211+
endpoint = os.environ.get("DATA_PROXY_WS", '')
212+
if endpoint:
213+
os.environ['POLYGON_WS_URL'] = endpoint
209214
self.data_ws = polygon.StreamConn(
210215
self._key_id + '-staging' if 'staging' in self._base_url else
211216
self._key_id)

0 commit comments

Comments
 (0)