Stock Trading Bot

Sebastian Dobrincu built a neural net for high frequency trading as a side project, and today it makes $3500/mo. Learn how he built it and what he's doing to grow.

Hello! What's your background, and what are you working on?

I'm Sebastian Dobrincu, and I'm a software engineer currently working as a freelancer. I'm also an avid product maker who loves building side businesses and crazy projects. Machine learning 🤖, mobile development 📱 and design 🖌 are some of the keywords related to my professional background.

I initially built Stock Trading Bot as a personal research project. I was testing the waters to see if modern machine learning approaches can be used to predict and automate selling and buying of assets in today's stock market, at a much more efficient rate.

Only 5 months in it makes around $3,500/month in revenue, with a maintenance cost just shy of $90/month. Currently I am the sole user. I'm planning to continue working on it with the goal of scaling the bot as much as possible.

How'd you come up with the idea to build your stock trading bot?

The idea popped up pretty randomly. I was getting ready to board a flight to SFO and decided to download some podcasts. I felt like trying something new, so I picked a few of the most popular ones from the Finance category. 10,000 feet above the ground, I hit play and made myself comfortable.

The host brought up the topic of liquidity, which boils down to 3 measures: price, size, and time. Essentially when liquidity is high, investors can successfully trade a larger order close to the current price and within a short time span. Once they began debating whether or not high frequency trading was improving the market by providing liquidity, I switched to the Notes app on my phone and started furiously typing some of the main ideas.

Prior to this project, my experience with finance in general was pretty limited. I had a solid understanding of the fundamentals of trading but not much beyond that. I wanted to change that, but I also remembered that 99% of finance books are bullshit.

After extensive research I settled on Trading and Exchanges by Larry Harris and also John Hull's Options, Futures & Other Derivatives. The first one is probably the best piece on finance I've ever read. It literally answers all those questions any curious person who has ever made a trade might ask. On the other hand, John Hull's book gave me a fantastic introduction on mathematical finance from an applied point of view. I highly recommend both if you are just getting started with trading.

I believe we've reached a peak in the field of AI. We now have both powerful machines and enough data to process. With this in mind, my inner engineer got excited at the possibilities of tackling the market with today's advancement in technology. Besides that, I have an addiction for creating fascinating projects and this was no exception.

How long did it take to build your bot, and what kind of tech did you use?

My goal initially was to bootstrap a high frequency trading (HFT) bot focused only on Bitcoin (mainly due to the great available APIs). The huge advantage is that you are not necessarily starting with a handicap against the big trading firms.

That's because when it comes to stock trading, even microseconds could make trades go wrong — such as your bot falling victim of a faster bot's bait offer. (And guess who owns the faster servers and bots?) With cryptocurrencies however, these small time increments are not nearly as important.

Although I believe it's the golden age to be in the Bitcoin market (because it's imperfect), I quickly abandoned the idea (maybe too quickly?) due to not being able to find a stable enough FIX-based API. Without boring you with technical details any longer, the solid trading APIs were mostly based on REST, which is not fast enough for what I was aiming for.

For proprietary reasons I will abstain from publicly discussing a lot of details about the technical implementation. Although I get many requests to open-source the project, I believe that disclosing deep details of the models or prediction approach would hurt the advantages that this solutions has over the other existing bots. However, for anyone willing to learn more about that, I would be more than happy to discuss in private, to some extent.

Long story short, I ultimately ended up going for the stock market, but not into high frequency trading in its real meaning. My bot holds a single position from seconds to minutes (sometimes even hours), which makes it more of an automated trader than a high frequency trader. The reason behind this is that being an individual trader makes it extremely hard to compete with the big guys, as you're lacking perks such as very powerful hardware, advance trained software, and great locations for your servers. The closer to the stock exchange you are, the faster you receive the information. Large investment servers are literally paying millions to get their servers a few miles closer to the exchanges.

For trading I recommend Kite, mainly for their stable Connect APIs and the low bandwidth. Their limitation is 3 requests per second, and this was more than enough for my new strategy. Getting solid historical financial data isn't cheap, and with so many people hitting the providers to scrape and download data, I don't blame them for limiting the offered information. Intrinio is a good provider for real-time stock quotes at very inexpensive prices. However, getting access to more in-depth data would always yield better results.

I built the first prototype in a little under a month. I was working late hours, trying to find time around my daily job as a freelancer. At this point the bot wasn't very smart. It took me about 2 more weeks to feed it with data until my error rate was satisfactory, and another 2 weeks to test it before putting it in production. Summed up, the technical implementation of the current version took about 4 months, with some more improvements along the way.

Interface Demo

What are your goals for the future, and how do you plan to accomplish them?

