We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1566c42 + a2187ed commit e9dfafbCopy full SHA for e9dfafb
alpaca_trade_api/stream2.py
@@ -39,11 +39,18 @@ async def _connect(self):
39
r = r.decode('utf-8')
40
msg = json.loads(r)
41
42
- if msg.get('data', {}).get('status') != 'authorized':
43
- raise ValueError(
44
- ("Invalid Alpaca API credentials, Failed to authenticate: {}"
45
- .format(msg))
46
- )
+ if msg.get('data', {}).get('status'):
+ status = msg.get('data').get('status')
+ if status != 'authorized':
+ raise ValueError(
+ (f"Invalid Alpaca API credentials, Failed to "
47
+ f"authenticate: {msg}")
48
+ )
49
+ else:
50
+ self._retries = 0
51
+ elif msg.get('data', {}).get('error'):
52
+ raise Exception(f"Error while connecting to {self._endpoint}:"
53
+ f"{msg.get('data').get('error')}")
54
else:
55
self._retries = 0
56
0 commit comments