I am building a simple trading UI using alpacas API with NODEJS,
I am trying to register to a trade event so I would be able to get events on trade filled/closed etc but so far without any success.
I couldn’t find anything that would help me in the documentation…
so what I have so far is:
this.alpaca = new Alpaca({
keyId: keyId,
secretKey: secretKey,
paper: true,
})
this.websocket = this.alpaca.data_stream_v2
this.websocket.connect()
and then
this.websocket.subscribeForTrades(...symbol)
this.websocket.onStockTrade(function (trade) {
console.log(trade);
})
is this the right approach? or is there something different I could do.
any help would be appriciated!