Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Hosting OpenAlgo in the Cloud using Amazon AWS Elastic Beanstalk

3 min read

OpenAlgo is an open-source algo trading platform, offering a wide range of features for both beginners and experienced traders. This blog post guides you through the process of hosting OpenAlgo in the cloud using Amazon AWS Elastic Beanstalk.

Prerequisites:

  • An Amazon AWS account
  • VS Code (or any code editor with Git installed)
  • A hosting account with DNS management and custom domain(Cloudflare is recommended)

Steps by Step Instruction to host OpenAlgo in Amazon Cloud with custom domain

Clone the OpenAlgo Repository:

    Configure the .env File:

      • Open the sample.env file in the OpenAlgo project.
      • Right-click and rename it to .env.
      • Update the REDIRECT_URL to your custom domain.
      • For example, if your custom domain for angel trading account is opendash.app, update it to https://opendash.app/angel/callback.
      • If you’re not using HTTPS, use http://openalgo.app/angel/callback.
      • Make sure to update the HOST_SERVER to your custom domain as well as shown in the video.
      • You might also want to update the BROKER_API_KEY and BROKER_API_SECRET according to your broker credentials.
      • Save the changes.

      Create the Elastic Beanstalk Application:

        • Go to the AWS Management Console and sign in.
        • Select the desired region (e.g., Asia Pacific (Mumbai) ap-south-1).
        • Search for “Elastic Beanstalk”.
        • Click on “Create application”.
        • Provide an application name (e.g., openalgo) and an environment name (e.g., openalgo-env).
        • Ensure the domain name is available (e.g., openalgo.ap-south-1.elasticbeanstalk.com).
        • Provide a description for your environment (optional).
        • Select “Python” as the platform and choose the “Python 3.11” platform branch.
        • Select “4.1.0 (Recommended)” as the platform version.
        • For “Application code”, choose “Upload your code”.
        • Give a version label (e.g., 1.0.0.1).
        • Choose “Local file” for “Source code origin”.
        • Select the zipped OpenAlgo project file you created earlier.
        • Choose “Single instance (free tier eligible)” as the configuration preset (or choose “Custom configuration” for more options).
        • Click on “Next” to proceed.

        Configure Service Access:

          • Select the existing service role you created earlier.
          • If you don’t have one, click on “Create and use new service role”.
          • Select your EC2 key pair (e.g., test).
          • If you don’t have an EC2 key pair, click on “Choose an EC2 key pair” and create a new one.
          • Select the existing EC2 instance profile (e.g., “aws-elasticbeanstalk-ec2-role-flaskenv”).
          • If you don’t have one, click on “View permission details” and create a new instance profile.
          • Click on “Next”.

          Configure VPC Settings:

            • Select the default VPC. You can create a new VPC, if needed.
            • This is the virtual network where your Elastic Beanstalk environment will be deployed.

            Activate Public IP Address and Instance Subnet:

            • Ensure the Public IP address is enabled for your instance. This allows your application to be accessible from the internet.
            • Choose an instance subnet from your VPC.
              1. Configure Security Group:
              • By default, select the default security group.
              • This will allow your application to connect to the internet.
              • If you want to restrict access, you can create a new security group and add rules to control incoming and outgoing traffic.
              • Click on “Next”.

              Configure Instance Type, Load Balancer, and CloudWatch Logs:

                • Choose an instance type (e.g., T3 micro, T3 Small).
                • If you are looking for a free tier option, use T3 micro.
                • Select “Single instance” if you don’t need a load balancer.
                • Choose “Enhanced” for health reporting (optional).
                • Choose the default settings for CloudWatch logs (optional).
                • Click on “Next”.

                Review and Submit:

                  • Review all the configuration steps.
                  • Make sure all the settings are correct.
                  • Click on “Submit”.
                  • This will initiate the automated provisioning of the servers in the backend.

                  After deploying your OpenAlgo application on Elastic Beanstalk, you need to configure your custom domain to point to the Elastic Beanstalk environment. This involves creating a CNAME record in your DNS settings. Here’s how to do it:

                  1. Access Your DNS Provider:

                  • Log in to your DNS provider (e.g., Cloudflare, GoDaddy, Namecheap, etc.)
                  • Find your domain’s DNS management section.

                  2. Create a CNAME Record:

                  • Click on “Add record” or similar to create a new record.
                  • Name: Enter the subdomain you want to use (e.g., trade). This will be the part of your custom domain that will point to your Elastic Beanstalk application (e.g., trade.openalgo.app).
                  • Type: Select “CNAME”.
                  • Value: Copy the Elastic Beanstalk domain generated by AWS. It will look something like this: openalgo.ap-south-1.elasticbeanstalk.com.

                  3. Save and Verify:

                  • Save the CNAME record you just created.
                  • Wait for the DNS propagation to complete, which may take some time (usually 24-48 hours).
                  • Test your custom domain by entering it into your web browser. You should be redirected to your OpenAlgo application on Elastic Beanstalk.

                  Example:

                  • Let’s say your custom domain is openalgo.app.
                  • You want to use the subdomain trade to access your OpenAlgo application.
                  • In your DNS settings, create a CNAME record with the following:
                    • Name: trade
                    • Type: CNAME
                    • Value: openalgo.ap-south-1.elasticbeanstalk.com (replace with your Elastic Beanstalk domain)

                  Once the DNS propagation completes, you’ll be able to access your OpenAlgo application at trade.openalgo.app.

                  SSL Configuration in Cloudflare

                  If you are using Cloudflare for DNS Management ensure to enable the flexible mode to access the openalgo domain with https SSL certificate.

                  By following these steps, you can successfully deploy OpenAlgo in the cloud using Amazon AWS Elastic Beanstalk. You can then start configuring your trading strategies and begin your algorithmic trading journey.

                  If you face any challenges or have any questions, feel free to leave a comment below.

                  Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

                  What’s New in the Latest OpenAlgo Version?

                  The latest release of OpenAlgo introduces a series of powerful features and improvements designed to enhance both the user experience and backend robustness. Whether...
                  Rajandran R
                  2 min read

                  Resolving SSL: CERTIFICATE_VERIFY_FAILED in OpenAlgo (Windows)

                  If you’ve encountered the SSL: CERTIFICATE_VERIFY_FAILED error while using OpenAlgo on Windows, there’s good news. A user from the OpenAlgo community has shared a...
                  Rajandran R
                  1 min read

                  Short-Term Roadmap for OpenAlgo (Jul – Sep 2024)

                  At OpenAlgo, we are dedicated to revolutionizing the trading experience by providing a powerful, multi-broker trading terminal that supports both manual and automated orders....
                  Rajandran R
                  2 min read

                  Leave a Reply

                  Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More