Thursday, March 2, 2023

Realized profit in crpto (Improving Accuracy in Transaction Value Calculation)

In my previous post, I discussed how calculating the value of a transaction from different prices can be inaccurate. After much thought, I decided to switch to calculating from transactions as the only way to ensure accuracy.

To do this, I used Python to write a program that would perform the calculations. However, I encountered some challenges due to certain methods not making sense.

Firstly, I had to determine whether the transaction was a buy or a sell. If it was a sell, then I had to check all the previous buy transactions to determine the correct value. The priority was given to the buy price that was closest to the sell price (and positive when close). However, this approach had a bug problem and was not ideal. For instance, if I bought at prices 10, 12, 13, and 14 and sold at 14.1, my ideal system would sell from buy price 13. However, my program would sell at buy price 14 (including fees) as it was still positive.

To fix this issue, I tried adding an x value to fix the buy and sell variant. For example, if x = 1, my program would sell at buy price 13. Although this seemed to work, my program still had some bugs related to this.

In conclusion, I will continue to work on fixing these bugs to ensure the accuracy of my program. By calculating from transactions, I believe that it is possible to obtain more accurate results than by calculating from different prices.

 

 

 

 Link for my calculator : https://github.com/AdeptEinzbern/Realized-profit-in-trading

No comments:

Post a Comment