python-okcoin-fix
python-okcoin-fix copied to clipboard
python-okcoin-fix
Python example for OKCoin FIX api
This is a simple python example for OKCoin FIX API.
Since quickfix api for python does not support SSL as in java case, we should use manual tunneling using stunnel
.
Because of that, the configuration file for quickfix api for using OKCoin should be slightly different from C# and Java case.
Note: I'm using python 2.7
Prerequisites
-
quickfix
- ssl tunneling (
openssl
andstunnel
)
Install prerequisites
- Install
quickfix
python api
pip install quickfix
- Install
openssl
andstunnel
See https://github.com/lim0606/python-okcoin-fix/tree/master/docs/stunnel
Install this example
- Download this repository
git clone https://github.com/lim0606/python-okcoin-fix.git
- Set OKCoin API keys
- Copy the example configuration file
cp my_api.py.example my_api.py
- Change the below lines with your api keys
api_key='your api key here'
secret_key='your secret key here'
- Set quickfix configuration file
- Copy the example configuration file
cp okcoin.cfg.example okcoin.cfg
- Open the configuration file
vim okcoin.cfg
- Change the line with the same used in tunneling (i.e. your ip address in this example)
SocketConnectHost=Your ip address here
Note: So this application communicates with OKCoin server via tunneling installed as prerequisites. That is why this setting is different from C# or Java example in OKCoin repo.
Note: We used <your ip address>
in stunnel
's configuration file
- Change the line with user defined client name (e.g. generated using UUID)
SenderCompID=SenderCompID user defined client name(e.g. generated using UUID)
- Run
python okcoin.py
Note: spec/FIX44.xml is copied from https://github.com/OKCoin/fix/blob/master/c%23/FixDemo/config/FIX44.xml
References
- https://github.com/tianyilai/QuickFix-python-client
- https://futures.io/matlab-r-project-python/35213-python-quickfix.html
- https://github.com/OKCoin/fix/blob/9e45e651cfada4a4c59cd51a40666cd33f22070b/java/src/com/okcoin/fix/OKClientApplication.java
- https://github.com/OKCoin/fix/blob/85679c5f6793963c2bdaf03b72d6cb00d3b04cf7/c%23/FixDemo/bin/Debug/config/quickfix-client.cfg