Closed xanoinc closed 2 years ago
Good catch.
I have been swamped with my current project lately but I will get to this by end of week!
I think I may have fixed this in stream.ts. So far this appears to work.
this.connection.onmessage = async (event) => {
let data = event.data
if (data instanceof Blob) {
data = await event.data.text()
}
let parsed = JSON.parse(data), messages = this.params.type == 'account' ? [parsed] : parsed;
Will try your fix out.
Just tested your fix, works great! Thanks for the contribution, version 6.2.2
has this update implemented.
@117 @seanmetrix The Blob
type doesn't exist in Nodejs, only the browser. So this breaks any attempt to access the stream.
@117 You need to add the following maybe?
import { Blob } from "node:buffer";
@FallingSnow @awweather This should be resolved in 6.2.6
.
Description When using type account for AlpacaStream it complains about malformed json.
I did some research and it looks like according to the documentation, the account stream uses binary frames for the paper api while the live stream uses text frames. I'm not sure why, but that seems to be causing an issue.
See note from - https://alpaca.markets/docs/api-documentation/api-v2/streaming/
Expected
Expecting paper support to work just like normal support.
Reproduction Steps we can take to reproduce the bug:
Just create a stream using a paper account and trade_updates channel and it will complain about bad json
Logs If applicable, add logs to help explain the bug.
Additional Add any other context about the problem here.