tribeca

在node.js中制作加密货币交易平台的高频率市场。(A high frequency, market making cryptocurrency trading platform in node.js.)

Github星跟蹤圖

Tribeca

tribeca是一个非常低延迟的加密货币市场,使得交易机器人具有全功能的Web客户端 后端测试器(backtester) ,并支持直接连接到多个加密币交换机。 在现代硬件上,它可以通过在毫秒内放置和取消订单来对市场数据做出反应。

运行最新的node.js(v7.8或更高版本)。持久性使用mongodb来实现。建议通过Docker进行安装,但也支持手动安装。

Docker compose 安装

  1. 安装 docker compose
  2. 更改 env 文件的环境变量以匹配您所需的配置。输入您的交换连接信息,帐户信息和mongoDB凭证。
  3. 运行 docker-compose up -d --build 。如果运行 docker-compose ps ,您应该看到容器正在运行。

Docker安装

  1. 在开始之前,请为您的系统安装 docker 。至少需要Docker 1.7.1。仅适用于Mac/Windows:确保boot2docker或docker-machine已设置,具体取决于Docker版本。请参阅文档获取更多帮助。
  2. 设置mongodb。如果您没有运行mongodb实例:docker run -p 27017:27017 --name tribeca-mongo -d mongo。
  3. 更改 env 文件的环境变量以匹配您所需的配置。输入您的交换连接信息,帐户信息和mongoDB凭证。
  4. 保存Dockerfile,最好是在安全的位置和空目录中。 从Dockerfile构建映像: docker build -t tribeca .
  5. 运行容器 docker run -p 3000:3000 --link tribeca-mongo:mongo --env-file ./env --name tribeca -d tribeca. 如果您运行 docker ps,则应该看到tribeca和mongo容器正在运行。

手动安装

  1. 确保您的目标机器具有节点v7.8(或更高版本)和mongoDB v3或更高版本。另外,确保Typescript 2.2,grunt和(可选)永远安装( npm install -g grunt-cli typescript forever )。
  2. 克隆存储库。
  3. 在克隆的存储库目录中,运行 npm install 以引入所有依赖关系。

  4. 通过 grunt compile 将打字稿编译为javascript。
  5. 在 tribeca/service 中输入到输出的JS文件。

  6. 根据提供的 sample-dev-tribeca.json 或 sample-prod-tribeca.json 创建一个 tribeca.json 代码>文件并将其保存在当前目录中。修改配置键(请参阅配置一节),并将实例指向正在运行的mongoDB实例。
  7. 将环境变量TRIBECA_CONFIG_FILE设置为tribeca.json的完整路径
  8. 运行永远启动main.js 以启动应用程序。

配置

  • 交换
    1. coinbase - 使用WebSocket API。如果您正在使用沙箱或实时交易环境,请确保使用正确的帐户信息设置了特定于Coinbase的属性。
    2. hitbtc - WebSocket + socket.io API。如果您使用dev或prod环境,请确保已使用正确的帐户信息设置了HitBtc特定的属性。
    3. okcoin - Websocket.Ensure已使用正确的帐户信息设置了OKCoin特定的属性。只有生产环境。
    4. bitfinex 仅适用于REST API。确保已填写Bitfinex特定的属性。 REST API不适用于毫秒级延迟交易。只有生产环境。
    5. null - 测试内存中的eXchange的。没有交换特定的配置需要。
  • TRIBECA_MODE
    1. prod
    2. dev
  • MongoDbUrl - 如果您在OS X上,请将URL中的“tribeca-mongo”更改为主机上 boot2docker ip 输出。如果您正在运行现有的mongoDB实例,请将URL替换为现有实例的URL。如果您正在Linux机器上运行并在步骤1中设置mongo,则不必修改任何内容。
  • ShowAllOrders - 显示UI中订单列表中应用程序发送的所有订单。这对于调试/测试非常有用,但会在实际交易过程中对性能造成负面影响。
  • TradedPair - 如果目标EXCHANGE支持交易货币对,则支持以下货币的任意组合:

    • USD
    • BTC
    • LTC
    • EUR
    • GBP
    • CNY
    • ETH
    • BFX
    • RRT
    • ZEC
    • BCN
    • DASH
    • DOGE
    • DSH
    • EMC
    • FCN
    • LSK
    • NXT
    • QCN
    • SDB
    • SCB
    • STEEM
    • XDN
    • XEM
    • XMR
    • ARDR
    • BTU
    • MAID
    • AMP
  • WebClientUsername和WebClientPassword - 用于 Web UI 访问的用户名和密码。如果保存为 NULL ,则Web客户端不会要求身份验证(根本不推荐!!)

