[URGENT] Buy order does not get placed through the API for the first time but works in the second time and later

When I place a buy order through the API, for the first time the code keeps running but if I interrupt the code and re-rerun it, order gets placed.

Am I doing something wrong? is there something missing? please let me know its urgent.

@amit44 Could you please share your code reference? You can either post the snippet here or upload your code to GitHub and share the link with us.