Since I publicly announced it, I've been receiving dozens of offers from trading companies. At the moment the system gives me an edge over other traders. If I sold it, I'd be giving this advantage to other traders and, subsequently, losing my lead. Although I do not exclude a future buyout, I am presently focusing on improving the product and trying to scale it.

One of the things that I plan on doing soon is increasing the capital and therefore putting the bot through more trading volume. There are tons of improvements I have in mind, especially on adjusting the position-holding time span, as well as solutions to make it more lightweight, facilitating larger volumes.

What are the biggest issues you've faced? What would you do differently if you had to start over?

I wasted way too much time trying to apply high frequency trading in Bitcoin. At first the idea sounded great, but I was soon facing a lot of technical issues trying to scale the amount of requests. However, I am not yet convinced that it's impossible to achieve true HFT with cryptocurrencies, so it might be something I come back to in the future.

After drifting away from the idea of HFT due to the technical limitations, I looked into a more analytical approach in automated trading. Most of those concepts couldn't be applied in the Bitcoin market, as it's highly unpredictable, making it hard to shape the models around it. That's when I decided to stick to the stock market.

Another big mistake in the beginning was relying too heavily on models. Instead of trying different approaches in analyzing the data I had, I relied solely on the models for identifying profitable patterns without investing time into other more direct solutions. Models are only simple real world abstractions, and my common sense has saved me more than once.

So far, my current strategy worked around 95% of the time. Now this is not by any means a reliable metric, and there are many factors that affect it. The bot has not been tested enough to guarantee that this isn't just a fluke (it might as well be). Large investment management companies would do anything to achieve those statistics, and I'm sure I won't keep up that amount of success in upcoming trades. The success so far was also greatly impacted by the favorable market conditions, chosen stocks, and the fact that the bot was running intermittently.

Also, when the 5% case happens, things can go really bad 📉. I learned this the painful way. Not too long ago the market went pretty crazy, and I'd be lying if I said that I wasn't expecting some major crashes of the stocks I was trading. Then it happened.

Although my stop-loss saved me from some brutal losses, had I not stepped in at the right time, the bot would've ruined all the profit from the past months. That event really got me thinking, and I decided to stop it running for a few days until I fixed that loophole.

Revenue Reports

This was also a great learning experience for me, and I believe that without going through those ups and downs, I would've never managed to get the algorithm to where it is today. I have no regrets losing time on Bitcoin, as it gave me a deeper understanding of how cryptocurrency trading works, which might prove useful some day.

What were your biggest advantages? Was anything particularly helpful?

Probably my biggest single advantage is being a starry-eyed young dreamer. To some extent, this allows me to believe enough to put effort into ideas in that others wouldn't. That's what motivated me to persevere in finding those "backdoors" in the market. While many people believe individual traders don't stand much of a chance against the well-equipped companies, I am here to prove that with the right implementation there still is plenty of space in the market.

Another immensely helpful resource were the public research papers available online. In fact, I got tremendous help from papers published back in 2006. I often found that most of them are easily overlooked, although they contain super useful analyses.

Being a workaholic has also contributed a fair amount to this success. I have no issue whatsoever working 10-12 hours per day. With time, I developed a very productive and consistent lifestyle, managing to get rid of most distractions. This allowed me time to invest in polishing and researching the different strategies for this project.

What's your advice for aspiring indie hackers?

Launch things! If you've worked your butt off to build something and give up on launching it, no one will care about it. We live in a very capitalist society where people will judge you based on real results. No one cares about your initiative and the reasons why you didn't launch.

As Sam Altman says, nothing will excuse you for not having a great product. However, not having anything is certainly worse than that. Don't make it perfect from the first version. Test the market first, gather tons of feedback and constantly iterate over your idea.

Although this is not necessarily a customer-focused product (yet?), I can't stress enough the power of side projects. Side projects allow you to experiment on crazy ideas without being labeled as crazy. And even when people do judge you based on this, you can just pull the, "Yeah, it's just a side project" card 😁

And definitely go for the craziest idea you have in mind. That's how most of the successful companies started (talk Facebook, Uber, AirBnb). You probably don't want to spend your most precious resource (⏰), building yet another Snapchat clone. Every problem has a solution. You just have to be creative enough to find it.

Where can readers learn more about you?

You can reach me at any of the following sources and obviously in the comments below. 😄

🔴 Got a cool project? I am currently available for freelance work. 🚀

Subscribe for new interviews every week! 🤗

Courtland here! I regularly interview the indie hackers behind profitable apps and side projects like Stock Trading Bot. Enter your email below, and I'll send you new interviews when they're out. Feel free to unsubscribe whenever you want.

Share this interview:

Loading comments...