How to Create a Crypto Trading Bot

This is a description of how you can, with the bots we created from our APIs, create your very own crypto trading bot. Yes, you too can enjoy the warm and fuzzy feeling of giving life to something, trusting it with pocket money, and sending it off into the world hoping it won’t return with magic beans.

Hello, wanderer of the internet, you’ve stumbled upon my first post for Deversifi and it’s fitting that it’s going to touch on two elements that excite me – trading and bots. For you see, over the last few weeks here at Deversifi we were running a competition where people could bet on which trading bot was going to end up with the greatest profit (or smallest loss..).

Since algo trading is notoriously hard to get right and requires teams of people alternating between furiously pointing at whiteboards and clutching their heads in dismay (well that’s how I imagine it anyway).. we decided to have a bit of fun and just do what Donald Trump told us.

Yes, as crazy as that sounds we created a crypto trading bot, gave it ~$460 of real funds (split equally between USDT and ETH), and set it loose listening to Trump’s tweets. On the basis of whether our trading bot’s superior artificial intelligence assessed the tweet to be positive or negative, it would happily buy or sell on the ETH:USDT market oblivious to the consequences. If that on it’s own wasn’t a sufficient crime against nature, we then spawned 14 more trading bots, gave them their funds, told them who to pay attention to and watched them wander off into the world like a parent watching their child depart on their first day of school.

Then we sat back and watched as our minions listened diligently and traded away, hoping our elite trading algorithms would not be upstaged by their naive choices but also secretly hoping to find some unexpected causality that would enable us all to retire. Users and visitors noticed too: we watched as one after another they started predicting who would end up top overall and tweeting from our competition page (it was a marketing exercise after all).

After the dust settled, the winner Martina Krung walked away with $621 of our beer vouchers – luckily we are a remote company otherwise we might have had trouble explaining at the pub to our thirsty developers why they had to buy their own drinks that Friday.

But this isn’t a retrospective of the Twitter trader project, Ben has already written a great summary of that. Rather this is a description of how you can, with the bots we created from our APIs, make your very own crypto trading bot. Yes, you too can enjoy the warm, fuzzy feeling of giving life to something, trusting it with pocket money, and sending it off into the world hoping it won’t return with magic beans.

Our trading bots were developed with our public API that is already extensively documented with examples in NodeJS, Python and C++. However we’ve gone one step further by releasing both the TraderBot code as well as a fully featured skeletal bot ready for own API keys and trading strategy. It’s the latter I will briefly introduce here.

So how do you create your own trading bot?

First go to your command line and ask Git nicely to clone the repo.

git clone

Then install all packages and dependencies.

npm install

Now’s a good time to register with Infura for your API key as it will be needed shortly. Once you have this and your wallet set up, pop these details into your config.js, filling in the blanks.

module.exports = {

API_URL: “”,




After the config file is completed run the following command to register and deposit your funds ready for trading. This will invoke the immediately-invoked function expression residing within (unsurprisingly) setup.js.

npm run setup

To start running the trading bot, simply start it via the command below which will trigger the immediately invoked function within trade.js.

npm start

But wait! The bot as supplied will begin alternatively buying and selling on a 60s timer as the code snippet below shows. Naturally this doesn’t qualify as a strategy and simply serves as a placeholder to demonstrate the function of the code.

// Starting selling ether

trade(dvf, -ethAmount);

let nextAction = “buy”;

// trading every 60 seconds switching buy and sell

setInterval(() => {

if (nextAction === “sell”) {

trade(dvf, -ethAmount);

nextAction = “buy”;

} else {

trade(dvf, ethAmount);

nextAction = “sell”;


console.log(“Sleeping 60 seconds”);

}, 60000);


The trading logic is all contained within the trade.js and can be customised and tweaked to serve whatever trading strategy you have in mind. We’d love to see what you create so feel free to fork the repo directly and show us what you come up with. Happy trading bot making!

About DeversiFi

DeversiFi gives traders the edge in fast-moving decentralised finance (DeFi) markets by allowing them to trade at lightning speed and with deep aggregated liquidity, directly from their privately owned cryptocurrency wallet.

Traders can take advantage of more trading opportunities while always preserving control of their assets for when they need to move fast. DeversiFi’s order books are off-chain, but settlement occurs on the Ethereum blockchain. This means that traders benefit from fast-moving order books and instant execution, without having to trust the exchange and whilst always maintaining control of their assets at all times.

For the first time, traders can enjoy all the benefits that they would expect from a legacy large centralised exchange, but with no exchange or counter-party risk.

Latest Posts

Bridge to Taiko – free on

Taiko’s hotly anticipated mainnet launch comes off the back of a hugely popular testnet which has seen over 1 million wallet addresses and more than 13 million total transactions to date.

Read Article

You’re automatically eligible to mint the Alpha Key if you have bridged with us any time before June 1, 2024.

It entitles you to free bridging under $100 until July 19th 2024 and big discounts for higher amounts.

Earn 19% APY on your stablecoins