Open amitreddy opened 11 years ago
I noticed this as well. I documented it in the support forum.
http://www.sitepoint.com/forums/showthread.php?1174017-Is-there-a-problem-with-exchange-js
What needs to be done is change the conditions of the while loop.
I will fork and pull request.
While running the Chapter 2 code. I found that the code in func "order" would trade any remainingvolume at the best available opp price irrespective of the actual order price. I am not an expert on "Trading" but based on the write up in the book the price check seems to be missing. I added the following and the code works as I expect it should:
var bestOppPrice = oppBook.prices.peek(); var bestOppVol = oppBook.volumes[bestOppPrice]; if (orderType == BUY && bestOppPrice > price) { console.log("break for buy");
break; } else if (orderType == SELL && bestOppPrice < price) { console.log("break for sell"); break; }