Let’s Create, Backtest, Optimize, and Deploy a Fully Automated Algorithmic Trading Strategy

Austin Starks
6 min readMay 13, 2023

--

The step-by-step guide on how to do automated investing in 2023

Conversation between a user and an AI Chat Bot

Overview

Algorithmic trading used to be hard. At the very least, if you wanted to create a trading strategy, you needed proficiency in Python and familiarity with libraries such as NumPy, Scikit, and Matplotlib. For more complex tasks such as multiobjective optimization or Monte Carlo tree search, strategies needed to be ported into C++, which is notorious for its difficult learning curve. Most importantly, the majority of your time is consumed by coding, rather than ideating, evaluating, and testing trading strategies.

I noticed this as an issue in around 2020. I tried other trading platforms, but most of them felt archaic, rigid, or lacking in functionality. So, I decided to fix this problem on my own. My first attempt at this resulted in the open-source platform NextTrade. While it has several extremely powerful features, such as multi-objective optimization and the ability to configure simple trading strategies, it was slow and lacked configurability.

My experience developing NextTrade has given me the ability to create a next-generation trading platform. NexusTrade was built to express any conceivable idea without a coding interface. The platform simplifies the process of creating, evaluating, and optimizing a strategy without sacrificing expressivity or performance, and it does so on a modern, easy-to-use UI. Today, I’m going to walk you through the process of configuring a trading strategy in NexusTrade.

Creating a Trading Strategy

The Navbar for NexusTrade. You can navigate to the AI Chat, Your Portfolios, and the NexusTrade Roadmap

Head over to https://nexustrade.io/chat. After you created an account, you should be redirected to the chat page. If this does not occur, you can manually select the AI Chat from the page header.

The AI Chat provides the most straightforward path to strategy creation. Here, you can describe your trading ideas to the AI, which subsequently translates your strategy from natural language into a format the application can interpret. For example:

You can describe your portfolio by giving it a name, an initial value, and a list of strategies

You can tell the chat to configure pretty much any conceivable idea. This includes compound conditions (A and B) and compound indicators (a + b). Presently, strategies are limited to technical indicators, such as Simple Moving Average, Relative Strength Index, Rate of Change, and an Asset’s Price.

Aside: What new features are coming soon?

  • Support for options and crypto is planned for the near-term.
  • More technical indicators like MACD, Pivot Point Standard, and Number of consecutive up/down days are on the roadmap
  • Fundamental indicators like revenue, income, and historical dividend yield are coming soon
  • Creating portfolios with 10+ strategies at once, or creating multiple portfolios simultaneously is not yet implemented in the AI Chat

It’s important to note that while these features aren’t implemented, the system’s architecture 100% supports them. If you want other features, you can add it to the Roadmap or reach out to me on Instagram.

Performance Evaluation

You can assess the strategy’s performance directly in the chat. Instructing the AI to backtest the portfolio will prompt it to generate a backtest. For example:

Telling the AI to backtest the portfolio will result in it creating a backtest

Clicking View Backtest will provide a detailed overview of the results.

These are the results of this strategy from June 2018 to now

Let’s say you are happy with the strategy you created, but wanted to improve your performance. How could we do this?

Optimize a strategy with a genetic algorithm

Returning to the chat, select View Portfolio and Save on the portfolio we previously created.

You can view the exact configuration of the portfolio it generated

Go to the Portfolio you just saved by clicking Portfolios (in the header) and then navigating to the name of the portfolio you just created.

You can navigate to your portfolios from the navbar

From here, you should see a screen that looks like this:

The Portfolio Dashboard lets you edit, create, backtest, and optimize your portfolio

Click on the Optimizer, and check out how we can configure our multi-objective optimization.

The Optimizer page lets you create a new optimization and view your past optimizations

Despite the myriad of configurability options available, for simplicity, let’s alter only the population size and the number of generations.

After around 2 minutes, you’ll notice that the average performance of the population tends to increase over time.

The Optimization Details Page gives details of our genetic optimization

We can run an optimization for as long as we want. This optimization process generates a population of portfolios that outperform the original one in various aspects. Some portfolios will exhibit a lower max drawdown, while others might display a better percent change. Many portfolios will demonstrate improvements in both. Each portfolio (and its associated backtest performance) are what we call an “optimization vector”.

An Optimization Vector is a portfolio, its strategies, and the performance of its last backtest

Let’s click on the strategies of an optimization vector.

Details of an optimization vector

From here, we can see the exact details in the change of the portfolio. If we wanted to update our portfolio from an optimization vector, we can just scroll all the way down, and click Edit.

Clicking Edit will replace your current portfolio with the optimized portfolio

Performance Evaluation of the Optimized Portfolio

Now that we have an optimized portfolio, it’s time to assess its performance. Click the backtest button and do from June 2018 to present day. Here are the results:

Spoiler: The Optimized Portfolio Does Significantly Better

This is a considerable improvement over the original portfolio! To further improve this, we can incorporate more strategies, more complex conditions, better indicators, more diversified assets, and continue to optimize the strategy’s performance. Moreover, by being rigorous with our optimization approach and subdividing it into train/validation/test sets, we can refine our strategy until it meets our satisfaction.

Deployment of the Strategy

The last move is to deploy our strategy to the market in a few easy clicks. This can be accomplished through a few simple clicks: select Settings, Deployment, and then Start Trading to launch your strategy live. It’s really that easy!

You can edit the deployment configuration in the portfolio’s settings

Final Remarks

Algorithmic trading used to be hard. The idea that you have to know how to code to be an algorithmic trader is archaic and outdated — people trade in the market everyday and have no coding experience. At the same time, it’s unfair that only well-funded hedge funds and prop shops have access to these optimization tools and AI algorithms.

NexusTrade was born out of a need for a superior trading platform. You can choose to ignore it and continue coding your strategies in Python and waste hours debugging your segmentation fault in C++. Or, you can think of a good idea, configure it in seconds, test its performance, and continuously improve it a sleek, simple UI. The choice is up to you.

If you liked this article, please give it an applause and share it with your friends! You can also check out my other social media links below. Thank you for reading!

--

--

Austin Starks

https://nexustrade.io/ Highly technical and ambitious. Building a no-code algotrading platform and an ecosystem of AI applications. https://nexusgenai.io