logo

OpenFinex configuration

OpenFinex configuration is stored in config/config.yaml.

#Database configuration

Finex currently support only MySQL driver.

database:
  driver: mysql
  name: peatio_development
  username: root
  password: ""
  host: database
  port: 3306

#InfluxDB configuration

InfluxDB is used to fetch klines from the API.

influx:
  url: http://localhost:8086
  database: peatio_production
  username: ""
  password: ""

InfluxDB sharding

You can enable the sharding of InfluxDB to split series over multiple servers to reduce the load of reads and writes operations of every single InfluxDB instance. The market id is used as sharding key, so one instance of InfluxDB will contain all series of a given market. To configure the sharding in Finex you need to provide the list of InfluxDB services to use separated by a coma in the URL field. If you use Peatio to write to InfluxDB make sure Finex and Peatio are configured with the same list of servers in the same order.

Re-balancing shards

To add or remove shards from the configuration you need to re-balance the data over shards. You can re-balance the market data using the following command:

influx rebalance --new-urls http://influx-1:8086,http://influx-2:8086

:warning: Notice that you can only add or remove shards at the end of the list, to replace a server from the list you would need to copy the database from the old server to the new one manually.

Disabling connection to InfluxDB

To disable features associated with InfluxDB (KLines API) you can omit the influx section in the config.yaml.

#Gateway orders create rate limits

Different rate limits can be applied for orders creation depending on users role.

This is configured in the section gateway.rate.

Note: It is not an API rate limit mechanism.

gateway:
  rate:
    maker:
      - limit: 500
        period: 10s
    default:
      - limit: 50
        period: 10s
      - limit: 10000
        period: 24h

The only mandatory role is default, this is the default configuration applied if a role doesn't have explicit settings.

  • role - user role defined in barong.
  • config - list of limit-period pairs. So it limits to Not more than {limit} requests per {period}.

#API request rate limits

Finex also has API-level rate limiter. The configuration is stored in config/config.yaml in the section api.rate.

api:
  rate:
    maker:
      limit: 500
      period: 10s
    default:
      limit: 500
      period: 10s

It works similarly to the gateway orders create rate limits, but supports only one limit per role.

#Bulk API limits

The maximum number of orders contained in bulk create/cancel order API request can be configured by the entry api.bulk_limit.

api:
  bulk_limit: 100

#Restrict features access

You can limit openfinex feature access to users with a specific role and a minimum KyC level. This is configure in the section api.actions.

The following configuration limits the bulk API endpoints to be accessed only by users with the role maker and a minimum of KyC level 3, regular trading endpoints (single order create, cancel) are allowed to other roles with a minimum KyC level 2.

api:
  actions:
    trade:
      min_level: 2
      roles: [member, broker, trader, maker]
    bulk_api:
      min_level: 3
      roles: [maker]

#Filters

You can configure specific filters applied to orders in Finex. If an order doesn't respect the rules it will be rejected by the API.

Significant digits filter

This filter allows to configure the number of significant digits for orders price.

For the following example:

api:
  filters:
    - type: significant_digits
      digits: 5

The following prices will be accepted:

1.2345
12.345
123.45
1234.5
0.012345

Custom price steps

This filter allows you to configure more fine gain steps in price depending on price range. The configured step is applied if the price is lower than the limit. Rules are applied in order.

Example:

api:
  filters:
    - type: custom_price_steps
      rules:
        - { limit: 10, step: 0.01 }
        - { limit: 100, step: 0.1 }
        - { limit: 1000, step: 1 }
        - { limit: 10000, step: 5 }
        - { limit: 100000, step: 10 }
        - { limit: 0, step: 1000 }

The following prices will be accepted:

9.99
99.9
999
9995
99990
1001000

Configure on which markets applies a filter

A filter can be applied on multiple markets using include and exclude configuration entries.

Examples:

Apply a filter on a specific market:

api:
  filters:
    - type: significant_digits
      digits: 5
      markets:
        include:
          - id: btcusd

Apply a filter on all usd quoted markets:

api:
  filters:
    - type: significant_digits
      digits: 5
      markets:
        include:
          - quote: usd

Apply a filter on all usd quoted markets except btcusdt:

api:
  filters:
    - type: significant_digits
      digits: 5
      markets:
        exclude:
          - base: btc
        include:
          - quote: usd

Apply a filter on all usd and btc quoted markets:

api:
  filters:
    - type: significant_digits
      digits: 5
      markets:
        include:
          - quote: btc
          - quote: usd