arbbot
arbbot copied to clipboard
TradeMatcher sometimes uses the wrong price when settling transactions, leading to incorrect P&L calculations
See this screenshot for example:
https://files.gitter.im/Exalovic/NggS/image.png
Here is an analysis of the problem:
- the Bleutrade API has a very similar setup where it has two separate calls one returns you a list of orders and the other returns you the individual trades in a given order
- when we want to compute the currency changes before/after the trades that we print out to the logs, use the total BTC price returned from these APIs and you will note that both are the same here
- so it doesn't matter which one you use
- but when calculating the profit and loss, we look at the price from the first table and multiply that by the amount
- we mistakenly assume that if the order is filled with a different price the API will correctly return that different price to us but Bleutrade violates this assumption
- and this causes some of the P&L calculations where Bleutrade has been involved to be incorrect
It seems that the issue here may not be limited to Bleutrade. At any rate the fix won't be exchange specific.