Cannot access FIX API Password to test the FIX API using the Python example
Cannot access FIX API Password to test the FIX API using the Python example
16 Mar 2022, 11:27
Hi,
My intention is to use the FIX API together with the Python support to test and later trade against a third party broker (Skilling)
Background
I created a cTrader account which was confirmed via email. I received an email confirming my cTraderID which allowed me to log onto the cTrader website https://ct.spotware.com/ - looks like it is a public Beta.
Here I used the default demo account that was automatically issued (3463567).
I then installed various python related libraries using pop install on my Mac (12.1 Montenerey): ctrader-open-api, ctrader-fix and inputimeout (See install log below)
I then downloaded the python samples app https://github.com/spotware/cTraderFixPy and configured Intellijay Idea to execute the project.
For configuration I needed to get the FIX configuration for my account.
On the cTrade web app I went to Settings -> Advanced -> FIX API. I selected 'Change Password' and updated the password, the app gave me a confirmation that I changed successfully changed my password but did not reflect it in the Fix API screen with '*****' as I have seen in demos (see appendix)
I updated the configuration of the ConsoleSample App to reflect my configuration (see appendix);
I ran the app and got a 'connect' and submitted an example request that resulted in the error as outlined below.
I do not think this is expected behaviour, please advise
Appendix
Screenshot of FIX API configuration page.
Configuration
{ "Host": "h51.p.ctrader.com", "Port": 5201, "SSL": false, "Username": "3463567", "Password": "testing", "BeginString": "FIX.4.4", "SenderCompID": "demo.ctrader.3463567", "SenderSubID": "QUOTE", "TargetCompID": "CSERVER", "TargetSubID": "QUOTE", "HeartBeat": "30" }
Install log
Michaels-MacBook-Pro:~ Michael$ pip install ctrader-open-api
Collecting ctrader-open-api
Downloading ctrader_open_api-0.9.0-py3-none-any.whl (29 kB)
Collecting protobuf==3.19.1
Downloading protobuf-3.19.1-cp310-cp310-macosx_10_9_universal2.whl (1.0 MB)
|████████████████████████████████| 1.0 MB 1.9 MB/s
Collecting Twisted==21.7.0
Downloading Twisted-21.7.0-py3-none-any.whl (3.1 MB)
|████████████████████████████████| 3.1 MB 2.4 MB/s
Collecting incremental>=21.3.0
Downloading incremental-21.3.0-py2.py3-none-any.whl (15 kB)
Collecting hyperlink>=17.1.1
Downloading hyperlink-21.0.0-py2.py3-none-any.whl (74 kB)
|████████████████████████████████| 74 kB 2.2 MB/s
Collecting constantly>=15.1
Downloading constantly-15.1.0-py2.py3-none-any.whl (7.9 kB)
Collecting Automat>=0.8.0
Downloading Automat-20.2.0-py2.py3-none-any.whl (31 kB)
Collecting zope.interface>=4.4.2
Downloading zope.interface-5.4.0.tar.gz (249 kB)
|████████████████████████████████| 249 kB 2.2 MB/s
Preparing metadata (setup.py) ... done
Collecting attrs>=19.2.0
Downloading attrs-21.4.0-py2.py3-none-any.whl (60 kB)
|████████████████████████████████| 60 kB 2.6 MB/s
Collecting typing-extensions>=3.6.5
Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Automat>=0.8.0->Twisted==21.7.0->ctrader-open-api) (1.16.0)
Requirement already satisfied: idna>=2.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from hyperlink>=17.1.1->Twisted==21.7.0->ctrader-open-api) (3.3)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from zope.interface>=4.4.2->Twisted==21.7.0->ctrader-open-api) (57.4.0)
Using legacy 'setup.py install' for zope.interface, since package 'wheel' is not installed.
Installing collected packages: attrs, zope.interface, typing-extensions, incremental, hyperlink, constantly, Automat, Twisted, protobuf, ctrader-open-api
Running setup.py install for zope.interface ... done
Successfully installed Automat-20.2.0 Twisted-21.7.0 attrs-21.4.0 constantly-15.1.0 ctrader-open-api-0.9.0 hyperlink-21.0.0 incremental-21.3.0 protobuf-3.19.1 typing-extensions-4.1.1 zope.interface-5.4.0
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -m pip install --upgrade pip' command.
Michaels-MacBook-Pro:~ Michael$ pip install ctrader-fix
Collecting ctrader-fix
Downloading ctrader_fix-0.1.0-py3-none-any.whl (7.4 kB)
Requirement already satisfied: Twisted==21.7.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from ctrader-fix) (21.7.0)
Requirement already satisfied: incremental>=21.3.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (21.3.0)
Requirement already satisfied: hyperlink>=17.1.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (21.0.0)
Requirement already satisfied: zope.interface>=4.4.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (5.4.0)
Requirement already satisfied: typing-extensions>=3.6.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (4.1.1)
Requirement already satisfied: Automat>=0.8.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (20.2.0)
Requirement already satisfied: attrs>=19.2.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (21.4.0)
Requirement already satisfied: constantly>=15.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Twisted==21.7.0->ctrader-fix) (15.1.0)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from Automat>=0.8.0->Twisted==21.7.0->ctrader-fix) (1.16.0)
Requirement already satisfied: idna>=2.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from hyperlink>=17.1.1->Twisted==21.7.0->ctrader-fix) (3.3)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from zope.interface>=4.4.2->Twisted==21.7.0->ctrader-fix) (57.4.0)
Installing collected packages: ctrader-fix
Successfully installed ctrader-fix-0.1.0
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -m pip install --upgrade pip' command.
Michaels-MacBook-Pro:~ Michael$ pip install inputimeout
Collecting inputimeout
Downloading inputimeout-1.0.4-py3-none-any.whl (4.6 kB)
Installing collected packages: inputimeout
Successfully installed inputimeout-1.0.4
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -m pip install --upgrade pip' command.
Michaels-MacBook-Pro:~ Michael$
Replies
amusleh
16 Mar 2022, 12:14
RE: RE: Cannot access FIX API Password to test the FIX API using the Python example
Groenewald.a.m said:
I found the issue. Two things - the cTrade website did accept my password change request - but the confirmation dialog was internittent and the dialog did not show that anything was set - My suggestion would be to make it explicit in the dialog, for example: "Password: Set / Not set for acc.
3463567
Secondly, The demo's work fine. however the first instruction to be sent should be:
Command (ex: Help): LogonRequest ResetSeqNum=Y
Sent: 8=FIX.4.4|9=126|35=A|49=demo.ctrader.3463567|56=CSERVER|57=QUOTE|50=QUOTE|34=1|52=20220316-09:31:34|98=0|108=30|141=Y|553=3463567|554=testing|10=148|
Received: 8=FIX.4.4|9=106|35=A|34=1|49=CSERVER|50=QUOTE|52=20220316-09:31:34.706|56=demo.ctrader.3463567|57=QUOTE|98=0|108=30|141=Y|10=054|
After that other commands worked.
Finally, the console app after a short while breaks with the following message :
Command (ex: Help): Unhandled Error
Traceback (most recent call last):
File "/Users/Michael/IdeaProjects/cTraderFixPy-main/samples/ConsoleSample/main.py", line 125, in <module>
reactor.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 1318, in run
self.mainLoop()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 1328, in mainLoop
reactorBaseSelf.runUntilCurrent()
--- <exception caught here> ---
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 994, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/Users/Michael/IdeaProjects/cTraderFixPy-main/samples/ConsoleSample/main.py", line 80, in executeUserCommand
userInput = inputimeout("Command (ex: Help): ", timeout=30)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/inputimeout/inputimeout.py", line 32, in posix_inputimeout
termios.tcflush(sys.stdin, termios.TCIFLUSH)
termios.error: (25, 'Inappropriate ioctl for device')
Hi,
The issue is with inputimeout package that is used by console sample, it allows using a single thread to get command and keep the FIX connection alive.
Maybe inputimeout is not compatible with Mac, it works fine on Windows and Ubuntu.
You can try the web sample or Jupyter sample.
@amusleh
Groenewald.a.m
16 Mar 2022, 11:38
RE: Cannot access FIX API Password to test the FIX API using the Python example
I found the issue. Two things - the cTrade website did accept my password change request - but the confirmation dialog was internittent and the dialog did not show that anything was set - My suggestion would be to make it explicit in the dialog, for example: "Password: Set / Not set for acc.
Secondly, The demo's work fine. however the first instruction to be sent should be:
Command (ex: Help): LogonRequest ResetSeqNum=Y
Sent: 8=FIX.4.4|9=126|35=A|49=demo.ctrader.3463567|56=CSERVER|57=QUOTE|50=QUOTE|34=1|52=20220316-09:31:34|98=0|108=30|141=Y|553=3463567|554=testing|10=148|
Received: 8=FIX.4.4|9=106|35=A|34=1|49=CSERVER|50=QUOTE|52=20220316-09:31:34.706|56=demo.ctrader.3463567|57=QUOTE|98=0|108=30|141=Y|10=054|
After that other commands worked.
Finally, the console app after a short while breaks with the following message :
Command (ex: Help): Unhandled Error
Traceback (most recent call last):
File "/Users/Michael/IdeaProjects/cTraderFixPy-main/samples/ConsoleSample/main.py", line 125, in <module>
reactor.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 1318, in run
self.mainLoop()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 1328, in mainLoop
reactorBaseSelf.runUntilCurrent()
--- <exception caught here> ---
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/base.py", line 994, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/Users/Michael/IdeaProjects/cTraderFixPy-main/samples/ConsoleSample/main.py", line 80, in executeUserCommand
userInput = inputimeout("Command (ex: Help): ", timeout=30)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/inputimeout/inputimeout.py", line 32, in posix_inputimeout
termios.tcflush(sys.stdin, termios.TCIFLUSH)
termios.error: (25, 'Inappropriate ioctl for device')
@Groenewald.a.m