How to deploy a Bot?
A first step to a automate trading machine
So let's say you have managed to work out a successful strategy. We assume it is an extremely simple one, whenever Elon Musk tweets about "Dogecoin", buy Dogecoin and hold it for 24 hours.
Backtesting
Don't rush to make a bot. First, you should make sure that your strategy is actually profitable. The method to verify is called Backtesting. The theory is to run your strategy through historical data, even if you think your strategy is perfect, it is always worth checking:
Does most of your profit come from one or two flukes?
What is the maximum drawdown that could happen to your strategy?
How does your profit growth graph look?
Some other indicators you may feel important...
There are plenty of professional Backtesting tools such as Quantstats, Backtrader.
Use APIs, not Fingers
A yesterday-you probably work as busy as a bee to follow Musk's X account and keep refreshing until you see something about Dogecoin. The first thing you need to know is that the machine doesn't read data as a human does.
The way computers interact with each other uses API (Application Interface). Apparently, computers don't need fancy colours or shapes to entertain their "eyes". All they need is cold data in shipshape. An API example is given below, you can click the URL to see what it looks like from your browser.
The majority of services you use daily are provided in the form of API as well with a few clicks on Google by searching "API + whatever you want" such as "Weather API", "API stock price". To track what Elon Musk has published, you need Twitter API. With that, you can define a function that loops every second to check if Musk has said something new and if yes, whether it is about Dogecoin.
Choose an Exchange
Sure you will need to find an exchange that deals with Dogecoin and provides API trading. Luckily almost all crypto exchanges do. Based on their documentation, you need to write some API calling functions to execute buy, and sell commands into functions.
A little Database
In most cases, you will need some methods to store the data you queried from the internet. And the most popular choice is SQL (Structured Query Language). There are so many different flavours of SQL, the simplest one is SQLite. Which means the database is just a mere file on your Computer. (I know some of you might say serverless functions or CSV etc, but I'm just giving the cheapest yet fastest option here 🥱)
Every time when you capture a Dogecoin tweet from Elon Musk's X account, and successfully open a position, you should record your action in your database. Such as:
Then you can always come back and check the order you opened through the API queries. Once it reaches 24 hours, send another close position command to close it.
Cloud Service
When you reach here, you already have a full-functioning bot. Time to give it a home. Of course, you can leave it on your computer just like that. But you can't guarantee your computer runs 24/7 and probably you can't stand the noise it makes during the night. That is why it makes sense to host it on someone else's computer -- tada! the Cloud.
An example of a runnable trading bot
Last updated

