10 mistakes when it comes to (automated) trading & how to avoid them

blog photo
Joanne SnelOctober 6, 2021

Hi! My name is Joanne and I’m part of the lemon.markets team in Berlin. We’re building a brokerage API to enable developers to curate their own stock market experience. Along with that, we hope to foster an environment where users can find and share their knowledge on the intersection between algorithm development and the stock market, among other things. We want to contribute to this conversation as well, and that’s why we’ve gathered a list of ten mistakes that those beginning in automated trading (and, to be fair, sometimes even seasoned pros) might make. But, most importantly, we’ve also listed how you can avoid them. 

By reading this article, hopefully you will be aware of some of the biases that many investors in the automated trading world experience at one point — and with the proper tools, you can avoid falling into the trap yourself. 

Title Card for "10 mistakes when it comes to (automated) trading & how to avoid themI"

We’ve split these mistakes into two sections: the ones that can happen before your algorithm is live and the ones that may happen once your algorithm is up-and-running. This way, you’re prepared for the obstacles that may arise at any part of the journey that is creating your own strategy. 

Before you’re live ⏰

Prior to funnelling all your hard earned money into your algorithm (which would be mistake #1 😉), it’s a good idea to ensure your strategy is built on reasonable assumptions. You could delve into the theory, but often this isn’t enough as the practical market functions quite differently from what it should look like in theory. Often, it’s a good idea to also run some simulations to see how the strategy performs in the ‘real world’. Let’s see what some of the pitfalls in this process might be:

1. Blindly Copying Someone’s Code

Especially for those starting in automated trading, looking at the projects and strategies others are building is a great place to start. It’s also the reason why we’re constantly sharing our own lemon.markets projects, such as this article on the mean-reversion strategy. However, there’s a big difference between blindly copying someone else’s code and thoroughly understanding what the strategy is doing. And, even then, you might be exposing yourself to vulnerabilities you’re not aware of (due to, for example, running it in different market conditions than the author). After all, articles are regularly being published claiming they have a ‘winning strategy’, but if that’s the case, then there’d be a lot more millionaires. 💸

You can avoid this mistake by writing your own code, this way you’re aware of how it will (or should) react to different market conditions. It’s crucial to really iterate over an algorithm. Another hot tip: consistently comment your code — trust us, future-you and future-contributors (#opensource) will thank you.

2. Overfitting

If you’re basing your trading strategy off of historical data, then you need to be careful not to overfit your model. In other words, your strategy can’t perform too well in the testing phase. This might sound counterintuitive, but let me explain. If you construct a strategy that performs really well, that’s likely because you’re tailoring it specifically to the market for the duration of the test period. Another sign of ‘over engineering’ your strategy is using a lot of different predictors (to the point where you don’t understand what’s happening anymore). It’s likely that this would be fine-tuned to what the market did in the past, and not necessarily to what the market is doing today and tomorrow. 

This mistake can be avoided if you use an out-of-sample test to verify a trading system, by, for example, leaving the most recent year of data untouched. You should only perform tests on data that has been not used to build or train (in the case of machine learning) your strategy. Rather than backtesting (or even better, in conjunction with), you can also perform walk forward testing or paper trading. This means that you’re not just testing your strategy against past market conditions, but also against the current conditions. One drawback is that you cannot test your strategy against years of data at once, but rather have to work in a real-time context. However, there’s value in both approaches. 

3. Survivorship Bias

Survivorship bias is exactly what it sounds like — focusing only on the winners while blindly ignoring the (conditions of the) losers. With regard to automated trading, the ‘winner’ and ‘loser’ terminology can be applied in several contexts. For example, if you’re benchmarking the performance of your trading strategy against a market index, you need to make sure that your data set is complete. You should pay special attention that it is a representative picture of the market for the duration of your test period. This means including companies that no longer exist. If you ignore the stocks that went bust, you are overestimating the historical performance of the market and this might cause you to discard a decent trading strategy. In the same way, if you’re backtesting, you should make sure you do it on a complete dataset. In this case, your strategy would appear to work better than it actually does. 

Another way that survivorship bias might affect your trading: basing your research only on winning strategies. You might be taking on more risk that you’re aware of, or perhaps you’re implementing something which has consistently been unsuccessful. You can avoid falling into this bias by doing thorough research, keeping involved in the community (like our Slack community and blog), reading papers and remaining analytical. 

4. Not Factoring in All Costs

Whether you're back- or walk forward testing, you need to account for transaction fees, costs associated with liquidity, slippage, exchange fees and others. Depending on what you’re trading and where you’re placing your trades, these costs can add up pretty quickly. They can also make a profitable trade, no longer profitable. For this reason, it’s important to factor in these costs from the get-go and stimulate realistic market conditions as accurately as possible. 

You can obtain what these costs will be from your broker, but sometimes it can be hard to find exactly what/how much to expect. Luckily, when you use lemon.markets you do not have to worry about hidden costs — it’s our mission to remain transparent and affordable. In addition, our paper trading environment is, and will remain, free so you can always test your strategy extensively before you send it to production.

5. Look-Ahead Bias 

In designing your strategy, you should take into account whether certain relevant information is published at the time you are using it. You should not be making decisions based on information which is not yet available, and while this may seem obvious, it’s a fairly easy mistake to make when backtesting. Your strategy might be based on earnings reports or unemployment numbers, and these metrics have very specific release dates. For example, earnings reports are released quarterly. Retrospectively, you might know that company A performs poorly in Q3 of 2020 and you might adjust your trading strategy based on this information. If you are trading in real time however, you do not have access to this information while you are in Q3. Therefore, it’s important to be critical of the information you are using to build and backtest your strategy. 

If you’d like to read more about this bias, here is an interesting article.

Up-and-running 🏃

When your trading strategy goes live, there’s other things you need to keep in mind. Let’s explore those now.


6. No Stop Loss

All professional traders work with stop losses — they are there to help you mitigate risk by cutting large losses short. A sell stop market order is placed below the current market price to prevent too much loss on a sale, whereas a buy market order is placed above the current market level to buy a stock before the price increases too much. If you’re using lemon.markets, a market order can easily be made into a stop market order by simply providing an additional parameter (the stop price) when placing an order. This looks as follows:

1import json
2import requests
4    data=json.dumps({
5        "isin" : ISIN,
6        "expires_at" : EXPIRY,
7        "side" : BUY/SELL,
8        "quantity" : QUANTITY,
9        "stop_price" : STOP_PRICE,
10        "venue" : VENUE,
11        "space_id" : SPACE_ID}),
12    headers={"Authorization": "Bearer YOUR-API-KEY"})

In the above code snippet, anything that’s in all-caps should be replaced with the proper variables. 

7. Too Big, Too Soon 

While your strategy probably won’t move the market, it’s relevant to consider whether it can be scaled. And this might be a little difficult to determine in the backtesting stage, therefore it’s a good idea to slowly scale up your strategy (and definitely avoid investing all your capital at once) when it performs as you’d like. Also, to practice good risk management, you might want to set up certain limits, such as avoiding trades that are more than 1% or even 0.05% of your total capital.

At lemon.markets, we’ve created a framework that supports this, namely the concept of Spaces. We’ve written an extensive article about it, which can be read here. But if you’re interested in the quick run down: Spaces allow you to split your account into smaller sub-sections, meaning that you control exactly what percentage of your capital is allocated to a specific strategy. You can choose to add additional funds to a Space later on too. This means that you can run several strategies at once and determine exactly how much of your capital you want to expose to them. 

8. System Interference

For most people venturing into automated trading, one of the main goals is to systematically stick to a particular trading strategy and/or to quickly identify investment opportunities. If you have set up your strategy to your satisfaction and done the appropriate backtesting, then there’s no reason for you to interfere. You want to avoid getting emotionally involved. The trick here is to find a balance between monitoring your strategy (to ensure it’s still placing the trades you expect it to place) and allowing it to perform as you intended. Very often, people are risk averse, meaning that they might leave a losing strategy running longer than they should and cut a winning strategy short (to secure losses).

9. Forgetting Performance Measures

There’s a lot of ways to evaluate the performance of your trading strategy. The most obvious choice is to calculate profit like the yearly average percentage. But, you might want to look into, for example, the amount of risk (volatility) you’re exposing yourself to, the Sharpe ratio, the maximum drawdown, the amount of addition fees you’re incurring, the number of winning trades against the number of losing trades, the average size of wins versus losses, the holding time, etc. The list can go on and some measures might be more appropriate than others. But, focusing purely on profits will not serve as a holistic look at your strategy and its performance. 

10. Never Changing it Up

The truth is, automated trading is a dynamic field. If you find an edge in the market, chances are, you’ll have to adapt and update your strategy within the next six months. It might be due to trends in automated trading (others might find alpha in the same place you did) or changes in the market. It would be a big mistake to assume that upon finding a working strategy, your job is done. The solution? Keep up to date with developments in the automated trading world (join our Slack!) and keep monitoring the performance of your algorithm.

We’re curious, do any of these mistakes sound familiar to you? We hope that by illuminating these mistakes, you’ll be able to catch them before they happen to you. And if you’ve already experienced one or two, let us know in the comments and what you did to rectify them. 

If you’re not yet signed up with lemon.markets, be sure to do so. We’re looking forward to seeing you in the community. Any and all questions can be posted in our community Slack channel or emailed to support@lemon.markets. 

Looking forward to welcoming you on lemon.markets very soon 🍋


You might also be interested in

blog photo

Using Time Series Forecasting to predict stock prices 🔮

In this article you will learn what time series forecasting is and how its application in finance looks like. Then you'll also dive into Facebook's Prophet Model for Time Series Forecasting and use it together with the lemon.markets Market Data API to forecast the development of the Tesla Stock.

blog photo

Dummies Guide to Trading with Machine Learning

Ever wonder how a trader with decades of experience on thousands of stocks and lightning fast reaction times might perform in the market? With some machine learning knowledge, you might be able to automate such a trader yourself! 💻 📈

blog photo

4 reasons why YOU should automate your trading strategy

In the current volatile market conditions, everyone is trying to find ways to minimise portfolio loss. In that context, have you ever thought about automating your trading strategy? In this article, we will dive into 4 reasons for doing so. Expect to learn how it can save you time, make your trading more efficient and lead to data-based decisions.

Dive Deeper

Find more resources to get started easily

Check out our documentation to find out more about our API structure, different endpoints and specific use cases.


Interested in building lemon.markets with us?

We are always looking for great additions to our team that help us build a brokerage infrastructure for the 21st century.

Need any help?
Get started with our DocumentationGet started with our DocumentationGet inspired on our BlogGet inspired on our Blog
© lemon.markets 2023Privacy PolicyImprint
Systems are down

As a tied agent under § 3 Sec. 2 WplG on the account and under the liability of DonauCapital Wertpapier GmbH, Passauer Str. 5, 94161 Ruderting (short: DonauCapital), lemon.markets GmbH offers you the receipt and transmission of orders for clients (§ 2 Sec. 2 Nr. 3 WpIG) of financial instruments according to § 2 Sec. 5 WpIG as well as brokerage of accounts.