Code Monkey home page Code Monkey logo

krypto's Introduction

REFUGEES WELCOME!

Release Platform 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 Coverage Status Quality Status Dependency Status Open Issues Open Issues

Total Downloads Week Downloads Month Downloads Day Downloads

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
REST
OKCoin.com
OKCoin.cn
REST + WebSocket

Korbit
REST

All currency pairs are supported, otherwise please open a new issue to easily include any missing currency that you would like.

README

Docker Installation

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

Manual Installation

  1. Ensure your target machine has installed git, vim, make and node v8 (see node -v or nodejs -v).

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

 $ git clone ssh://[email protected]/ctubio/Krypto-trading-bot K
 $ cd K
 $ cp etc/K.json.dist etc/K.json
 $ vim etc/K.json
 $ make start

See configuration section while setting up the configuration options in your new config file etc/K.json.

make start will run K.sh in the background using forever. But also it will auto run make install to install all local dependencies in build folder and compile the application in app folder if it was not already done before.

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

Troubleshooting:

  • Create a temporary swap file (after install you can swapoff) if the installation fails with error: virtual memory exhausted: Cannot allocate memory.

  • 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.

  • Replace the certificate at dist/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 folder.

Upgrade to the latest commit

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 display of the new commit messages).

After install the latest version, all running instances will be restarted.

Multiple instances party time

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

You can list the current instances running anytime with make list.

Simple commands like make start, make stop or make restart (without any config file defined) will use the default config file etc/K.json or etc/K.png.

To run multiple instances using a collection of config files:

  1. Create a new config file with cp etc/K.json etc/X.json (with any name but .json extension).

    1. Edit the value of WebClientListenPort in the new config file to set a new port, so all applications have a unique port to display the UI.

    2. Edit the values of BotIdentifier, EXCHANGE and TradedPair in the new config file as you alternatively desire.

  2. Run the new instance with KCONFIG=X make start, also the commands make stop and make restart allow the environment variable KCONFIG, the value is simply the filename of the config file under etc folder that you want to run (without extension because could be a PNG also); this value will also be used as the uid of the process executed by forever.

  3. 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 and the config option MatryoshkaUrl.

After multiple config files are setup under etc folder, 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.

Steganographic configuration files

If you dont like to have your etc/*.json files in plain text, you can encrypt them behind any PNG image:

  1. Download any PNG file that you like and place it at etc/ folder.

  2. Rename the *.png filename to match the *.json filename (for example if you have a etc/K.json file you can rename your png file to etc/K.png).

  3. Once you have your json file all configured and your png file renamed equal than the json file (lets say the files are named K):

 $ PNG=K make png

Feel free to change the suggested filename K. Also you can run make png as many times as you update your original json file, always with PNG environment variable matching the filename of both json and png files.

  1. Delete the now useless .json file and restart the application.

  2. Keep your .png file in a secure location always, never share it. Even if your api keys and api secrets are now binary encrypted, they can still be easily readable with tools like identify -verbose etc/K.png.

Application Usage

  1. Open your web browser to connect to HTTPS port 3000 (or value of WebClientListenPort) 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 value of WebClientListenPort) 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, remove the files server.crt and server.key inside dist/sslcert folder.

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).

Test units and Build notes

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.

To ignore the output, execute the application in the background with forever start -c /bin/sh K.sh or with the alias make start.

Passing a config filename is possible with environment var KCONFIG like for example KCONFIG=X ./K.sh.

Unreleased Changelog:

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 has all features unlocked, but to support further development by ctubio, the plan soOn is to lock some features.

To unlock all features currently nothing has to be done, but maybe, soOn, a payment of 0.12100000 BTC will be required.

In case you are looking to extend the trial period, please generate a new API Key in your exchange (each API key have its own trial period). Otherwise if you choose to not support further development by ctubio, just keep running some old commit and do not upgrade.

The current payment is to support further development by ctubio to fix all bugs on the market you are paying against (an alternative Votes system).

To provide exclusivity to proefficient traders and to keep teenagers away, once the bot is bug-free, the payment required may be increased by a minimum of x3.

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.

Help

If you need installation or usage support contact me at 21.co/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 the relevant log messages (run ./K.sh to see the output).

Votes

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

like yesterday, since 0day and ∞

bcn

every new day we sing:

krypto's People

Contributors

ctubio avatar michaelgrosner avatar camille92 avatar jokot3 avatar benmarten avatar jangrewe avatar mikadily avatar samhug avatar egasimus avatar bappelt avatar charles-rumley avatar devanp92 avatar discosultan avatar josephfrazier avatar mikehostetler avatar pascal66 avatar ricardohbin avatar shanejonas avatar gitter-badger avatar waldyrious avatar zachaller avatar ahalekelly avatar

Watchers

James Cloos avatar  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.