在您打算进行交易的交易所的配置属性中输入交换连接信息,帐户信息和API密钥。

应用程序使用

  1. 打开您的网络浏览器以连接运行tribeca的机器的端口3000。如果您在Docker上的Mac/Windows上本地运行tribeca,请将“localhost”替换为由 boot2docker ip 返回的地址。
  2. 阅读如何在 wiki 中使用tribeca和制作市场。
  3. 根据您的喜好设置交易参数。点击“BTC/USD”按钮,以便开始进入市场。

网页界面

一旦 tribeca 启动并运行,请访问运行它的机器的端口 3000 以查看管理视图。有报价参数输入,网格显示市场订单,市场交易,您的交易,您的订单历史记录,您的头寸,以及您正在交易的货币对的大按钮。准备好后,点击绿色按钮开始发送报价。 UI使用了一个健康的socket.io和angularjs混合。

REST API

Tribeca还公开了所有数据的REST API。这些数据都是通过Web用户界面获得的数据,只需通过其他应用程序轻松连接即可。例如,访问 http://localhost:3000/data/md 获取当前市场数据。

TODO

TODO:

  1. 添加新的交换
  2. 添加新的更智能的交易策略(一如既往!)
  3. 支持不以0.01美元为单位进行交易的货币对(LTC,DOGE)
  4. 更多文件
  5. 更高性能的用户界面

捐赠

如果您想支持此项目,请考虑捐赠给1BDpAKp8qqTA1ASXxK2ekk8b8metHcdTxj

概覽

名稱與所有者michaelgrosner/tribeca
主編程語言TypeScript
編程語言JavaScript (語言數: 3)
平台Linux, Mac, Windows, Docker
許可證Other
發布數1
最新版本名稱1.0 (發布於 )
第一版名稱1.0 (發布於 )
創建於2015-07-07 18:40:45
推送於2021-12-08 19:02:31
最后一次提交2018-02-26 13:01:13
星數4k
關注者數294
派生數0.9k
提交數841
已啟用問題?
問題數158
打開的問題數109
拉請求數70
打開的拉請求數9
關閉的拉請求數13
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

tribeca

Join the chat at https://gitter.im/michaelgrosner/tribeca

tribeca is a very low latency cryptocurrency market making trading bot with a full featured web client, backtester, and supports direct connectivity to several cryptocoin exchanges. On modern hardware, it can react to market data by placing and canceling orders in under a millisecond.

Web UI Preview

Runs on the latest node.js (v7.8 or greater). Persistence is acheived using mongodb. Installation is recommended via Docker, but manual installation is also supported.

Docker compose installation

  1. Install docker compose.

  2. Change the environment variables of env file to match your desired configuration. Input your exchange connectivity information, account information, and mongoDB credentials.

  3. Run docker-compose up -d --build. If you run docker-compose ps, you should see the containers running.

