arbbot icon indicating copy to clipboard operation
arbbot copied to clipboard

TradeMatcher sometimes uses the wrong price when settling transactions, leading to incorrect P&L calculations

Open cryptoeax opened this issue 8 years ago • 1 comments

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

cryptoeax avatar Jan 10 '18 18:01 cryptoeax

It seems that the issue here may not be limited to Bleutrade. At any rate the fix won't be exchange specific.

cryptoeax avatar Jan 10 '18 21:01 cryptoeax