Optimizing Execution Time: Improving TradingView to Interactive Brokers Delay with AWS Cloud
When deploying the TBOT application on the AWS Cloud, it receives Webhook messages from TradingView PineScript and places orders using the IB Insync API to Interactive Brokers. However, the overall execution time from TradingView to Interactive Brokers was significantly high.
Background:
When deploying the TBOT application on the AWS Cloud, it receives Webhook messages from TradingView PineScript and places orders using the IB Insync API to Interactive Brokers. However, the overall execution time from TradingView to Interactive Brokers was significantly high.
One specific bottleneck was the delay in the arrival time of TradingView's webhook to the Nginx/Flask server (represented by the red box in the image) which took around 500ms.
Initially, an Amazon AWS EC2 T2.Small instance located in London was used. However, this approach had its drawbacks.
Solutions:
To address this issue, I investigated the IP addresses used by TradingView's webhook servers and added them to the firewall whitelist. The IP addresses are as follows:
- 52.89.214.238
- 34.212.75.30
- 54.218.53.128
- 52.32.178.7
Further information and verification can be found on TradingView's website: Link to TradingView's Information
After analyzing the situation, it was discovered that TradingView utilizes Amazon AWS for its webhook servers, which are located in Oregon, United States.
As a solution, the AWS EC2 instance was relocated from London to Oregon, resulting in a significant reduction in the delay from TradingView to the webhook servers. The delay was now reduced to approximately 100 milliseconds.
To run TBOT on TradingBoat directly on a cloud computer, it is important to understand the architecture. The process of launching TBOT on TradingBoat can be initiated through Docker.
For detailed instructions on setting up a simple and fast trading robot using Docker and TradingView, please refer to the following Udemy course: Link to Udemy Course.