Docker Installation

  1. Please install docker for your system before preceeding. Requires at least Docker 1.7.1. Mac/Windows only: Ensure boot2docker or docker-machine is set up, depending on Docker version. See the docs for more help.

  2. Set up mongodb. If you do not have a mongodb instance already running: docker run -p 27017:27017 --name tribeca-mongo -d mongo.

  3. Change the environment variables of env file to match your desired configuration. Input your exchange connectivity information, account information, and mongoDB credentials.

  4. Save the Dockerfile, preferably in a secure location and in an empty directory. Build the image from the Dockerfile docker build -t tribeca .

  5. Run the container docker run -p 3000:3000 --link tribeca-mongo:mongo --env-file ./env --name tribeca -d tribeca. If you run docker ps, you should see tribeca and mongo containers running.

Manual Installation

  1. Ensure your target machine has node v7.8 (or greater) and mongoDB v3 or greater. Also, ensure Typescript 2.2, grunt, and, optionally, forever are installed (npm install -g grunt-cli typescript forever).

  2. Clone the repository.

  3. In the cloned repository directory, run npm install to pull in all dependencies.

  4. Compile typescript to javascript via grunt compile.

  5. cd to the outputted JS files, in tribeca/service.

  6. Create a tribeca.json file based off the provided sample-dev-tribeca.json or sample-prod-tribeca.json files and save it in the current directory. Modify the config keys (see configuration section) and point the instance towards the running mongoDB instance.

  7. Set environmental variable TRIBECA_CONFIG_FILE to full path of tribeca.json

  8. Run forever start main.js to start the app.

Configuration

  • EXCHANGE

    1. coinbase - uses the WebSocket API. Ensure the Coinbase-specific properties have been set with your correct account information if you are using the sandbox or live-trading environment.

    2. hitbtc - WebSocket + socket.io API. Ensure the HitBtc-specific properties have been set with your correct account information if you are using the dev or prod environment.

    3. okcoin - Websocket.Ensure the OKCoin-specific properties have been set with your correct account information. Production environment only.

    4. bitfinex REST API only. Ensure the Bitfinex-specific properties have been filled out. REST API is not suitable to millisecond latency trading. Production environment only.

    5. null - Test in-memory exchange. No exchange-specific config needed.

  • TRIBECA_MODE

    1. prod

    2. dev

  • MongoDbUrl - If you are on OS X, change "tribeca-mongo" in the URL to the output of boot2docker ip on your host machine. If you are running an existing mongoDB instance, replace the URL with the existing instance's URL. If you are running from a Linux machine and set up mongo in step 1, you should not have to modify anything.

  • ShowAllOrders - Show all orders sent from the application in the Orders List in the UI. This is useful for debugging/testing, but can really negatively impact performance during real trading.

  • TradedPair - Any combination of the following currencies are supported, if the target EXCHANGE supports trading the currency pair:

    • USD
    • BTC
    • LTC
    • EUR
    • GBP
    • CNY
    • ETH
    • BFX
    • RRT
    • ZEC
    • BCN
    • DASH
    • DOGE
    • DSH
    • EMC
    • FCN
    • LSK
    • NXT
    • QCN
    • SDB
    • SCB
    • STEEM
    • XDN
    • XEM
    • XMR
    • ARDR
    • WAVES
    • BTU
    • MAID
    • AMP
  • WebClientUsername and WebClientPassword - Username and password for web UI access. If kept as NULL, no the web client will not require authentication (Not recommended at all!!)

Input your exchange connectivity information, account information, and API keys in the config properties for the exchange you intend on trading on.

Application Usage

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

  2. Read up on how to use tribeca and market making in the wiki.

  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 tribeca is up and running, visit port 3000 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.

REST API

Tribeca also exposes a REST API of all it's data. It's all the same data you would get via the Web UI, just a bit easier to connect up to via other applications. Visit http://localhost:3000/data/md for the current market data, for instance.

TODO

TODO:

  1. Add new exchanges

  2. Add new, smarter trading strategies (as always!)

  3. Support for currency pairs which do not trade in $0.01 increments (LTC, DOGE)

  4. More documentation

  5. More performant UI

Donations

If you would like to support this project, please consider donating to 1BDpAKp8qqTA1ASXxK2ekk8b8metHcdTxj

去到頂部