How to build an efficient trading bot for Binance using Node.js

Hervé Fulchiron
JSapp.me JS Full Stack Engineering
3 min readJun 4, 2018

As a Full Stack engineer, I get to build many types of front ends for the web or mobile. But my favorite type of apps are actually Console Apps. They run on the Terminal (or Command Prompt), and they provide an easy and efficient way to execute difficult tasks like low latency cryptocurrency trading. The minimalism of the graphical interface give them an edge on the speed of execution vs. manual retail trading.

This console app built on top of Node.js can automate dynamic and complex cryptocurrency trades on Binance. You can download, install and test the code from this GitHub repository: https://github.com/jsappme/node-binance-trader

How to upgrade your crypto trading experience. 🤖

This trading bot is able to perform the following dynamic trade:

  • Buy a given amount of cryptocurrency at the best price when the user decide.
  • Sell this amount when price reaches a defined Loss Percentage.
  • Sell this amount when price reaches a defined Profit Percentage.

This bot is minimalist yet beautifully interactive, super fast, efficient and reliable.

I use the following Node.js tools to build the interface of the console app:

  • Chalk: 🖍 Terminal string styling done right
  • Ora: An elegant terminal spinner
  • ConfigStore: Easily load and persist config without having to think about where and how
  • Inquirer.js: A collection of common interactive command line user interfaces

After introducing the trading bot, the console app asks the user which pair she/he would like to trade using Inquirer.js. Then it displays some live market price data, and the bot offers to buy the pair after entering the Amount to buy, the Loss Perrcentage and the Profit Percentage. After confirming the trade, it automatically executes all the buy and sell limit orders as fast as possible depending of the live trading price of the pair.

The bot uses the complete and heavily tested wrapper Binance-Api-Node to connect to the Binance API via WebSockets. It reads all trade prices in real time and set the Stop Loss Sell order when current price is bellow the Buy Price and set a Limit Sell order at the Profit Price when the price go above 50% of the Profit Percentage. If something goes wrong, it will sell at Market Price before it exits the trade making sure nothing is left on the table.

I am using this code as the framework of all the trading bots I develop for my personal use and my clients. I am open sourcing it so it can be peer reviewed and tested by more people. If you encounter any problems or errors running it, please feel free to submit an issue on the GitHub repository. I will make sure to fix all of them. I welcome all your suggestions to improve the efficiency and reliability of this trading bot. I plan to support, improve and add new features to this console app in the future.

If you need some help building your trading bot or improving your trading strategies using the latest AI/ML algorithms (like LSTM Time Series Forecasting), please feel free to contact me.

--

--

Hervé Fulchiron
JSapp.me JS Full Stack Engineering

Passionate JavaScript Full Stack Developer specialized in Vue, Gridsome, Shopify progressive web apps and Crypto Trading Solutions.