Is it okay to call kite.positions() API on every iteration inside the main algorithm loop (one iteration takes around 0.5 seconds)? It somewhat simplifies my code, But I keep getting connection errors for the positions API ( 502 bad gateway etc) every 30 minutes
No, it's not recommended to poll positions and holdings APIs. You can fetch it once and use the value throughout the program. This thread explains more.