Great questions!
My apologies for not making these points clear.
‘percentageDiff’ is calculated based on prices only. It’s the percentage difference between the price at the last operation you made and the price “now”.
Your total balance will only be used to determine how much of an asset to buy or sell.
As for when an operation executes, the API will generally return to you some orderId and/or some details. I should have made this clear, although it’s hard to assert with certainty since different APIs will return different things.
But essentially, once an operation executes, you’ll either get the price back for it from the API, or you store it yourself when you make the call, or the API will return an id that you can use to query for the price at execution.
Does this answer your questions? Feel free to ask more questions if you want.