Hi! I am creating a service for calculating the profitability of a trader’s trade.
I need to calculate the profitability on historical data, and if it seems clear for the spot:
we take all deposits / withdraws, buy and sell orders and consider that we entered 1 BTC, bought 10 ETH, then sold for EOC, I can get a historical ticker for EOC in BTC and understand how much was spent and received. BTC is at this level, but how do you deal with margin trading?
For margin trading, there are load and interest involved. So similar to spot, you will have to query the loan, repay and interest history, then calculate the profit based on these data.