Service that provides API for listening and collecting data for different instruments from Binance and FTX cryptoexchanges.
- If you use manual install, you need Python 3.8 and corresponding pip3 (maybe newer versions are also suitable, but this is not guaranteed).
- If you prefer docker-compose usage instead, you need installed and launched docker and docker-compose.
- MySQL database installed and started. Guide for Ubuntu.
- Also you should have Binance and FTX API keys. FTX and Binance guides.
Once you have installed everything and downloaded all the necessary tools, you can move on to start up:
-
Clone project using
git clone https://github.com/egor-bystepdev/saver-cryptoexchange
andcd saver-cryptoexchange
. -
To install dependencies run
pip3 install -r requirements.txt
. -
After that, put your API keys and secrets into environment variables
ftx_api_key
,ftx_api_secret
,binance_api_key
andbinance_api_secret
. -
Also if and only if you have password for MySQL database (to check execute
sudo mysql -u root
, if no password field appear, skip that step) set ENV variablesql_password
equals to it. -
Optionally, adjust
listener/config.json
(it is responsible for instruments which start being listened immediately after API launch). For example, config.json can look like this:{ "checker_cooldown_s" : 600, "fatal_time_for_socket_s" : 300000, "symbols_in_start" : [ { "exchange" : "binance", "symbol" : "BNBBTC" }, { "exchange" : "ftx", "symbol" : "BTC/USDT" } ] }
-
And finally,
python3 api.py
to run the API.
- Put your API keys and secrets into environment variables
ftx_api_key
,ftx_api_secret
,binance_api_key
andbinance_api_secret
. - Also if and only if you have password for MySQL database (to check execute
sudo mysql -u root
, if no password field appear, skip that step) set ENV variablesql_password
equals to it. - Run
docker-compose up -d
.
- To get data, send GET request to
http://hostname:8080/
with setexchange
,instrument
,start_timestamp
andfinish_timestamp
(in ms) parameters. For example, to get data for BNBBTC instrument from Binance exchange check URLhttp://hostname:8080/?exchange=binance&instrument=BNBBTC&start_timestamp=1652991738435&finish_timestamp=1652991739435
. - To start listening for instrument, send GET request to
http://hostname:8080/start
with set parametersexchange
andinstrument
. For instance, to start listening data for BTC/USDT pair from FTX exchange check URL
http://localhost:8080/start?exchange=ftx&instrument=BTC%2FUSDT
. - To stop listening of instrument, send similar GET request to
http://hostname:8080/stop
.
To get metrics collected by Prometheus, check http:://hostname:9090/graph
.
In logs/
directory you can observe .log files, info and error messages about everything that happens in the programme are written there.