Advanced highly customizable asynchronous cryptocurrency arbitrage bot written for Node.js
To start the program run:
npm start
Then open 'http://localhost:3001' in your favorite browser to monitor markets' spreads, for example:
firefox http://localhost:3001
Note that browser frontend do not include the bots' activity monitoring yet.
The whole idea of the program is to monitor difference between different cryptocurrency markets and hit it when it's big. Simple math tells us, that if, when the spread is high, we sell on one market and buy on the other and reverse the operation when the spread is low (or high in the opposite direction) we just earn free money. (Not so free actually, considering the money freezing due to waiting for that situation to occur).
That said, dtarbitragec monitors markets set with './configure markets' command, activates bots based on strategy configured with './configure bot' and finance settings configured with './configure finance', using api keys stored through './configure keys', sending mail notifications from real or simulated bots configured via './configure mail' command and writes down monitored data to './textdb' local directory if the history mode is enabled using './configure modes' command.
So, the most important task in setting up bots' strategy is to specify the highest and the lowest spread to react to for each market and each currency. Hopefully './configure bot' program can handle this task.
You can run infinite numbers of bots simultaneously - they won't get confused or leave you without money due to misunderstandings. Bots are constructed to run simultaneously - they have queues, multiple checkings of available balance, strong logics and good sustainability to errors, disconnections and rebootings of the system. All bots save their progress after each valuable action, that's why you can reboot your system right in the process of bots doing some trading, and bots will revive after restart (not recommended still).
Monitored data (spreads) is sent to localhost:3001 via socket interface; bots' progress is not - it is stored in './botV1' local directory instead. Logs of bots' operatoins are written into './log' directory.
dtarbitragec is written for Linux in the first place, but if you wish to run it under other platforms you can. At your own risk!
Node.js ^8.0.0, bash/sh (with gnu coreutils).
Optional 1: curl, make, perl. (For bots' and markets' configuration -- system/your perl)
Optional 2: curl, make, gcc. (For bots' and markets' configuration -- local program perl)
Most of these is by default included in major Linux distributions, so you basically need to install nodejs/npm on your system.
If you wish to deploy on a Windows/other system, it is possible too, all you need is to install the software listed above first and may be do some magic after that.
git clone git://github.com/dta90d/dtarbitragec.git
cd dtarbitragec
npm install
Installation script will guide you through the basic installation and configuration.
To update dtarbitragec simply run
git pull
npm install
in its root directory.
All configuration files are written in JSON, so be aware of the syntax there.
Major configuration of the program is done via the configuration script.
./configure [-e <editor>] <command> [ARGS]
Settings (=commands) are divided into logical groups, including:
- modes -- enabling and disabling modes ('./configure modes').
- bot -- bots' strategy and triggers ('./configure bot').
- markets -- enabling and disabling markets ('./configure markets').
- finance -- bots' settings like order minimum and maximum cost ('./configure finance').
- keys -- your api keys from different markets ('./configure keys').
- mail -- mail notifications configuration ('./configure mail').
There are three modes available now:
- bots_mode -- activate bots, that do financial operations based on strategy contained in botdata ('./configure bot') and static options in finance data ('./configure finance'), using api keys, contained in keys data ('./configure keys').
- simulate_bots -- bots do not buy or sell really, so there's no need for finance and keys settings, but botdata is required still, as simulation is its test. These bots are simplier that real ones and applied only for testing if your strategy is reliable or not.
- history -- writes down all the monitored data to local directory ('./textdb'), that can be analyzed afterwards.
To configure modes simply run:
./configure modes
This will open configuration file and some instructions. Note: you need to restart the program for modes change to work.
Bots' settings are called botdata. It can be configured dynamically even if the program is up and the bots are active. Newly configured data will apply only to future bots and won't disrupt the running ones.
Botdata is an array of cases telling bots whether to buy or sell or wait or whatever.
Basic structure of each bot (element in botdata array) is:
- coin -- pair/currency to watch for.
- high_market -- information about the market we suppose the bid to be higher than the other's ask.
- low_market -- information about the market we suppose the ask to be lower than the other's bid.
- spread_high -- bid / ask (with a big difference).
- spread_low -- bid / ask (with a small difference).
- wait -- when to open the deal an activate the bot - high, low, both or none.
An example of real botdata:
[
{
"coin":"BTC_EOS",
"high_market": {
"lev":3,
"name":"bitfinex",
"step":0
},
"low_market": {
"lev":3,
"name":"hitbtc",
"step":0
},
"spread_high":"0.9",
"spread_low":"0.25",
"wait":"high"
},
{
"coin":"USD_XMR",
"high_market": {
"lev":3,
"name":"kraken",
"step":0
},
"low_market": {
"lev":3,
"name":"bittrex",
"step":0
},
"spread_high":"1.2",
"spread_low":"0.4",
"wait":"low"
}
]
To configure this settings run:
./configure bot
This will tell you how to use BotdataManager program to configure botadata on fly.
You can tell the program is it needed to monitor the market or not.
Just run:
./configure markets
and turn on/off some of the markets in the configuration file. This will affect opened bots, as they won't be able to get the data from the markets after reboot.
Another peace of settings for the bot, but more static one:
- min_cost -- set minimal cost for each order for each margin currency (USD, BTC, ETH, EUR).
- max_cost -- set maximal cost for each order for each margin currency (USD, BTC, ETH, EUR).
- balance_buffer -- buffer to remain on balance for each margin currency (USD, BTC, ETH, EUR).
- amount_mult -- parameter to lower the amount attampting to buy/sell from the orderbook to guarantee the deal.
- limit_price_buffer -- parameter to heighten/lower buy/sell price to guarantee the first ask/bid.
- commission -- your commission on each order for each market.
To configure these settings simply run:
./configure finance
An example of finance file:
{
"min_cost": { "USD": 10, "BTC": 0.0001, "ETH": 0.001, "EUR": 7 },
"max_cost": { "USD": 20, "BTC": 0.0002, "ETH": 0.002, "EUR": 14 },
"balance_buffer": { "USD": 100, "BTC": 0.001, "ETH": 0.01, "EUR": 70 },
"amount_mult": 0.6,
"limit_price_buffer": 0.8,
"commission": {
"bitfinex": 0.2,
"kraken" : 0.26,
"hitbtc" : 0.1,
"bittrex" : 0.25,
"poloniex": 0.25
}
}
API keys configuration. Of course needed for the bots_mode to work.
./configure keys
Example:
{
"bitfinex": {
"key": "sdssdsd",
"secret": "dsdsdjsijd"
},
"kraken": {
"key": "sdsdsdsd",
"secret": "dsdscsdcsdcsc"
}
}
Mail notifications are available only via gmail service. Configure the outbox gmail and give the program its address and password. Note that you need to allow gmail to be used by the program.
./configure mail
Example (note that outbox address do not need the @gmail.com extention):
{
"enable" : true,
"mail" : "example",
"pass" : "123456really7",
"SEND_TO": [
"[email protected]",
"[email protected]"
]
}
Feel free to contact me at [email protected]
Written by dta90d
See the LICENSE.md file for details