Building a Trading Bot from Scratch - Part 2

in LeoFinance6 months ago (edited)

Screenshot_20210417_055016.png

I've reached a major milestone in the development of my trading bot. It now reads the current price stream (ticker), stores it to the database, as well as backfills any missing history required for the trading strategy by requesting it from the server, and of course, also storing that to the database.

That means I now have a working price buffer to feed to the trading strategy.

The next step is implementing the strategies. I'm looking at how the Gekko trading bot, for ideas on how to do this, but already have structured things differently.

Gekko has restrictions on the number of strategies working simultaneously on one exchange, because of its architecture. I should have a solution to overcome this with my bot.

I will also be using Node.js threads instead of processes to run parallel tasks. From my research it should be more efficient and only limited by the number of processor threads.

It's a huge advantage to be able to look at the work of others and study the successes and short comings of their projects. Many of the issues and feature requests that Gekko had were slated to be dealt with, but the project creator moved on to new things. Various people have made modifications, but no one has sifted through them all and merged them into one working repository. This is pity, because there's been a great deal of work done.

This is part of the reason I decided to start programming my own trading bot. I did not want to take over the time consuming work of firstly understanding the internals of Gekko and then trying to merge many different modifications.

But, that said, I have recently done some tinkering with Gekko to extend its usefulness while I am still developing my own bot. More on that in the next post.

Posted Using LeoFinance Beta

Sort:  

It seems like you've started a big project! It sounds very interesting, though. Any plans on the strategies yet? From what I've seen, there are several 'frameworks' for trading bots available online, but it seems either very hard to come up with a 'working' strategy, or people with successful strategies keep them for themselves (can't blame them...)

Yes, there are no end of trading bots, but very few of them are free and open source, and fewer still are flexible, and fewer still have good interfaces. With that, I've set myself a tall order to fill. It will take some time to get working, because I have to do other things to turn a dollar and pay the bills. I've accepted that.

Working strategies are another thing. The bot will come with some basic ones, but after that, yes, you will have to write your own, because if you share a very successful trading strategy with everyone, you lose your edge, and it no longer becomes profitable.

However, there are resources which give you a starting point.

I started tinkering with Pine Srcipt on TradingView.com after comparing price movements to various indicators and noticing patterns and signals. There are heaps of open source scripts on Trading View that you can use and study. You can then develop your own ideas and back test them against price history.

From there, I rewrote the strategy in Javascript for the Gekko trading bot.

With my own bot, I'm planning to have the features of displaying indicators and strategy buy sell signals on a modern price chart, and back test against price history. So in essence, do more than what I can on Trading View, because I don't want to pay for a subscription there.