Calculate profit

Hi this isn’t really connected with API but i don’t see any other forum where I could ask it. How do i calculate profit after paying fee? Also is there maybe some endopint that could do this or something similar? Also extra question, is It possible to calculate price for market order since the API returns 0 as response for set market order?

Example: Pair: ADA/USDT

Buy Order: Price: 0.3717, Filled: 37.6, Fee: 0.0376 ADA, Total: 13.97592 USDT

Sell Order: Price: 0.3721, Filled: 37.6, Fee: 0.01399096 USDT, Total: 13.99096 USDT

Ok I just got the error when sending the buy order caused by insufficient balance. So my guess that he value returned as response in buy order as “executedQty” is not the amount i get on my SPOT account, I will have to deduct fee from this?

Also extra question, is It possible to calculate price for market order since the API returns 0 as response for set market order?

Please consult How to get MARKET order's executed price in SPOT?
I believe now that you know the filled price, order quantity and the commission fee, you don’t have trouble calculating the final received quantity now (profit).