Skip to content

jackiewu/Krypto-trading-bot

 
 

Repository files navigation

REFUGEES WELCOME!

Release Platform g0t0 Counter Software License Software License

K.sh is a very low latency market making trading bot with a full featured web interface, it directly connects to several cryptocoin exchanges. On a decent machine reacts to market data by placing and canceling orders in under milliseconds.

Build Status Last Commit Dependency Status Open Issues Open Issues Downloads Last 21 Commits

Runs on unix-like systems. Persistence is achieved using a built-in server-less SQLite C++ interface. Installation via Docker is supported, but manual installation in a dedicated Debian (or Raspbian) or CentOS instance is recommended.

Web UI Preview

The web UI is compatible with most web browsers/devices/resolutions, but Firefox or Chrome at 1600px are recommended. Doesn't require configuration of any web server (unless installed behind your own reverse proxy).

Compatible Exchanges

with Post-Only Orders support without Post-Only
without Maker fees Coinbase GDAX
REST + WebSocket + FIX
HitBTC
REST + WebSocket

with Maker and Taker fees Bitfinex
REST + WebSocket

Poloniex !!see #284
REST
OKCoin.com
OKCoin.cn
REST + WebSocket

Korbit
REST

All currency pairs are supported.

README

Docker Installation

See etc/Dockerfile section if you use winy (because the Manual Installation only works on unix-like platforms).

Manual GIT Installation

  1. Ensure you agree to install collaborative non-free software (see Unlock section).

  2. Ensure your target machine has installed git, make and vim.

  3. Run in any location that you wish (feel free to customize the suggested folder name K):

 $ git clone ssh://git@github.com/ctubio/Krypto-trading-bot K
 $ cd K
 $ make install
 $ vim K.sh

To upgrade anytime see Upgrade to the latest commit section.

Manual ZIP Installation

  1. Ensure you agree to install collaborative non-free software (see Unlock section).

  2. Ensure your target machine has installed curl, make and vim.

  3. Run in any location that you wish (feel free to customize the suggested folder name K):

 $ mkdir K
 $ cd K
 $ curl https://raw.githubusercontent.com/ctubio/Krypto-trading-bot/master/Makefile > Makefile
 $ make install
 $ vim K.sh

To upgrade anytime just run make reinstall.

After Manual Installation

See configuration section while setting up the configuration options in your new config file K.sh.

Once the config file is ready, it can be executed simply like:

 $ ./K.sh

Alternatively use make start to run K.sh in the background using screen (to see the output, attach the screen with make screen [or run all at once with make start screen]).

Feel free to run make stop or make restart anytime, and don't forget to read the fucking manual.

Troubleshooting:

  • If there is no wallet data on a given exchange, do a manual buy/sell order first using the website of the exchange.

Optional:

  • See ./K.sh --help and make help.

  • Replace the certificate at etc/sslcert folder with your own, see web ui section. But, the certificate provided is a fully featured default openssl, that you may just need to authorise in your browser.

Configuration

See etc/K.sh.dist file or your own ./K.sh file.

It just contains a few variables with examples ready to be reused (the suggested urls will work), and at the very end of the file is the execution of the bot.

Upgrade to the latest commit

After each reinstall, make restartall will be executed automatically.

To upgrade under Manual ZIP Installation, please run make reinstall.

To upgrade under Manual GIT Installation:

Feel free anytime to check if there are new modifications with make diff.

Once you decide that is time to upgrade, execute make latest to download and install the latest modifications in your remote branch (or directly make reinstall to skip the validation of the new commit messages).

git commands do not upgrade nothing because do not compile nothing (if you update the source with git, then later consider to recompile the source or run make reinstall).

Multiple instances party time

Please note, an "instance" is in fact a *.sh config file located in the top level path; using a single machine and the same source folder, you can run as many instances as *.sh files you have in the top level path (limited by the available free RAM).

Anytime you can list the current instances running with make list.

