-
Notifications
You must be signed in to change notification settings - Fork 18
Home
Although Interactive Brokers might not have built-in back-testing or forward-testing capabilities, these features can be incorporated using the strategy or indicator tools on TradingView.
TradingView can generate alert messages based on specific trading strategies, which are then sent to a trading bot. This bot subsequently transmits orders to Interactive Brokers, creating a dynamic and efficient trading ecosystem.
You can visualize the concept of the Trading Robot in the green rectangle in the image that follows.
TradingView dispatches alert messages using the HTTPS protocol. To receive these alert messages, the trading bot needs an HTTP server. Upon receiving the alert messages, the trading bot decodes them and places orders with Interactive Brokers accordingly.
In summary, the Trading Robot should comprise at least three parts:
- HTTP server
- Decoder for alert messages
- Order Placement tools using TWS API or ib_insync API over IB Gateway or TWS workstation
Additional features including a reverse proxy, message brokers, and messaging applications can make the Trading Robot design more robust and modular.
We can visualize the platform as shown in the image below.
The most straightforward way to test the TBOT application is by integrating it into the TradingBoat platform using Docker.
TradingBoat is a trading platform that receives orders from TradingView Webhook and places them into IB Gateway or TWS. The platform can use NGROK, Flask(TVWB), Redis, TBOT(ib_insync), and IB Gateway.
When you install the Docker TradingBoat, TBOT is automatically installed as well.
To start, clone the repository:
git clone https://github.com/PlusGenie/ib-gateway-docker
Copy dotenv into the root directory:
cd ib-gateway-docker
cp stable/tbot/dotenv .env
Open the dotenv file using a text editor and update the values of:
TWS_USERID: The account name used to log in to TWS / IB Gateway
TWS_PASSWORD: The password used to log in to TWS / IB Gateway
VNC_SERVER_PASSWORD
NGROK_AUTH: Authentication Token for NGROK as needed. (optional)
Once these steps are complete, you can run Tbot on Tradingboat Docker using the following command:
docker-compose up --build
For a detailed installation guide for The docker TraingBoat, please refer to
GitHub - PlusGenie/ib-gateway-docker: Interactive Brokers Gateway Docker
The complete source code repositories for the components inside TradingBoat are also available as follows:
-
TBOT application: GitHub - PlusGenie/tbot-tradingboat
-
Customized TVWB (Flask) for TradingBoat: GitHub - PlusGenie/tradingview-webhooks-bot: Customized TradingView Webhooks Bot
-
PineScript's TBOT library: PineTradingbotWebhook — Library by AlphaCentauri66367
-
PineScript examples using the TBOT library: GitHub - PlusGenie/tbot-pinescripts
For a user-friendly video tutorial, I highly recommend referring to the comprehensive Udemy course available here: Link to Udemy Course.