oanda / v20-javascript

OANDA v20 bindings for Javascript
MIT License
66 stars 31 forks source link

Issue on transaction stream node, probably when the expected result data is larger #12

Open lukzard opened 4 years ago

lukzard commented 4 years ago

Oanda,

Please be informed that the "transaction stream" node raises the error below, and has been raised when the result set is larger than the usual, for example, on ORDER FILL.

Seems the python wrapper provided @oanda deals with this in a better way.

SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at /home/luciancapdefier/node_modules/@oanda/v20/transaction.js:8174:32 at /home/luciancapdefier/node_modules/@oanda/v20/context.js:137:33 at Array.forEach (<anonymous>) at IncomingMessage.<anonymous> (/home/luciancapdefier/node_modules/@oanda/v20/context.js:134:32) at IncomingMessage.emit (events.js:219:5) at addChunk (_stream_readable.js:332:12) at readableAddChunk (_stream_readable.js:307:11) at IncomingMessage.Readable.push (_stream_readable.js:241:10) at HTTPParser.parserOnBody (_http_common.js:126:24) at TLSSocket.socketOnData (_http_client.js:467:22) at TLSSocket.emit (events.js:219:5) at addChunk (_stream_readable.js:332:12) at readableAddChunk (_stream_readable.js:307:11) at TLSSocket.Readable.push (_stream_readable.js:241:10) at TLSWrap.onStreamRead (internal/stream_base_commons.js:185:23)

See json response that caused the error. As mentioned, this is larger than the rest. { "id": "727", "time": "2019-12-16T07:18:35.828606829Z", "userID": nnnnnnnnnnnnnn, "accountID": "nnnnnnn-nnnnnn-nnnnn", "batchID": "727", "type": "ORDER_FILL", "orderID": "726", "instrument": "BCO_USD", "units": "7500", "gainQuoteHomeConversionFactor": "1", "lossQuoteHomeConversionFactor": "1", "price": "65.579", "fullVWAP": "65.579", "fullPrice": { "type": "PRICE", "bids": [ { "price": "65.548", "liquidity": "5000" }, { "price": "65.546", "liquidity": "5000" }, { "price": "65.543", "liquidity": "5000" }, { "price": "65.540", "liquidity": "5000" }, { "price": "65.534", "liquidity": "5000" } ], "asks": [ { "price": "65.578", "liquidity": "5000" }, { "price": "65.580", "liquidity": "5000" }, { "price": "65.584", "liquidity": "5000" }, { "price": "65.587", "liquidity": "5000" }, { "price": "65.592", "liquidity": "5000" } ], "closeoutBid": "65.534", "closeoutAsk": "65.592" }, "reason": "MARKET_IF_TOUCHED_ORDER", "pl": "0.0000", "financing": "0.0000", "commission": "0.0000", "guaranteedExecutionFee": "0.0000", "accountBalance": "97139.9383", "tradeOpened": { "tradeID": "727", "units": "7500", "price": "65.579", "guaranteedExecutionFee": "0.0000", "halfSpreadCost": "120.0000", "initialMarginRequired": "49172.2500" }, "halfSpreadCost": "120.0000" },