Krypto-trading-bot

node.js、angular、typescript和c++中的自托管加密交易机器人(自动高频市场制作)。【 Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++. 】

Github星跟蹤圖

K 是一个非常低延迟的造市交易机器人,具有功能齐全的Web界面。这款机器人可以在一台不错的机器上,用不到几毫秒的时间,在几家受支持的加密币交易所之一下订单或取消订单。

最新版本在https://github.com/ctubio/Krypto-trading-bot

在unix类系统上运行。 通过内置的无服务器SQLite C++接口实现持久性。 支持通过Docker进行安装,但建议在专用的Debian/Raspbian、CentOS或macOS实例中进行手动安装。

Web UI与大多数Web浏览器/设备/分辨率兼容,但建议使用1600px的Firefox或Chrome。 不需要配置任何Web服务器(除非安装在您自己的反向代理之后)。

概覽

名稱與所有者ctubio/Krypto-trading-bot
主編程語言C++
編程語言Shell (語言數: 8)
平台BSD, Docker, Linux, Solaris, Unix-like
許可證Other
發布數6
最新版本名稱0.6.x (發布於 )
第一版名稱1.0 (發布於 )
創建於2017-06-13 20:15:54
推送於2022-09-18 23:11:54
最后一次提交2021-12-08 19:01:54
星數3.3k
關注者數237
派生數808
提交數5.3k
已啟用問題?
問題數1021
打開的問題數74
拉請求數81
打開的拉請求數2
關閉的拉請求數34
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

self reminder:patience is the mother of science*** REFUGEES WELCOME! ***     *** FATAL ROUTES? ***

Release
Platform
g0t0 Counter
Code Size
Software License
Software License

K is a very low latency market making trading bot with a fully featured web interface. The bot can place and cancel orders on one of several supported cryptocoin exchanges in less than a few miliseconds per order on a decent machine.

Latest version at https://github.com/ctubio/Krypto-trading-bot

Build Status
Coverage Status
Quality Status
Open Issues
Last Commit
Downloads Last 21 Commits

Runs on unix-like systems. Persistence is achieved through a built-in server-less SQLite C++ interface. Installation via Docker is supported, but manual installation in a dedicated Debian/Raspbian, Red Hat, CentOS or macOS 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, BitMEX (fees)REST + WebSocket, none, with Maker and Taker fees, Coinbase (fees)REST + WebSocket + FIXHitBTC (fees)Bequant (fees)REST + WebSocketBitfinex (fees)Ethfinex (fees)REST + WebSocketKraken (fees)RESTPoloniex (fees)REST, FCoin (fees)REST + WebSocket, 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 git, make and vim installed.

  3. Download it wherever you want (feel free to customize the suggested folder name K) and execute the installer:

 $ git clone ssh://git@github.com/ctubio/Krypto-trading-bot K
 $ cd K
 $ make install
  1. Open the config file in your favorite text editor:
 $ 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 curl, make and vim installed.

  3. Download it wherever you want (feel free to customize the suggested folder name K) and execute the installer:

 $ mkdir K
 $ cd K
 $ curl https://raw.githubusercontent.com/ctubio/Krypto-trading-bot/master/Makefile > Makefile
 $ make install
  1. Open the config file in your favorite text editor:
 $ 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, you can start the bot:

 $ ./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.

  • Use your own SSL certificate with --ssl-crt and --ssl-key, see web ui section. Otherwise, the unsecure built-in certificate 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 very end of the file contains the code that starts the bot.

Upgrade to the latest commit

After reinstalling, you will need to manually restart any running instances using make restart or make restartall.

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

If you only use git to pull the latest commits, you will still need to recompile using make reinstall (or using make dist K or just make if you have modified source files) and then make restart to start using the latest version.

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

You can list the current running instances with make list.

If you haven't defined a config file, make start, make screen, make stop and make restart 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 vim X.sh

  3. Run the new instance with ./X.sh or to run in the background, use K=X.sh make start. To attach to the new instance's screen, use K=X.sh make screen. To stop the new instance, use K=X.sh make stop and to restart it, use K=X.sh make restart. The environment variable K specifies the filename of the config file that you want to use.

  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. Use the web UI to change the quoting parameters. Click the "BTC/USD" button to start making markets. Click it again to stop. When the button is green, the bot is actively placing orders.

Web UI

Once K is up and running, visit HTTPS port 3000 (or your configured port number) to access the UI (i.e. https://localhost:3000). 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 angularjs hydrated with websockets 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 with WAL mode enabled.

All database files are located at /var/lib/K/db/K-*.db*, outside the download folder to survive wild rm -rf path/to/K or reinstalls.

You can copy any group of *.db* files to another machine when migrating or as a backup.

If a database does not exist, the application will create it on boot; otherwise, it will use the existing one.

To explore each database you can use https://github.com/sqlitebrowser/sqlitebrowser or a similar tool.

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

Even if using an in-memory database, the quoting parameters are always loaded from and saved into the disk file database.

Charts

The metrics are not saved anywhere, it is just UI data collected with a visibility retention of n hours (where n is the value of profit quoting parameter), 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 (i'm a user since 2008).

Build notes

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

To rebuild the application with your modifications, see make help and choose a target (just make may be what you are looking for).

Test units are executed before the application exits, only if the application was compiled with KUNITS=1 make.

Otherwise, just make without the environment var KUNITS produces an application that simply exits on exit.

A quick test runner therefore is ./K.sh --version or the alias make test or all at once with KUNITS=1 make K test.

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

Updated exchange integrations as simple libcurl wrappers.

Added main KryptoNinja class derived from all other classes and ready to be extended.

Added C++ OOP everywhere.

Added test units.

Added --interface=IP argument to bind outgoing traffic to a specific network interface.

Added Ethfinex and FCoin API.

Added build-in document root to stop reading files from disk.

Added build chain for win32.

Updated OKEx websocket to binary data.

Added build chain for OSX v10.13.

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

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 Coinbase FIX API.

Added Korbit API.

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.

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 let me know the BTC Payment Address for the bot that you wish to unlock in the description of the PR, and I will credit it for you).

While locked, the orderbook will be not in realtime, instead market price levels will be updated only once every 7 seconds.

Anonymous users can also unlock any API Key by paying 0.01210000 BTC to the address displayed. Once unlocked you may use different currency pairs or reinstall on a different machine with the same unlocked API Key. However, if you want to use more than one exchange, you will need to pay again to unlock the API Key for each exchange.

Otherwise if you choose to not support further development by ctubio, just keep running some old commit and do not upgrade (any commit prior to v0.3.0 was completely unlocked).

Please don't open issues asking how much % less the bot generates with --free-version; it is relative to your trading strategy, the market conditions, and the bot's performance.

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 IRC channel #tradingBot at irc.freenode.net on port 6697 (SSL), or 6667 (plain); or feel free to make any question, but questions technically are not donations.

General Discussion

IRC is awesome!

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.

like yesterday, since 0day and ∞

bcn

every new day we sing:

去到頂部