question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Paper API trade_updates stream

See original GitHub issue

I noticed the Paper API websockets is not working. My live key authenticates to AlpacaStream, but I get the error below when I try to connect with my paper key:

Error: There was an error in authorizing your websocket connection. Object received: { "stream": "authorization", "data": { "action": "authenticate", "message": "access key verification failed", "status": "unauthorized" } }

I checked the urls.js in your code, the paper websockets endpoint is not there, so I figured either paper websockets trade_updates is probably not implemented or Alpaca made one of their confusing changes again. Paper and live accounts share the same wss endpoint for data (wss://data.alpaca.markets/stream), but the trade_updates for paper accounts is at this wss endpoint:

wss://paper-api.alpaca.markets/stream

I will appreciate if this can be integrated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
117commented, Nov 12, 2020

I’ve gone ahead and pushed a new version which has support for paper. You can now specify whether or not the credentials are paper when creating the AlpacaStream like below:

let stream = new AlpacaStream({
  credentials: {
    key: '***',
    secret: '******',
  },
  paper: true,
  stream: 'account',
})

stream.on('authenticated', () =>
  stream.subscribe(['trade_updates'])
)

stream.on('trade_updates', (data) => console.log(data))

Hope this helps! Just make sure you are on version 2.2.4.

1reaction
117commented, Nov 11, 2020

Thank you for letting me know, I’ll attempt to integrate this today. 😎

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streaming | Alpaca Docs
Streaming # Alpaca's API offers WebSocket streaming for trade, account, and order updates which follows the RFC6455 WebSocket protocol.
Read more >
Alpaca Trading API Guide - A Step-by-step Guide
The above code subscribes to account updates, trade updates, and the AAPL one-minute bar stream all from the same WebSocket connection. This is...
Read more >
Websocket streaming does not work with paper trading creds
The Alpaca websocket streaming API appears to have an issue that prevents paper trading credentials from being used to stream ...
Read more >
alpaca-trade-api 0.29 - PyPI
It allows rapid trading algo development easily, with support for the both REST and streaming interfaces. For details of each API behavior, please...
Read more >
I have this code using the alpaca websocket but there is a ...
conn = tradeapi.stream.Stream( key_id=api_key, secret_key=api_secret, base_url='https://paper-api.alpaca.markets', data_feed='iex' ).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found