Sort:  

which is also feasable in dynamic, in the script. Using some API to know instant prices

Very dangerous though. A sudden error in the API or a quick wick up or down and things could go horribly wrong. Averaging is better.