aloysius-pgast / crypto-exchanges-gateway

Your gateway to the world of crypto !
586 stars 152 forks source link
api binance bittrex cryptocurrency exchanges kucoin okex poloniex trading

crypto-exchanges-gateway

Your gateway to the world of crypto !

NB: this project won't build unless you use node 14.x (check Nix for that). It's unlikely to be updated since I don't really have time to work on it anymore :)

Disclaimer

This project cannot be considered in any way as trading advice.

Use it at your own risks and be careful with your money ;)

Faq

Yes, gateway provides a WS endpoint. See video explaining how to create custom WS streams

ccxt is a very nice project which provides a library to connect to multiple exchanges (php,js,python). When I started, I wasn't aware of the project. While ccxt aims at providing a library, I want to offer an http gateway as an independant service to be used by any REST client (so virtually any language).

Btw, ccxt library is now used to interface with some exchanges ;)

There is no monthly fee. It's free since you will be the one running the service on your own server

This is a self-hosted service. You need to install it on your own server

Besides the privilege to go to bed, knowing that you did the right thing ? Not much

What it does

See a live demo at https://mpe-demo.crazyme.net/ui/

Of course, above demo does not use any valid user/token. This means the following :

In order to have a full experience, just follow installation steps

How to use it

Install it wherever you want and start sending requests from your own program

Just use you favorite language (python, javascript, ruby, bash, ...) to send request to the gateway. Your own service, your own rules !

A Node.js client is available here or as a npm package

Available Exchanges

Currently supports for following exchanges :

Following API are currently supported :

See documentation in doc directory for an overview of each REST API

See documentation in doc directory for a description of the supported websocket protocol (similar to JSON-RPC)

See documentation in doc directory for informations regarding unit tests

Alerts

Have you ever wanted to receive an alert in case ALL of the following conditions are met :

Probably not ;) Anyway, you will now be able to define this kind of custom alerts. See documentation in doc directory

It comes with built-in support for PushOver but any other notification system can be easily implemented (through third party applications) since all alert changes are emitted over a websocket endpoint (see documentation in doc directory)

Limitations

Other services

MarketCap

MarketCap module supports :

See documentation in doc directory for an overview of each API

Push Over

PushOver module supports :

See documentation in doc directory for an overview of each API)

Rate limiting

Rate limiting is implemented when required by exchange thanks to Bottleneck

Installation

npm install
cp config/config.sample.json config/config.json

Check documentation in doc directory for detailed information on each config section

node gateway.js

If you want to use the UI, follow these steps to build the UI before starting the gateway:

cd ui
npm install && ./rebuild-ui

Open http://127.0.0.1:8000/exchanges/ in your browser. You should see JSON content such as below :

["binance","bittrex","poloniex","kucoin"]

By default, only public API will be enabled. In order to access trading/private API, you need to update config.json with appropriate user and secret provided by exchange (check documentation in doc directory )

Open http://127.0.0.1:8000/marketCap/tickers?symbols=BTC,ETH in your browser. You should see JSON content such as below :

[
    {
        "symbol":"BTC",
        "name":"Bitcoin",
        "circulating_supply":17372012,
        "price_usd":6406.1049,
        "percent_change_1h":-0.08,
        "percent_change_1d":-0.08,
        "percent_change_7d":-0.15,
        "volume_24h_usd":3120534126.1266,
        "lastUpdated":1542009997,
        "market_cap_usd":111286930723.4185,
        "rank":1,
        "price_btc":1
    },
    {
        "symbol":"ETH",
        "name":"Ethereum",
        "circulating_supply":103150460,
        "price_usd":210.4854,
        "percent_change_1h":-0.39,
        "percent_change_1d":-0.39,
        "percent_change_7d":-0.8,
        "volume_24h_usd":1294093048.2094,
        "lastUpdated":1542009997,
        "market_cap_usd":21711669585.6914,
        "rank":2,
        "price_btc":0.032857
    }
]

Execute the following in a terminal :

curl -X POST 'http://127.0.0.1:8000/exchanges/bittrex/openOrders?pair=BTC-NEO&quantity=1&targetRate=0.0040'

You should see JSON content such as below :

{"orderNumber":"8bc49a59-1056-4c20-90f2-893fff2be279"}

Execute the following in a terminal :

curl -X DELETE 'http://127.0.0.1:8000/exchanges/bittrex/openOrders/8bc49a59-1056-4c20-90f2-893fff2be279'

You should see JSON content such as below in case order is valid :

{}

Docker

See this video to know how to be ready to trade in less then 3 minutes using Docker & Kitematic

A docker image is available at https://hub.docker.com/r/apendergast/crypto-exchanges-gateway/

docker pull apendergast/crypto-exchanges-gateway
docker run --rm -p 8000:8000 -p 8001:8001 --name ceg apendergast/crypto-exchanges-gateway

You should then be able to access service on http://127.0.0.1:8000

WS endpoint will be available on ws://127.0.0.1:8001

Open http://127.0.0.1:8000/exchanges/ in your browser. You should see JSON content such as below :

["binance","bittrex","kucoin","okex","poloniex"]

By default, only public API will be enabled. In order to access trading/private API, you need to pass environment when creating container. Following environment variables are available :

If you don't want to use environment variables or want to customize config for a running container, you can create and edit custom_config/config.json

Examples :

Run container with Bittrex user/key environment variables

docker run --rm -p 8000:8000 -p 8001:8001 --name ceg -e cfg.exchanges.bittrex.key='abcdefghijkl' -e cfg.exchanges.bittrex.secret='123456789' apendergast/crypto-exchanges-gateway

Dependencies

This project was made possible thanks to following projects :

Donate

This project is a work in progress. If you find it useful, you might consider a little donation ;)

BTC: 163Bu8qMSDoHc1sCatcnyZcpm38Z6PWf6E

ETH: 0xDEBBEEB9624449D7f2c87497F21722b1731D42a8

NEO/GAS: NXbbNQ2wSuavGRRffxFQrKLvSysEewzSHZ