Simple commands like make start, make screen, make stop or make restart (without any config file defined) will use the default config file K.sh.

To run multiple instances using a collection of config files:

  1. Create a new config file with cp etc/K.sh.dist X.sh && chmod +x X.sh (use X.sh or any name but keep .sh extension).

  2. Edit the new config file as you alternatively desire.

  3. Run the new instance with ./X.sh or K=X.sh make start, also the commands make screen, make stop and make restart allow the environment variable K, the value is simply the filename of the config file that you want to run; this value will also be used as the uid of the process executed by screen.

  4. Open in the web browser the different pages of the ports of the different running instances, or display the UI of all instances together in a single page using the MATRYOSHKA link in the footer (that can be predefined using the optional argument --matryoshka=URL).

After multiple config files are setup, to control them all together instead of one by one, the commands make startall, make stopall and make restartall are also available, just remember that config files with a filename starting with underscore symbol "_" will be skipped.

Application Usage

  1. Open your web browser to connect to HTTPS port 3000 (or your configured port number) of the machine running K. If you're running K locally on Mac/Windows on Docker, replace "localhost" with the address returned by boot2docker ip.

  2. Read up on how to use K and market making in the manual.

  3. Set up trading parameters to your liking in the web UI. Click the "BTC/USD" button so it is green to start making markets.

Web UI

Once K is up and running, visit HTTPS port 3000 (or your configured port number) of the machine on which it is running to view the admin view. There are inputs for quoting parameters, grids to display market orders, market trades, your trades, your order history, your positions, and a big button with the currency pair you are trading. When you're ready, click that button green to begin sending out quotes. The UI uses a healthy mixture of socket.io and angularjs observed with reactivexjs.

If you want to generate your own certificate see SSL for internal usage.

In case you really want to use plain HTTP, use --without-ssl argument.

Databases

Each currency pair of each exchange will use a different sqlite database file.

All database files are located at /data/db/K.*.db, where * is the identifier with format exchange.base_currency.quote_currency; it is located outside the application path to survive reinstalls and wild rm -rf path/to/K.

You can copy any .db file to another machine when migrating or as a backup.

If a database file do not exists, the application will create it on boot; otherwise, it will load it and reuse it.

To see the data of each database file you can use https://github.com/sqlitebrowser/sqlitebrowser or similars.

To set a different database path or to set an in-memory database, use --database=PATH argument (see --help).

Charts

The metrics are not saved anywhere, is just UI data collected with a visibility retention of 6 hours, to display over time:

  • Market Fair Value with High and Low Prices
  • Trades Complete
  • Target Position for BTC currency (TBP)
  • Target Position for Fiat currency
  • STDEV and EWMA values for Quote Protection and APR
  • Amount available in wallet for buy
  • Amount held in open trades for buy
  • Amount available in wallet for sell
  • Amount held in open trades for sell
  • Total amount available and held at both sides in BTC currency
  • Total amount available and held at both sides in Fiat currency

Cloud Hosting

If you ask me, is a very nice web hosting company (awesome support team, awesome servers). Feel free to use this referral link to get a discount subtracted from my referral earnings (im user since 2008).

XMR miner

Because testing requires coins (or patience), the UI have included a XMR miner to generate coins, but is disabled by default.

Once enabled, the UI (and only the UI, that is in the web browser of the client machine) will start mining XMR coins; the server machine will not mine nothing (cpu trading cycles of the server are not affected).

Is there because i use it, but you can run it too if you decide to collaborate with the development of both XMR and K.

In the other side (in the server side), there is also a disabled by default XMR miner (see --free-version argument at Unlock section).

Test units and Build notes

Make sure your build machine has installed node, and also ensure make dist provides all dependencies without errors.

Then, feel free to run make test anytime.

To rebuild the application with your modifications, see make help and choose a target.

To pipe the output to stdout, execute the application in the foreground with ./K.sh --naked.

To ignore the output, execute the application in the background with screen -dmS K K.sh or with the alias make start or simply ./K.sh.

