I have discovered a crypto pump and dump trading group called “KuCoin Pump Signal” at the Discord chat platform, somewhere in July 2021.
Since I have already been deeply involved into crypto trading and mining, I came with an idea on how to build a crypto pump and dump trading bot, by using this kind of chat group to get the crypto coin name immediately after a signal appears and place the orders at KuCoin exchange.
For those who haven’t had a chance to trade with crypto, this kind of trading behaviour is mostly planned.
Pump and Dump (P&D) is a common scheme used in cryptocurrency trading that involves inflating the price of an owned cryptocurrency through misleading statements, in order to sell the cheaply purchased cryptocurrency at a higher price.Source: Wikipedia
First of all, I started analysing the first pump and waiting for the coin name to appear in the chat group at the planned time and then – manually placing orders at KuCoin.
I have placed market buy order at DINO-USDT trade with a stake of 100 USDT (≈$100). Immediately after the market order had been filled, I placed another sell limit order, with an increased target price of 20% (while their projected gain was 500-900%).
A few seconds later, when I realised that I had already placed my buy order too late and that the price drops down every second, I panically canceled my sell limit order and sold everything by the market type of sell order. Lost 37 USDT. Lesson learned.
After a disappointing failure, a week later I have tried the strategy once more and it returned with negative profit again. I knew I’ve done something wrong, as there were tons of users in the chat group, posting their success trades with profits over $5k.
Therefore, I decided to find a way to programmatically fetch the coin name and automate the trades at KuCoin crypto exchange platform using their API.
Developing the bot – attempt #1
I started analysing HTTP traffic going from my browser to Discord chat platform. Of course, I have been trying to get the fastest route to the coin signal as possible. While scanning the requests at Discord, I have discovered that, after the Discord chat group webpage has been loaded, it triggered a GET request.
I quickly copied the whole request as cURL and did a paste into Postman. There were also a few additional (required) header parameters in this request.
I realised that I could change the GET parameter
1 and actually get the latest Discord chat group message posted. The response was very useful.
have written a Node.js script that will be executed 10-15 seconds before the coin pump signal. A code is using
axios promise-based dependency to send a request to Discord public API over and over again until it finds a matching phrase.
And it worked! I could easily fetch the coin name once the signal triggers at the exact planned time, in less than a second!
I had to go to the KuCoin API docs and do a little research on how to programatically place limit and market orders using Node.js. Their documentation is well written, for both newbies and professionals in trading.
I decided to go with a market buy order, immediately after I receive the coin name signal from Discord chat group.
I have used
kucoin-node-sdk package for placing buy orders at the API.
After the order has been created and filled, the script will fetch the order details and check if it is either filled or not. Then it will get its fill price and amount of filled coins, then forward the data to the limit sell order function with the same amount of coins, but with an increased price by 20% (later specified by the script parameter).
After testing the pump & dump situation, using a fake/mock signal in my own Discord group, then forwarding the coin name to the script and finally – placing the orders at the KuCoin sandbox environment, I realised that the bot was actually performing really wonderful.
Immediately after receiving a Discord group coin name signal, the script placed a market buy order at KuCoin in 383ms, fetched the order details, did the calculations and successfully placed a new limit sell order in 508ms.
And BOOM! After I had started the bot on the real pump signal at the Discord group on 23.10.2021, I returned with a profit of 23.91% (the stake was 200 USDT).
Improving the bot speed – attempt #2
After doing a brief testing and research, I had noticed that I could easily replace all API GET request information with a live web socket. I had done two things that would speed up the bot a bit more:
- Replace Discord API with Discord web socket (for fetching the coin signal message in real time)
- Use KuCoin web socket to get the order details after it has been successfully filled
I have found a web socket connection while inspecting requests in my browser. Therefore I quickly realised that the socket receives a new message every time someone posts into a Discord chat group. So, let’s focus on that WS request.
So, let’s first create a web socket connection to Discord.
Afterwards, I have created
onmessage callback where I would actually read live socket messages, decode them and retrieve the coin name signal from Discord chat group message by parsing the result with a regular expression. Also, it was required to send an authorization token as a reply to the first heartbeat message from Discord.
This worked perfectly after sending a simple test message to my own Discord group. The script successfully established a web socket connection to Discord with a valid authorization, and got the token name by parsing the RegEx.
Let’s now focus on the KuCoin web socket listed on their documentation page. The following code will actually replace my previous
processOrder() API call function with a live socket.
I have decided to use
kucoin-node-sdk dependency again to get the details or changes of my latest crypto buy order.
Finally, after wrapping up all the things I mentioned above, I had decided to test the bot on the next real KuCoin Pump and Dump signal from the Discord group, and it worked.
It returned me a profit of 11.94%, while the stake was 450 USDT. What a brilliant buy/sell trade in less than 1 second!
Relocating VPS server – attempt #3
After I had finally deployed my bot to the production, I came up to an idea on how to optimise the script a little bit more by using the VPS server in the closest datacenter to Discord and KuCoin location as possible.
After purchasing and trying 36 Linux VPS servers in several continents, different countries, among various datacenters and providers (AWS, DigitalOcean, Google, Linode, Vultr, etc), overall the fastest VPS cloud provider was DigitalOcean (in the FRA1 datacenter), returning responses from Discord and KuCoin in less than 1 millisecond.
axios(fetching web requests)
kucoin-node-sdk(accessing the KuCoin API)
uuid(generating unique uuidv4 for KuCoin orders)
lodash(helper functions for string and object manipulation)
minimist(providing input parameters/arguments to the script)
ws(web socket for Discord and KuCoin)
zlib-sync(decoding Discord web socket response messages)
DISCLAIMER: This article is meant for educational purposes only. Therefore I’m not responsible for any harm/illegal activity that may happen.