API Configuration¶
The API is best configured using a Window’s style INI file.
It is common to configure the API by supplying the name of the INI on a call Session.create_from_ini_file()
.
If no filename is provided then the Session
will look for a file called
.bidfx/api/config.ini
in the user’s home directory.
Configuration methods¶
There are three ways to provide a configuration for the API:
- by using a default config file located in your home directory
- specifying a named config file from any location
- creating a config in code.
Default configuration¶
For convenience, all of configuration items may be provided through a single configuration object. The API uses a ConfigParser to read its configuration from a Windows-style INI file.
The config file is commonly located at $HOME/.bidfx/api/config.ini
.
When using the default INI file location, the Session
can be created and configured as follows.
from bidfx import Session
session = Session.create_from_ini_file()
Non-standard configuration file¶
The config file location may be changed by passing a in file name to Session.create_from_ini_file()
.
from bidfx import Session
session = Session.create_from_ini_file("./my_config.ini")
INI file sections¶
There is four sections in the configuration INI file:
[DEFAULT]
- defines shared properties such as host and port.[Exclusive Pricing]
- is for overrides and properties particular to Exclusive Pricing (Pixie protocol).[Shared Pricing]
- is for overrides and properties particular to Shared Pricing (Puffin protocol).
Default section¶
The [DEFAULT]
section provides default properties that are shared by the other sections.
At present all four protocols can be accessed by tunnelling via a single host on secure port 443.
The required user credentials are also the same for all usages of the API.
These data can therefore be defined once in the [DEFAULT]
section of the configuration.
Should this situation change then it is possible to override default settings in the each specific sections.
Exclusive pricing section¶
Exclusive pricing by contrast is not shared across users. It is exclusive to one particular user or group of users. Tradable FX OTC prices direct from liquidity providers are exclusive to the subscribing user. The BixFX API currently implements the Pixie protocol for subscribing to exclusive pricing from BidFX price servers.
The configuration of the Price Provider for exclusive pricing uses the following properties:
- host
- port
- username
- password
- product_serial
- default_account
- min_interval
Example INI config file¶
[DEFAULT]
# The host and port number of the BidFX service to connect to.
host = api.ld.bidfx.biz
port = 443
# Provide the API login credentials provided by your BidFX account manager.
username = smartcorp_api
password = 4EL77HqPC2W8hQut
# If you have an API serial key then set it below otherwise leave it blank.
# product_serial = aad33247deffe2aa2832001f
[Exclusive Pricing]
# Use this section to override DEFAULT settings for user-exclusive pricing.
# When subscribing to user-exclusive quotes, the prices consumed may vary by account.
# A default account is defined here for use no explicit account has been provided.
default_account = GIVE_UP_ACCT
# The minimum price publication interval is given below in milliseconds.
min_interval = 500
[Shared Pricing]
# Use this section to override DEFAULT settings for use with shared pricing.