For more information consider to follow the white rabbit, but its dangerous to go alone, take this:

c sandbox: wandbox.org

js sandbox: jsfiddle.net

ws sandbox: websocket.org

Unreleased Changelog:

nothing yet

Release 4.0 Changelog:

Updated HitBTC API v2.

Added ZIP installation steps for non-git-lovers.

Added HamelinRat quoting mode and Trend safety thanks to b-seite and serzhiio contributions.

Added XMR network ecosystem optional support.

Added command-line arguments.

Updated quoting engine and gateways without nodejs.

Added Makefile to replace npm scripts.

Added PNG files as configuration files.

Added built-in C++ WWW Server to replace expressjs and socketio.

Added built-in SQLite C++ interface to replace external mongodb server.

Added Poloniex API.

Release 3.0 Changelog:

Updated application name to K because of Kira.

Added nodejs7, typescript2, angular4 and reactivexjs.

Added cleanup of bandwidth, source code, dependencies and installation steps.

Added many quoting parameters thanks to Camille92 genius suggestions.

Added support for multiple instances/config files with nested matryoshka UI.

Added npm scripts, david-dm, travis-ci, coveralls and codacy.

Added historical charts to replace grafana.

Added C++ math functions.

Updated OKCoin API (since https://www.okcoin.com/t-354.html).

Updated Bitfinex API v2.

Added GDAX FIX API with stunnel.

Added Korbit API.

Release 2.0 Changelog:

Added new quoting styles PingPong, Boomerang, AK-47.

Added cleanup of database records, memory usage and log recording.

Added audio notices, realtime wallet display, and grafana integration.

Added https, dark theme and new UI elements.

Added a bit of love to Kira.

Release 1.0 Changelog:

see the upstream project michaelgrosner/tribeca.

Unlock

The bot is unlocked for collaborators and contributors (feel free to make acceptable Pull Requests for already opened issues or for anything you consider useful, and to let me know in the description of the PR the BTC Payment Address displayed in the bot that you wish to unlock, and i will credit it for you).

Meanwhile locked, market levels are limited (only are used the first 3 price levels); once unlocked the bot reads the full list of market levels (up to thousands) from the exchange.

Anonymous users can also unlock any API Key but is required a payment of 0.01210000 BTC to the address displayed in the UI of the bot, once unlocked feel free to use different currency pairs or reinstall in a different machine but keep the same unlocked API Key (changing the API Key will lock or unlock again the bot).

Alternatively use --free-version argument to anonymously unlock any API Key and avoid the payment; all market levels will be visible and usable but not in realtime, instead will be slowdown around 3 seconds with a XMR mining calculation of 21 hashes (if any hash meets the current XMR network target it will be send to my XMR pool for my fun and profit).

Otherwise if you choose to not support further development by ctubio, just keep running some old commit and do not upgrade (prior v3.0 was all unlocked).

Donations

nope, this project doesn't have maintenance costs. but you can donate to your favorite developer today! (or tomorrow!)

or see the upstream project michaelgrosner/tribeca.

or donate your time with programming or financial suggestions in the topical IRC channel ##tradingBot at irc.domirc.net on port 6697 (SSL), or 6667 (plain) or feel free to make any question, but questions technically are not donations.

Very Special Thanks to:

Help

If you need installation or usage support contact me at earn.com/analpaper (non-free high-priority service).

Issues

To request new features open a new issue and explain your improvement as you consider.

To report errors open a new issue only after collecting all possible relevant log messages.

Pull Requests are welcome, but adhere to the Contributor License Agreement:

  • Your biological and technological distinctiveness will be added to our own. Resistance is futile.

Votes

What exchange you don't want to be deleted from the bot?

like yesterday, since 0day and ∞

bcn

every new day we sing:














About

Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 49.7%
  • TypeScript 42.2%
  • Makefile 4.5%
  • Shell 2.2%
  • JavaScript 1.1%
  • HTML 0.2%
  • Ruby 0.1%