I am working with the orders API trying to match up Buy and Sell orders to work out profit and loss.
I am trying to match the original order amount from the Buy order to the total calculated amount via the transactions of the Sell order inc the fees, but the figures are slightly out and thus are not matched.
Does anyone know of another method on how to much up buy/sell orders?
The most likely cause of this is the change in commission currency, I.e. when the order is a BUY the fee is in the long token while when it is a SELL it is in the short asset. E.g. Buy BNBUSDT and pay BNB in and USDT out. Running a transform to go fee*price on all buys might help.
When you open your order, give a custom clientOrderId, this way you will know in your tool when the websockets events come the full details of your orders. Then you can make link between your orders.