Tired of Losing to the Big Guys? Maybe You Should Write a Bot

My Plan to Enter the World of Algotrading

Silver Berry
DataDrivenInvestor

--

Photo by Gerd Altmann on Pixabay

According to Business Wire, algorithmic trading (algotrading) is responsible for around 60–73% of all U.S. equity trading. These are largely owned by high-frequency trading firms that rely on data and lightning-fast speed to execute trades in all situations. Because speed is such an important part of the business, many firms are based in Chicago and New York where fiber optic cables connected them directly and saved precious milliseconds on trades.

As one of the smallest fish in the ocean, my goal is to swim along the current of the big guys. If the market is pushing upward, I want to have long positions that benefit from bullish exposure. On the contrary, if the market is selling off, I want to have bearish positions on.

What Does Algotrading Have to Do With the Retail Trader?

Photo by Austin Distel on Unsplash

In order to make better educated guesses on where the market is heading and appropriately open positions that fit my trading thesis, I need to look at more data. The leading trading firms regularly process petabytes of data, streaming them in real-time to facilitate near instant and automated decision making.

Many retail traders use technical indicators to inform their trading decisions. These are fantastic as they provide historical patterns and signals that assess the practicality of opening a position, but I personally want more data on my side.

Good trading is supposed to be boring. The best traders I’ve seen are successful because they have mastered the art of making disciplined trades. Disciplined traders follow a mostly strict set of rules and do not allow emotions to compromise business. In other words, good traders aim to be like computers.

I don’t know about you, but I’m pretty bad at being a computer. Excitement and fear of missing out drive trading decisions more than I’d like to admit. Having traded for nearly a year now, I have developed some discipline in the markets because I’ve been able to see what works and doesn’t work for me. But, it’s time for me to do more than draw on previous experience.

Backtesting and Paper Trading

Photo by Kristopher Allison on Unsplash

This is the first thing that I am going to do when I start building the trading bot. Think of backtesting as a way of running a trading simulation. I plan on coding up the trading strategies I use on a regular basis and see how they perform in different market conditions.

You don’t need to be a programmer to run backtests. There are platforms out there that allow you to run a backtest over a set period of time by simply selecting options from dropdown menus. For day traders, TD Ameritrade’s ThinkOrSwim desktop platform has a setting called OnDemand which allows you to rewind to a day of your choosing and paper trade. You can easily fast forward in time to see how your positions performed.

I tried out a few online solutions, but I haven’t been able to configure more granular settings. Although there’s definitely a steeper learning curve with code, I believe that the control I get will be well worth it. Many proprietary firms require traders to be proficient in programming to backtest solutions after trading hours.

While I’m not actively trying to become a trader in a firm, I’m confident that the backtesting will teach me valuable lessons about what I should do moving forward. Here’s my plan:

  1. Write scripts to backtest different strategies.
  2. Regularly run experiments on them, comparing how they perform in different periods of time.
  3. Once I have enough data, write a bot that dynamically chooses the most suitable strategy given previous history and current context.
  4. Run the bot in real time for a couple months of real trading sessions with simulated money.

Improve the Bot and Use the Bot’s Insights in Trades

Photo by Jason Leung on Unsplash

By the time I get to step 3, there will be data points from the bot for the strategies I’ve chosen. This will be an iterative process as I’m sure I will want to make small tweaks here and there or introduce new strategies to the backtests.

At this point, I plan on having a better understanding of how to navigate different market conditions. I will start taking trades that have had a history of working well according to the backtest results. I’ll keep a separate journal for trades informed by the bot to get an understanding of how well those are performing. Of course, if I get to step four, I’ll have concrete data on how well the bot is actually performing.

Deploy the Bot to the Live Markets

Photo by Robert Bye on Unsplash

After the bot has been in step four for a while and I feel comfortable taking off the training wheels, it’s time to algotrade in the live markets. This process will start slow and with a smaller amount of capital. Over time, I will monitor the performance of the live bot and continue training it outside of market hours.

I will only add more capital and/or strategies to the bot if I feel confident enough. Everything I’m saying for this stage is extremely hand wavy, but it would be really neat to get to this point.

How I’m Getting Started

Photo by Matt Duncan on Unsplash

Right now, I have 0 lines of code written. Based on my research so far, I have decided to use QuantConnect, a platform suited for backtesting, paper trading, and live trading. QuantConnect can be used with a couple of different programming languages, but I will use Python. Python is a favorite among the data science community, and this will be a good opportunity to strengthen my programming abilities since I rarely use Python.

QuantConnect has a “bootcamp” for new users to familiarize themselves with the platform. I’m planning on getting through that this week so that I can start testing strategies and have a better understanding of what’s happening.

Time to Hit the Ground Running

There’s a lot of work to do, and I’m just at the very start. If you have any insights on algotrading or any thoughts on how you refine your trading strategies, I would love to hear them. I’m also planning on sharing more as I continue down this path so stay tuned! It’s going to be fun.

Originally published at https://www.datadriveninvestor.com on March 3, 2021.

Gain Access to Expert View — Subscribe to DDI Intel

--

--