I’m getting this “unsupported operand type(s) for +=: ‘dict’ and ‘bytes’” when trying to send the authenticate action.
Here’s my code:
import alpaca_trade_api as tradeapi
from alpaca_trade_api import StreamConn
import time
import websocket
ALPACA_BASE_URL = "https://paper-api.alpaca.markets";
ALPACA_API_KEY = 'KEY'
ALPACA_SECRET_KEY = 'KEY'
STREAMING_ENDPOINT = "wss://data.alpaca.markets/stream"
stream = websocket.WebSocket()
trade = tradeapi.REST(ALPACA_API_KEY, ALPACA_SECRET_KEY,
ALPACA_BASE_URL, api_version = 'v2')
stream.connect(STREAMING_ENDPOINT)
stream.send({
"action": "authenticate",
"data": {
"key_id": ALPACA_API_KEY,
"secret_key": ALPACA_SECRET_KEY
}
})
trade.submit_order("AAPL", 3, 'buy', 'market', 'day')