GithubHelp home page GithubHelp logo

mastha123 / nodejs-binance-trader-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tannguyen248/nodejs-binance-trader-bot

0.0 1.0 0.0 101 KB

This bot use Ichi cloud system combines with some popular indicators to make the prediction when I should buy and notify via Telegram

License: MIT License

JavaScript 100.00%

nodejs-binance-trader-bot's Introduction


Node-Binance-Trader

An efficient cryptocurrency trading bot for Binance using Node.js ๐Ÿ’ธ

Why Node-Binance-Trader? ๐Ÿค”

My name is Herve Fulchiron, Iโ€™m a passionate full stack JS engineer, and I also trade cryptocurrencies on a weekly basis. I mostly use Binance for my altcoins trading. The high volatility of the crypto market makes it an emotional rollercoster that requires high awareness and constant attention. This demands a lot of time to monitor always more trading pairs and more data to process. Like most of the people I used to trade manually via the Binance website. I was slow to execute and beating the market gets more difficult every days. It was time to speed up the testing of my strategies and to automate my trading operations. I tried Gekko, it's a nice tool specially for back testing but I wanted something much more simplier, faster, dedicated to Binance, so I could test my strategies as fast and as easy as possible live on the crypto market. I wrote this one simple but efficient node.js script to:

  • monitor in real time all the BTC trading pairs on Binance
  • apply one or multiple strategies to the live market
  • record live performances of those strategies over time
  • auto trade the most successful strategies

What is Node-Binance-Trader? ๐Ÿ“ก

Today NBT is an experimental node.js script that asynchronosly run api calls and listen to websockets connected to binance. It can track the 100 btc pairs currently available and apply the predefined strategies for testing purposes. This way I can tell if a strategy is working under the actual market conditions very quickly. The buy and sell signals and their performance can be emailed or even notified via a sound. This is still a work in progress so please take it with a grain of salt. I keep optimizing it so it uses as less cpu as possible.

Installation ๐Ÿ“ฆ

git clone https://github.com/jsappme/node-binance-trader

Configuration ๐Ÿ”‘

  1. Signup Binance ( Referral url: https://www.binance.com/?ref=10177791 )
  2. Enable Two-factor Authentication
  3. Go API Center, https://www.binance.com/userCenter/createApi.html
  4. Create New Key [โœ“] Read Info [โœ“] Enable Trading [X] Enable Withdrawals
  5. Copy the API key and secret to index.js

Usage โšก๏ธ

yarn
yarn start

or

npm install
npm run start

Customization ๐Ÿ› ๏ธ

To add new strategies to the script, you need to add your own buying/selling conditions by adding new functions to the strategies section in the code.

In the following example, I wrote two strats, one is buying when the Moving Averages are showing the beginning of an hourly and minutely uptrend and the second one is buying when the asking and bidding first prices are very close to each others. This example is for education purpose to show you the use of the different types of data available as of today.

//////////////////////////////////////////////////////////////////////////////////
// that's where you define your buying conditions:
//////////////////////////////////////////////////////////////////////////////////

buying_up_trend = (pair) => {
	const ma_s = 3
	const ma_m = 13
	const ma_l = 99
	const ma_h_s = hourly_prices[pair].slice(0,ma_s).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(hourly_prices[pair].slice(0,ma_s).length)
	const ma_h_m = hourly_prices[pair].slice(0,ma_m).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(hourly_prices[pair].slice(0,ma_m).length)
	const ma_h_l = hourly_prices[pair].slice(0,ma_l).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(hourly_prices[pair].slice(0,ma_l).length)
	const ma_m_s = minute_prices[pair].slice(0,ma_s).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(minute_prices[pair].slice(0,ma_s).length)
	const ma_m_m = minute_prices[pair].slice(0,ma_m).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(minute_prices[pair].slice(0,ma_m).length)
	const ma_m_l = minute_prices[pair].slice(0,ma_l).reduce((sum, price) => (sum + parseFloat(price)), 0) / parseFloat(minute_prices[pair].slice(0,ma_l).length)
	if ( (ma_h_s >= ma_h_m) && (ma_h_m >= ma_h_l) && (ma_m_s >= ma_m_m) && (ma_m_m >= ma_m_l) ) { 
		return "BUY"
	}
	else {
		return "SELL"
	}
}

buying_low_depth_diff = (pair) => {
	const max_ask_bid_ratio = 3.0 	// depth_asks/depth_bids < max_ask_bid_ratio
	const min_depth_volume = 2.0  	// btc
	const max_depth_diff = 0.003 	// pourcent(ask-bid/bid)
	if ( (parseFloat(depth_bids[pair])>=(parseFloat(depth_asks[pair])*max_ask_bid_ratio)) 
		&& (parseFloat(depth_bids[pair])>=min_depth_volume) 
		&& (parseFloat(depth_diff[pair])<=parseFloat(max_depth_diff)) ) { 
		return "BUY"
	}
	else {
		return "SELL"
	}
}

let strategies = [ 
	{ name: "UP_TREND", condition: buying_up_trend }, 
	{ name: "LOW_DEPTH_DIFF", condition: buying_low_depth_diff },
]

//////////////////////////////////////////////////////////////////////////////////

Roadmap ๐Ÿšง

  • โœ”๏ธ All BTC Pair tracking.
  • โœ”๏ธ Live testing of 1 or n strats.
  • Auto Trading.
  • Add an AI/ML "brain" to the bot.

Disclaimer ๐Ÿ“–

I am not responsible for anything done with this bot. 
You use it at your own risk. 
There are no warranties or guarantees expressed or implied. 
You assume all responsibility and liability.

Final Notes ๐Ÿ™

Feel free to fork and add new pull request to this repo. If you have any questions/suggestions, or simply you need some help building your trading bot, or mining historical data or improving your strategies using the latest AI/ML algorithms, please feel free to contact me.

Special thank you to Jon for his very helpful repo https://github.com/jaggedsoft/node-binance-api

If this repo helped you in any way, you can always leave me a BNB tip at 0xf0c499c0accddd52d2f96d8afb6778be0659ee0c

nodejs-binance-trader-bot's People

Contributors

tannguyen248 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.