To be clear, the problem is with the web stream, not a regular request to place an order.
The problem cannot be demonstrated with just a regular request, payload and response.
The expectation is that the currency pair received in a trade event message, notified via a web socket should match the currency pair specified in the request to create the order.
It does not. It is not backwards compatible when using a web socket to listen to trades
Code to create a web socket and listen to trade events is similar to below -
socket = new WebSocket(“wss://paper-api.alpaca.markets/stream”);
// Helper method to convert binary stream data to text
const binaryToString = (buf: any): string => String.fromCharCode.apply(null, new Uint16Array(buf));
const auth = { action: ‘authenticate’, data: { key_id: process.env.API_KEY, secret_key: process.env.SECRET_KEY, } };
const onTradeEvent = async (event: any) => { const message = binaryToString(event);
console.log(message);}
socket.once(‘open’, () => { socket.send(JSON.stringify(auth)); socket.on(‘message’, onTradeEvent); });
Sample event message received
Notice the currency pair. received It is ETH/USD ( the new format, forward slash) This is despite the order using the legacy format of ETHUSD (old format, no forward slash)
It is not backward compatible when using a web stream to listen to trade events.
{“stream”:“trade_updates”,“data”:{“event”:“fill”,“execution_id”:“e677fdbc-d1d6-445f-a439-65b1f063ef8e”,“order”:{“asset_class”:“crypto”,“asset_id”:“a1733398-6acc-4e92-af24-0d0667f78713”,“cancel_requested_at”:null,“canceled_at”:null,“client_order_id”:“0e379e92-33b2-4a10-b916-17ebc96e4b52=2-false”,“created_at”:“2022-07-28T21:26:30.87603913-04:00”,“expired_at”:null,“extended_hours”:false,“failed_at”:null,“filled_at”:“2022-07-29T01:26:30.937119008Z”,“filled_avg_price”:“1719.8”,“filled_qty”:“0.1”,“hwm”:null,“id”:“d9d9db5c-9314-49d2-9148-a37b90aa9503”,“legs”:null,“limit_price”:null,“notional”:null,“order_class”:“”,“order_type”:“market”,“qty”:“0.1”,“replaced_at”:null,“replaced_by”:null,“replaces”:null,“side”:“buy”,“status”:“filled”,“stop_price”:null,“submitted_at”:“2022-07-28T21:26:30.87478825-04:00”,“symbol”:“ETH/USD”,“time_in_force”:“day”,“trail_percent”:null,“trail_price”:null,“type”:“market”,“updated_at”:“2022-07-28T21:26:30.938998823-04:00”},“position_qty”:“0”,“price”:“1719.8”,“qty”:“0.1”,“timestamp”:“2022-07-29T01:26:30.937119008Z”}}