A Python package for interacting with cTrader FIX API
Project description
cTraderFixPy
A Python package for interacting with cTrader FIX API.
This package uses Twisted and it works asynchronously.
- Free software: MIT
- Documentation: https://spotware.github.io/cTraderFixPy/.
Features
-
Works asynchronously by using Twisted
-
Allows you to easily interact with cTrader FIX API and it manages everything in background
-
Generate FIX message by using Python objects
Insallation
pip install ctrader-fix
Config
Config file sample:
{
"Host": "",
"Port": 0,
"SSL": false,
"Username": "",
"Password": "",
"BeginString": "FIX.4.4",
"SenderCompID": "",
"SenderSubID": "QUOTE",
"TargetCompID": "cServer",
"TargetSubID": "QUOTE",
"HeartBeat": "30"
}
Usage
from twisted.internet import reactor
import json
from ctrader_fix import *
# Callback for receiving all messages
def onMessageReceived(client, responseMessage):
print("Received: ", responseMessage.getMessage().replace("", "|"))
messageType = responseMessage.getFieldValue(35)
if messageType == "A":
print("We are logged in")
# Callback for client disconnection
def disconnected(client, reason):
print("Disconnected, reason: ", reason)
# Callback for client connection
def connected(client):
print("Connected")
logonRequest = LogonRequest(config)
send(logonRequest)
# you can use two separate config files for QUOTE and TRADE
with open("config-trade.json") as configFile:
config = json.load(configFile)
client = Client(config["Host"], config["Port"], ssl = config["SSL"])
# Setting client callbacks
client.setConnectedCallback(connected)
client.setDisconnectedCallback(disconnected)
client.setMessageReceivedCallback(onMessageReceived)
# Starting the client service
client.startService()
reactor.run()
Please check documentation or samples for a complete example.
Dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctrader_fix-0.1.1.tar.gz.
File metadata
- Download URL: ctrader_fix-0.1.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4906a664663c82aa153db84cdabedf5590f6716e4512eb15e6f04ec6fe41e40d
|
|
| MD5 |
071aa3a8855a33964e298c1478579864
|
|
| BLAKE2b-256 |
3e2a0b275d7a78e10f3068bb9f8f2456201267d0ee70cfded95cea7f8930b66d
|
File details
Details for the file ctrader_fix-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ctrader_fix-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bc2f143350ef70900bba1cfd1ab7f7aebe7f9379c966bf8f88a5c02eb7b0ed5
|
|
| MD5 |
c543be9135504c4a81b8488da484dc38
|
|
| BLAKE2b-256 |
1c9f2821bd77005cf172ae2a4a6bfa9b1fae2213ebd8585b5c9c664149bf6eab
|