Launching a Trading Robot on the AWS Cloud (Terraform)

This guide provides instructions for launching a Trading Robot on the AWS cloud, specifically designed to connect TradingView with Interactive Brokers in just 5 minutes using Terraform.

Background

 

This guide provides instructions for launching a Trading Robot on the cloud, specifically designed to connect TradingView with Interactive Brokers in just 5 minutes using Terraform.

Prerequisites

 

Step-by-Step Guide

Step 1: Initialize Terraform

Clone the TradingBoat Terraform repository:

  
git clone https://github.com/PlusGenie/tradingboat-terraform.git
cd tradingboat-terraform/src/docker

  

Run terraform init to initialize Terraform, download the AWS provider, and prepare your environment for deployment.

  
    terraform init
  

Step 2: Terraform Configuration Files

  1. Create terraform.tfvars for TradingBoat Terraform and save it.
  2. Define variables in terraform.tfvars such as AWS region, instance type, AMI ID, and TradingBoat credentials.

Example of terraform.tfvars:

  
TWS_USERID="yourPaperAccountID"
TWS_PASSWORD="yourPaperAccountPassword"
NGROK_AUTH="2a60uMoemV6LGtDOcGWVH5HYFHv_YOUR_NGROM_AUTH"
aws_ALLOWED_IPS = ["90.192.XXX.1/32"]
aws_instance_type="t2.medium"
aws_region="eu-west-2"
aws_ssh_key_name="Terraform_TBOT" # SSH PEM File
  

Step 3: Plan Your Deployment

  • Execute terraform plan to preview the actions Terraform will perform. This step helps verify your configuration and shows what resources will be created on AWS.
  
    terraform plan
  

Step 4: Deploy TradingBoat

  • Execute terraform apply to initiate the deployment process. When prompted, type 'yes' to confirm and proceed with the action. Upon completion of the terraform apply command, Terraform will provide you with the Elastic IP address (YourInstancePublicIP) assigned to your AWS instance.
  
    terraform apply
  

5: Accessing TradingBoat

  • Find the Public IP: Terraform will output the public IP address of the EC2 instance.
  • Access TBOT Interface: Navigate to http://[YourInstancePublicIP]:5000 to access the TBOT interface.
  • Access via VNC Viewer: Connect to [YourInstancePublicIP]:5900 to access the IB Gateway through the VNC server.

Step 6: Managing Your Infrastructure

  • Monitor: Regularly check the AWS Console and Terraform logs to ensure your resources are running as expected.
  • Update: For changes, update your Terraform configuration files and run terraform apply again.
  • Destroy: Remove all resources with terraform destroy when no longer needed.

How to Access TBOT on TradingBoat

  • SSH into your AWS cloud:
  
ssh -i Terraform_TBOT.pem ubuntu@YourInstancePublicIP
  

How to Access Docker

  • Once connected to AWS EC2 via SSH, access your Docker containers. Refer to the chapter “Managing TradingBoat Components with DotEnv and tbottmux: A Comprehensive Guide" for detailed commands.
  • Ensure containers are running:
  
    tail -f /var/log/terraform-tbot.log
  
  • Access container: docker exec -it tbot-on-tradingboat bash

  docker exec -it tbot-on-tradingboat bash

How to Debug Tbot Terraform Logging

  • View logging messages: tail -f /var/log/cloud-init-output.log
  
    tail -f /var/log/cloud-init-output.log
  

Warning

  • This guide is for educational purposes only. Do not share your SSH key or use real Interactive Broker usernames and passwords.
  • Ensure you destroy your Terraform setup when not in use to avoid continuous AWS costs.
  • Note that running Docker Containers may be slower than running the native TradingBoat application. For native application setup, refer to the course book: Converting TradingView PineScript alerts into Interactive Brokers orders.

Further details and procedures, I highly recommend referring to the comprehensive Udemy course available here: Link to Udemy Course.

Subscribe to TBOT on TradingBoat

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe