Mathematically Improve Your Trading Strategy: An In-Depth Guide

The Most Important Guide for All Traders in 2024

Austin Starks
DataDrivenInvestor

--

The Category 3 Trader, generated by DALL-E

I used to be a Category 1 trader. You see, in this world, there are 3 types of traders. Category 1 is The Uninformed Investor, or the WallStreetBets Yoloer. These traders ride the waves of popular opinion, often finding their strategies in the most upvoted posts on forums like /r/WallStreetBets. Their approach is akin to gambling, relying more on luck than analysis. They lose money consistently, and never seem to learn from their mistakes; they blame “the Market Makers” for “rigging the market against them”.

Eventually, realizing that I’d have better luck going to Vegas, I evolved into a better trader. Let’s call it Category 2: the independent systematic trader. Oftentimes, these types of folks used to be WallStreetBets Yoloers, but have learned the hard way that following the crowd doesn’t work. These traders often maintain trade journals, reflecting on their decisions to improve future strategies. Embracing technology, they often use APIs for efficient trading. However, when faced with unpredictable market movements, emotions can still cloud their judgment, leading to panic-driven decisions and regret when the market eventually stabilizes.

Many people quit after this stage because they are still unprofitable. But those that make it through evolve to the final category of traders: Category 3: the algorithmic trader. This trader doesn’t just use computers to execute their trades; they use computers to formulate them. They understand strategy optimization, how to prevent overfitting, and how to make their strategies generalizable. They understand that the best way to beat the market is to have a rigourous systematic approach. They use backtesting to confirm their hypothesis, and then paper-trade after they think they’ve developed an edge. When their portfolio drops suddenly, they don’t panic, because they understand that it’s mathematically impossible to win every single trade. These are the traders that are profitable when the year ends.

There’s a common misconception that you have to be a MIT PhD student to become an algorithmic trader. But this is far from true. Thanks to the advent of Large Language Models, anybody with a computer and wifi and learn to become an algorithmic trader. This article will show you exactly how.

Using Advanced Algorithms To Your Advantage

There is not a single trader on Wall Street browsing Reddit to inform their decisions. Traders that are actually profitable are utilizing advanced algorithms to craft, improve, and deploy their trading strategies. It’s finally true that retail investors have access to these same type of algorithms.

NexusTrade is a platform that brings WallStreet-like tools to retail investors. By creating a free account, users can perform financial research, craft algorithmic trading strategies, and deploy those strategies live to the market. However, the purpose of this article isn’t to show all of NexusTrade’s amazing features; it’s to show how to use mathematics to to improve your trading strategy. The best part is, you don’t need a PhD in math to understand.

You see, NexusTrade offers a unique feature that other similar platforms don’t offer: its genetic optimization engine. “Genetic Optimization” is a unique, biologically-inspired AI algorithm that’s capable of finding amazing, diverse solutions in a sea of potential candidates. It works by using computation to mimic the process of natural selection — the way real-world organisms adapt and evolve in their environment.

For more information about Genetic Algorithms in general, check out the following article:

For details on how these algorithms work under the hood, check out this article:

NexusTrade makes utilizing these genetic algorithms simple for everybody, even non-technical users. Let’s see how.

The Algorithmic Trader’s Secret Weapon: Trading Strategy Optimization

Genetic algorithms take your current portfolio of strategies and improves it based on historical data. Users can configure how they want these algorithms to work on their portfolio within NexusTrade’s easy-to-use UI.

There are A LOT of configuration options available. For 90% of use-cases, the default options will work fantastically. However, for the savvy algorithmic trader, I’m going to explain what each of these configuration options do to the optimization process.

The Genetic Optimization Configuration in NexusTrade

The Date Range

To start, let’s look at the start date and end date. This defines the range that the genetic optimization will act under. If the user thinks that more recent data is relevant for their portfolios, they can choose a narrow start and end date. If the user thinks all available data is relevant, they can choose a wider range. NexusTrade gives the users flexibility to optimize over what time period they want.

Our Population Characteristics

Next is the population size and the number of generations. These attributes dictate how many new portfolios will be generated, and how long the optimization process will occur for. The bigger these numbers are, the more computation that these portfolios will undergo. That means it’ll take longer for the optimization process to terminate. However, theoretically, we should generate better solutions the longer this optimization runs for.

Out-thinking Overfitting

Now, let’s talk about number of windows. This configuration option is useful for trying to prevent the weakness of all optimization algorithms: overfitting. With number of windows, we split the training set with this variable, and perform an average over the performance of each window. In contrast, the traditional approach is to maximize the performance over one giant window; which is great for backtesting, but tends to fall short in real-world trading. By segmenting our training set into windows, we reduce the liklihood of overfitting and improve the chances that are portfolio’s performance translates into real-world trading.

Initial positions is another tool in our overfitting-prevention toolbox.

The different options for “Initial Positions”

When running a genetic optimization, we run backtests on historical data. The positions in those backtests can be configured: we can choose to copy the same positions that our portfolio has right now (All), make the portfolio start with no positions (None), or we can choose to randomize our initial positions. Each option serves a different use-case, and the savvy trader might pick a different option depending on current market conditions.

Improving Our Population

Next, we have two special options that affects our population. Elitism rate defines how many of our best individuals will automatically make it to the next population. Typically, because genetic algorithms favor elite individuals, we don’t need this number to be particularly high, and the higher it is, the more likely it is for our population to converge prematurely.

Next is spontaneous generation rate. In genetic optimization, typically all new individuals are born from their parents, just like in the real-world. Spontaneous generation is a unique option that allows us to generate a completely random individual de novo. This individual will then be added to the population. This is a way to increase the diversity of our population, and continuously add new individuals by increasing our potential solution space. However, genetic algorithms work by continuous improvement, and thus, this number typically doesn’t exceed 10% of the population.

Next we have our mutation parameters: mutation rate and mutation intensity. Mutation rate defines the probability that a new individual will experience a mutation. Think of it as a random variation in the strategy. Mutation intensity defines how strong a mutation is if it occurs. A high intensity will completely change a parameter in the individual semi-randomly, while a low intensity will only make small changes in an individual, as if nothing had occurred at all. These parameters are also useful to improve the diversity of a population.

We’re almost done! Stick with me here! If you find this article useful so far, please give it a round of applause, and share it on your personal social media account!

The Statistician’s Secret Weapon

Next we have one of the most important metrics to measure if our strategies are overfitting: the train/validation set ratio. This ratio defines what percent of our data will be in the training set, the part of the optimization that we use directly use, and what percent will be in the validation set, the part of the optimization that isn’t used to train our portfolios. Typically, if our training set has high performance by our validation set has low performance, that’s a signal that our portfolios are overfit, and won’t translate well for real-world trading. If our validation set performance matches our training set performance, then we have more confidence that our portfolios will perform well in real-world trading.

Our Fitness Functions

The last configuration option available to NexusTrade users is the most important: out fitness functions.

Fitness Functions in the NexusTrade platform

When optimizing our portfolio, we have to make a decision: how will we optimize it? What is important to reach our goals? Should we focus on improving our percent gain, and earning the most amount of money possible? Or, should we focus more on minimizing our drawdown, so we don’t lose the money that we gained? NexusTrade gives users the flexibility to perform multi-objective optimization, which means we can select as many fitness functions as we want. Typically, we tend to select 2, but with larger population sizes, we can get away with selecting 3 or 4.

These fitness functions tell us exactly how our new portfolios will be better than our original portfolios. They allow us to customize the optimization process to be tailored for our unique goals. This is what makes the NexusTrade platform so dang powerful.

Summary and Conclusion

Most traders never make it past Category 2. Before the advent of Large Language Models, it was nearly impossible for a non-technical trader to utilize these advanced algorithms for their portfolios.

Yet, NexusTrade makes this process seamless. Users can create, update, and optimize their trading strategies easily, in a no-code user interface. It’s free, fun, and powerful, and other platforms lack the power that NexusTrade offers.

NexusTrade offers a paradigm shift in how traders approach the market. Gone are the days where you’re hopping on WallStreetBets to gamble your money away. It’s time to take your trading to the next level, and use sophisticated algorithms to your advantage.

🤝 Connect with me on LinkedIn

👨‍💻 Explore my projects on GitHub

📸 Catch me on Instagram

🎵 Dive into my TikTok

Visit us at DataDrivenInvestor.com

Subscribe to DDIntel here.

Have a unique story to share? Submit to DDIntel here.

Join our creator ecosystem here.

DDIntel captures the more notable pieces from our main site and our popular DDI Medium publication. Check us out for more insightful work from our community.

DDI Official Telegram Channel: https://t.me/+tafUp6ecEys4YjQ1

Follow us on LinkedIn, Twitter, YouTube, and Facebook.

--

--

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