Skip to content

uddugteam/index-daemon

Repository files navigation

index-daemon (ICEX)

Config

You can use env vars or config file. You can specify config file in CLI params (described below). If you specify config file - configs are taken from it. Else - from env vars. If you don't specify config file and you don't have configs in env vars - default configs are used.

All configs are optional.

CLI params

You can get cli params description by calling program with "-h" cli param.

  • service_config - path to service config file. Supports yaml and toml
  • market_config - path to market config file. Supports yaml and toml
  • fill_historical - fill historical data. Params: timestamp (contains comma-separated "from" and "to", "to" is optional), coins (uppercase comma-separated)

Configs

service_config

  • log_level - string. Variants: off, error, warn, info, debug, trace. Default: trace.
  • rest_timeout_sec - u64. Timeout in seconds between requests to REST API.
  • ws - string ("1" - on, default - off). Turn on websocket server.
  • ws_host - string (default: 127.0.0.1). Websocket server host.
  • ws_port - string (default: 8080). Websocket server port.
  • ws_answer_timeout_ms - u64 (min - 100, default - 100). Timeout in ms between websocket answers.
  • historical - string ("1" - on, default - off). Turn on historical data storage.
  • storage - string. Variants: sled. Default: sled.

market_config

  • exchanges - array (contains market names in lowercase. E.g. "binance")
  • coins - array (contains coin name abbreviations in uppercase. E.g. "BTC")
  • channels - array. Variants: ticker, trades, book.

Env vars format description

  • env var name must be uppercase
  • env var name is a concatenation of
    • prefix "APP"
    • config group name (e.g., "service_config")
    • config name (e.g., "log_level"), separated by a double underscore "__"
  • env var name example: "APP__SERVICE_CONFIG__LOG_LEVEL"
  • if param is array, env var value must contain string with comma-separated array values, e.g., "1,2,3"

Supported exchanges

binance bitfinex bybit coinbase ftx gateio gemini
hitbtc huobi kraken kucoin okcoin poloniex

Websocket server

Websocket server configs are described above (section Configs -> service_config -> ws)

Channels

coin_average_price

subscription request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_average_price",
  "params": {
    "coins": ["BTC", "ETH"],
    "frequency_ms": 100
  }
}

coin_exchange_price

subscription request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_exchange_price",
  "params": {
    "coins": ["BTC", "ETH"],
    "exchanges": ["binance", "coinbase"],
    "frequency_ms": 100
  }
}

coin_exchange_volume

subscription request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_exchange_volume",
  "params": {
    "coins": ["BTC", "ETH"],
    "exchanges": ["binance", "coinbase"],
    "frequency_ms": 100
  }
}

coin_average_price_historical (not a channel, but a request)

  • interval - interval between snapshots. Variants: second, minute, hour, day, week, month.
  • from - timestamp from
  • to - timestamp to

request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_average_price_historical",
  "params": {
    "coin": "BTC",
    "interval": "day",
    "from": 1643835600,
    "to": 1644440400
  }
}

coin_average_price_candles

subscription request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_average_price_candles",
  "params": {
    "coins": ["BTC", "ETH"],
    "frequency_ms": 50,
    "interval": "day"
  }
}

coin_average_price_candles_historical (not a channel, but a request)

  • interval - interval between snapshots. Variants: second, minute, hour, day, week, month.
  • from - timestamp from
  • to - timestamp to

request json example:

{
  "id": "some_id",
  "jsonrpc": "2.0",
  "method": "coin_average_price_candles_historical",
  "params": {
    "coin": "BTC",
    "interval": "day",
    "from": 1643662800,
    "to": 1644872400
  }
}

unsubscribe (not a channel, but a request)

request json example:

{
  "id": null,
  "jsonrpc": "2.0",
  "method": "unsubscribe",
  "params": {
    "method": "coin_exchange_price"
  }
}

Description

  • There can be only one subscription per channel. If you subscribe twice, then, previous subscription is declined and new subscription is activated.
  • id must be unique or null.
  • id of unsubscribe request is ignored.

Note

There's only one fiat currency supported - USD, and it's hardcoded.