Home

Awesome

crypto-exporter

Pipeline Status Docker Stars Docker Pulls Docker Image Version (latest) Docker Image Size (latest) Gitlab Project

Prometheus exporter, written in python, for different crypto exchanges

Archive Notice

Please note that this software is no longer maintained and will no longer receive any updates.

Documentation

Warning: This documentation applies for version v1.x.x.

Note: Please open any issues or pull/merge requests in GitLab.

Check out the docs/ folder.

Contributing

Please read how to contribute and the code of conduct.

Features

The crypto-exporter generates three sets of metrics. You can also get only the account_balance for off-exchange accounts (see: Off-Exchange Balances)

exchange_rate

The exchange rates for the symbols traded. Use this to get the tickers.

Example:

# HELP exchange_rate Current exchange rates
# TYPE exchange_rate gauge
exchange_rate{currency="BTC",exchange="bitfinex",reference_currency="USD"} 9386.9
exchange_rate{currency="LTC",exchange="bitfinex",reference_currency="USD"} 70.256
exchange_rate{currency="LTC",exchange="bitfinex",reference_currency="BTC"} 0.007498
exchange_rate{currency="ETH",exchange="bitfinex",reference_currency="USD"} 182.59
exchange_rate{currency="ETH",exchange="bitfinex",reference_currency="BTC"} 0.019445
exchange_rate{currency="ETC",exchange="bitfinex",reference_currency="BTC"} 0.0012486
exchange_rate{currency="ETC",exchange="bitfinex",reference_currency="USD"} 11.712
exchange_rate{currency="RRT",exchange="bitfinex",reference_currency="USD"} 0.0234

Account balance

Warning: To see the account balance, authentication is mandatory.

Example:

# HELP account_balance Account Balance
# TYPE account_balance gauge
account_balance{account="total",currency="XRP",exchange="kraken"} 279.39357642
account_balance{account="total",currency="XLM",exchange="kraken"} 14.0003552
account_balance{account="total",currency="ETH",exchange="kraken"} 9.29332537

Transaction totals

Warning To see the totals, authentication is mandatory.

Example:

# HELP transactions_total The transaction history for an account
# TYPE transactions_total gauge
transactions_total{currency="XLM",exchange="coinbase",reference_currency="EUR",type="trade"} -60.0
transactions_total{currency="XRP",exchange="coinbase",reference_currency="EUR",type="trade"} -50.0
transactions_total{currency="LTC",exchange="coinbase",reference_currency="EUR",type="trade"} -108.18
transactions_total{currency="ETH",exchange="coinbase",reference_currency="EUR",type="trade"} 149.5100000000007
transactions_total{currency="BTC",exchange="coinbase",reference_currency="EUR",type="trade"} -1639.779999999999

See also ENABLE_TRANSACTIONS

Usage

docker run --rm -it -p 9999:9999 \
  -e EXCHANGE="coinbasepro" \
  -e NONCE="seconds" \
  -e API_KEY="your_api_key" \
  -e API_SECRET="your_api_secret" \
  -e API_PASS="your_api_password" \
  -e REFERENCE_CURRENCIES="USD,EUR" \
  -e SYMBOLS="LTC/BTC,ETH/BTC" \
  -e GELF_HOST="graylog" \
  -e GELF_PORT="2201" \
  -e LOGLEVEL=DEBUG \
  -e PORT=9999 \
  --name coinbasepro-exporter \
  registry.gitlab.com/ix.ai/crypto-exporter:latest

Supported variables

VariableDefaultMandatoryDescription
EXCHANGE-YESSee below Tested exchanges
API_KEY-NOSet this to your Exchange API key
API_SECRET-NOSet this to your Exchange API secret
API_PASS-NOOnly needed for certain exchanges (like coinbasepro)
API_UID-NOOnly needed for certain exchanges (like cex)
NONCEmillisecondsNOSome exchanges (looking at you, coinbasepro) don't support nonce in milliseconds, but want seconds
ENABLE_TICKERStrueNOSet this to anything else in order to disable retrieving the ticker rates
ENABLE_TRANSACTIONSfalseNOSet this to true in order to enable retrieving the transaction totals. See also below ENABLE_TRANSACTIONS
DISABLE_FETCH_TICKERSfalseNOSet this to true in order to use the slower method for fetching the tickers instead. See also Multiple Tickers For All Or Many Symbols
SYMBOLS-NOSee below for explanation (SYMBOLS and REFERENCE_CURRENCIES)
REFERENCE_CURRENCIES-NOSee below for explanation (SYMBOLS and REFERENCE_CURRENCIES)
DEFAULT_EXCHANGE_TYPE-NOSome exchanges support multiple types (for example: binance supports future). You can set this here
TIMEOUT10NOTimeout in seconds for each request sent to an exchange API
LOGLEVELINFONOLogging Level. Additionally, you can specify TRACE for a really verbose logging
GELF_HOST-NOIf set, the exporter will also log to this GELF capable host on UDP
GELF_PORT12201NOIgnored, if GELF_HOST is unset. The UDP port for GELF logging
PORT9188NOThe port for prometheus metrics

Note: Look at Off-Exchange Balances for additional supported environment variables.

SYMBOLS and REFERENCE_CURRENCIES

Since not all exchanges support getting the ticker with one request (coinbase, coinbasepro, bitstamp), crypto-exporter has to request for every traded pair the exchange rate. This takes a lot of time, especially if there are a lot of pairs traded (>50 minutes for one run with coinbase).

If you're only interested in a subset of those trade pairs, you can:

The two variables are cumulative. If you set both, for example REFERENCE_CURRENCIES=EUR and SYMBOLS=BTC/USDT, you will get the results for all trading pairs for EUR and BTC/USDT.

ENABLE_TRANSACTIONS

Note This metric is gathered for all the individual accounts that are found. If the exchange created a lot of currency accounts for you, it will take a while to query all

This metric can be interpreted as follows (from the example above):

transactions_total{currency="XRP",exchange="coinbase",reference_currency="EUR",type="trade"} -50.0
transactions_total{currency="ETH",exchange="coinbase",reference_currency="EUR",type="trade"} 149.5100000000007
transactions_total{currency="EUR",exchange="kraken",reference_currency="XLM",type="trade"} -596.117
transactions_total{currency="XLM",exchange="kraken",reference_currency="EUR",type="trade"} 69.14959999999999

This option is disabled by default, since there aren't many exchanges that support it and it increases the time, by querying the exchange. So far, it has been tested successfully with coinbase and kraken.

Tested exchanges

Limited tests (without API credentials) have been done with:

All other exchanges supported by ccxt should work as well, however they are untested.

Tags and Arch

Starting with version v0.5.1, the images are multi-arch, with builds for amd64, arm64, armv7 and armv6.

Resources: