Thanks for sharing your interesting findings. Some thoughts from my end,
1. If there are multiple bots already running on that exchange, it is possible that the corrections happen quickly in the exchange before our order gets executed. Might have to save on the time between fetching the price and placing the order.
2. I was forced to add a sleep timer between api calls due to limitations from the exchange. If your exchange allows it, then async calls should be a good option.
3. Another option that can be explored could be to pick the prices from the order book using the exchange apis directly instead of fetching the ticker prices and placing the orders based on it. There could be some discrepancy between the fetched ticker price and the actual traded value.
Thanks for the input on the smart contract. Sounds like a good option to explore.