Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: alpaca-trade-api-python/examples/websockets/v2_example.py --> stream.subscribe_trade_updates Failed to authenticate #617

Open
2 tasks done
frenchthibaut opened this issue May 7, 2022 · 1 comment

Comments

@frenchthibaut
Copy link

frenchthibaut commented May 7, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

`import logging
import config

from alpaca_trade_api.stream import Stream

log = logging.getLogger(name)

async def print_trade(t):
print('trade', t)

async def print_quote(q):
if q["x"] == "FTXU":
print('quote', q)

async def print_trade_update(tu):
print('trade update', tu)

async def print_crypto_trade(t):
print('crypto trade', t)

def main():
logging.basicConfig(level=logging.INFO)
feed = 'iex' # <- replace to SIP if you have PRO subscription
stream = Stream(key_id=config.API_KEY,secret_key=config.SECRET_KEY,data_feed=feed, raw_data=True)
stream.subscribe_trade_updates(print_trade_update)
stream.subscribe_trades(print_trade, 'AAPL')
stream.subscribe_quotes(print_quote, 'IBM')
stream.subscribe_crypto_trades(print_crypto_trade, 'ETHUSD')
stream.subscribe_crypto_quotes(print_quote, 'ETHUSD')

@stream.on_bar('MSFT')
async def _(bar):
    print('bar', bar)

@stream.on_updated_bar('MSFT')
async def _(bar):
    print('updated bar', bar)

@stream.on_status("*")
async def _(status):
    print('status', status)

@stream.on_luld('AAPL', 'MSFT')
async def _(luld):
    print('LULD', luld)

stream.run()

if name == "main":
main()
`

Expected Behavior

In the provided example, all functions work as expected but "stream.subscribe_trade_updates".
It gives the following error:

INFO:alpaca_trade_api.stream:started trading stream
INFO:alpaca_trade_api.stream:starting trading websocket connection
ERROR:alpaca_trade_api.stream:error during websocket communication: failed to authenticate

SDK Version I encountered this issue in

alpaca_trade_api version 2.1.0

Steps To Reproduce

run stream.subscribe_trade_updates

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

No response

@AleFestante
Copy link

Have you ever resolved this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants