So I am working on a bot (first time) that needs extremely accurate pricing, specifically market pricing, to the cent. Below is the code I am using to receive live trade data, and while I am getting what I need from this, the trade data compared to the market data on the dashboard once the trade my bot makes is made is all ways 1-5 cents off in either direction. Is there a way to get the market price directly from the dashboard or a more accurate way that won’t have this couple cents disconnect? Thank you!
url = ‘wss://stream.data.alpaca.markets/v2/iex’
ws = create_connection(url)
print(json.loads(ws.recv()))
auth_message = {“action”:“auth”,“key”: Secret.key, “secret”: Secret.secret_key}
ws.send(json.dumps(auth_message))
subscription = {“action”:“subscribe”,“trades”:[“{Whatever Stock}”]}
ws.send(json.dumps(subscription))
print(json.loads(ws.recv()))