- >News
- >Can ChatGPT Build You A Crypto Trading Bot?
Can ChatGPT Build You A Crypto Trading Bot?
I know how to program, but that doesn’t mean I know how to build a crypto trading bot. Luckily, in today’s day and age, you don’t necessarily need to know how to do either to build a trading bot. ChatGPT can build one for you.
Although, merely building a trading bot is different from actually launching, deploying, and letting a trading bot handle your money. In this article, we’ll explore two questions. Can ChatGPT build a crypto trading bot for you and — if it can — should you let it make decisions on your crypto?
Building a Bot with ChatGPT
To start things off, we need a good initial prompt that will shape our entire interaction with ChatGPT. Also, with any ChatGPT interaction, we have to be specific about what we want.
An absence of specific terminologies will cause ChatGPT to provide an answer in an assumed domain. With that, here is what my initial prompt looked like:
Before we ask ChatGPT to produce any code for us, we need to decide which programming language we want to use to build our bot. I have a preference for Javascript, so I will be asking it to produce NodeJS code for me.
Asking ChatGPT to Produce Code
My formal profession is a Full Stack Web Developer and I use ChatGPT almost every day to accelerate and multiply my capacities.
One thing that I’ve learned is that ChatGPT is very good at laying out frameworks and less adept with working with specific libraries such as the one we would need to build a proper trading bot. So in the second prompt, I’ve decided to ask ChatGPT to produce a simple NodeJS server with some empty functions that we can dig into and fill in later.
ChatGPT effortlessly output what I think is a pretty decent framework for a trading bot. If you’re not a programmer, no problem, keep reading as I will attempt to break things down for the less technically inclined.
The code snippet produced by ChatGPT basically consists of 4 parts:
1. The Bot Server
The bot has to run somewhere and be open to requests. The line that says ‘app.listen(3000)…’ is the main driver of our bots ability to take in requests such as “stop” or “start” or “execute new strategy” or “stop old strategy”.
2. Signals
The bot has to have information about the market. ChatGPT was intelligent enough to know that the entire industry calls this information “signals” and that we should have an explicit piece of code for receiving and processing signals.
3. Status
The status indicator is for the benefit of the human running the bot. We can actually customize this function quite a bit to tell us all sorts of things about the inner workings of the bot. How much money have you made? What was your most profitable trade? How many trades have you made?
4. Trade
We need to tell ChatGPT what to actually trade. This particular function looks like it’ll just execute a single trade for us, which is not a strategy in and of itself.
A trading strategy will consist of many trades. Any particular strategy must have at least two trades in order to become profitable. One to buy something, and one to sell at a profit later. So with this in mind, we have what we need to make our next prompt for ChatGPT.
I asked ChatGPT to use the code it created for itself in the first prompt to actually create a “scalping bot” in a separate script.
A scalping bot simply tries to make small consistent gains, repeatedly. You can see that ChatGPT knows how to use the output of one prompt in the output of another. You can think of the first prompt as the “server” or the “tool” and the output of the second prompt as the “harness” or “user” of the tool.
From this perspective, the second prompt is the bot and the first prompt is the tool that the bot needs to use.
This is a nice structure for our bot because it means we have some freedom in how we implement the tool. For example, I’ve asked ChatGPT to use the ByBit API, but I could have just as easily asked it to use KuCoin or Kraken. This way, the strategy (2nd prompt) stays the same, and the exchange that the bot is interacting with changes.
Filling in the Gaps of the Trading Bot
There are a lot of details missing from the code that ChatGPT produced for us. It’ll be up to you to take ChatGPT’s output and fill in the gaps. You can conceivably get ChatGPT to help with that coding effort, but the difficult part will be getting it to produce actual code from the APIs of cryptocurrency exchanges. Up-to-date knowledge of these APIs is often missing from ChatGPT’s knowledge so you’ll need to do a lot of the legwork here.
Finally, you’ll need to deploy your trading bot. You can do this on your own computer, but then you would need to keep your computer on 24/7 so your bot is always running. It is recommended to rent a server from AWS or GoogleCloud on which to run your bot. ChatGPT may be able to help with instructions on how to set that up as well.
Should You Trust Your TradeBot With Your Crypto?
We’ve arrived at the final question, should you actually trust your bot that you’ve built with the help of ChatGPT? I wouldn’t. Not without extensive testing.
Most exchanges offer sandbox accounts with test cryptocurrency. If you intend on using code given to you by ChatGPT, make sure to thoroughly test the code with fake money before using real cryptocurrency.
In conclusion, it does seem that ChatGPT can build a trading bot, but it requires a lot of assistance from a programmer who knows which questions to ask. Furthermore, the profitability and effectiveness are still in question. Until we launch the bot with real money, this question will go unanswered.