Skip to main content

cTraderFixPy

PyPI version versions GitHub license

A Python package for interacting with cTrader FIX API.

This package uses Twisted and it works asynchronously.

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

Metadata

Release files for ctrader-fix 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctrader-fix 0.1.1
File Size Uploaded
ctrader_fix-0.1.1.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ctrader-fix 0.1.1
File Interpreter ABI Platform
ctrader_fix-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / ctrader_fix-0.1.1.tar.gz

Download URL ctrader_fix-0.1.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4906a664663c82aa153db84cdabedf5590f6716e4512eb15e6f04ec6fe41e40d
BLAKE2b-256 checksum
How to use checksums
3e2a0b275d7a78e10f3068bb9f8f2456201267d0ee70cfded95cea7f8930b66d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1021-azure

Release files / ctrader_fix-0.1.1-py3-none-any.whl

Download URL ctrader_fix-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bc2f143350ef70900bba1cfd1ab7f7aebe7f9379c966bf8f88a5c02eb7b0ed5
BLAKE2b-256 checksum
How to use checksums
1c9f2821bd77005cf172ae2a4a6bfa9b1fae2213ebd8585b5c9c664149bf6eab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1021-azure

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page