Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Imhotep), 567 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
In progress/POC cTrader FIX plugin #472600
05/07/18 15:17
05/07/18 15:17
Joined: Jan 2016
Posts: 122
V
Veratyr Offline OP
Member
Veratyr  Offline OP
Member
V

Joined: Jan 2016
Posts: 122
I've got something somewhat usable so I figured I'd share it in case anyone has any feedback before I make the code even shittier grin

Here's the source code.

Here's the DLL.

How to use:

  • Put a ctfix.ini in your Plugins directory. There's a sample configuration here. You should only need to change SocketConnectHost, SenderCompID, Username and Password, all of which you can find in the cTrader platform your broker provides in one of the menus labeled "FIX Credentials".
  • Set up your assets. cTrader's FIX API has numeric codes for all assets rather than names. There's a mapping of symbol -> FIX ID here but unlike other plugins, for the moment at least, you must add an account specific prefix with a dash to your assets. Where you'd write "1" (for EURUSD), you must instead write "broker-1" or "Oanda-1" or "FXCM-1" etc. My code is written to require a dash in all asset names.


What's working:


  • Connecting
  • Logging in
  • Multiple accounts
  • Subscribing to assets
  • Receiving data for assets


What's not working (yet):

  • Trading
  • Good, readable code


What will never work:

  • Account balances
  • Price history


I understand that without trading this is of limited use, I'm more putting it out there for anyone who cares to play with it to research arbitrage or something and so I can point people to code when I need help after breaking something.

I'll also add that this code is tailored specifically to cTrader. If you want it to work with another broker, more likely than not, you'll have to modify the code to do what your broker wants.

Last edited by Veratyr; 05/07/18 15:21.
Re: In progress/POC cTrader FIX plugin [Re: Veratyr] #472601
05/07/18 17:02
05/07/18 17:02
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
If you don't mind me asking, have you had good experiences with QuickFix?

I ask because while implementing the DTC plugin, I stumbled across this complaint from the Sierra Chart staff:
https://www.sierrachart.com/SupportBoard.php?ThreadID=15382
Quote:
We have a very poor impression of Quick FIX and consider it very substandard quality and buggy.
I'm not sure what kind of bugs they are talking about. They do appear to have strong opinions and think highly of their programming ability.

Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD] #472603
05/07/18 19:14
05/07/18 19:14
Joined: Jan 2016
Posts: 122
V
Veratyr Offline OP
Member
Veratyr  Offline OP
Member
V

Joined: Jan 2016
Posts: 122
Originally Posted By: AndrewAMD
If you don't mind me asking, have you had good experiences with QuickFix?

I ask because while implementing the DTC plugin, I stumbled across this complaint from the Sierra Chart staff:
https://www.sierrachart.com/SupportBoard.php?ThreadID=15382
Quote:
We have a very poor impression of Quick FIX and consider it very substandard quality and buggy.
I'm not sure what kind of bugs they are talking about. They do appear to have strong opinions and think highly of their programming ability.


Frankly I came across two open source C++ FIX engines: fix8 and QuickFIX.

fix8's docs were horrible and hidden in a wiki that needed an account and even with access to them, it was a bitch to get anything working. I gave it a go on Mac at first, where C++ dev is a little less shitty but even there it was horrible. The thought of getting all its dependencies working on Windows put me right off it. I never actually got fix8 to work.

QuickFix had nice clear docs, only depended on OpenSSL (which I already had installed on Mac) and took very minimal effort to get successfully connected to a broker. On Windows, I installed OpenSSL binaries, built QuickFix itself with cmake and got it working with few problems.

I didn't want to pay for one of the commercial options. I'm sure they have better performance and if you buy a support contract they'll do whatever you need but this is a hobby for me, not a profession. Plus, I think anything super low latenc will be wasted on a Zorro plugin; I don't think Zorro can compete with a proper C++ implementation, which for arbitrage at least is pretty trivial.

Anyhow, I'm pretty happy with QuickFix. It's easy to install, easy to use, I haven't run into any bugs, the docs are easy to read and the code I've looked at (mainly session management and settings code) has been pretty clear and tidy.

I think the Sierra Chart people are full of themselves. There's some more feedback here, which is mostly positive: https://quant.stackexchange.com/questions/557/how-fast-is-quickfix

Re: In progress/POC cTrader FIX plugin [Re: Veratyr] #472604
05/07/18 19:25
05/07/18 19:25
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
I appreciate the insight. Thanks! laugh

Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD] #472647
05/09/18 22:56
05/09/18 22:56
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Some basic questions:

1. In general a cTrader account is required for the plugin? A 'pure' FIX API account does not work or at least not out of the box?

2. Using your example AssetsCT.csv what do you mean concerning the dash in the assets names? AUD/USD e.g. has the symbol 5 there, selecting it in the strategy must be with asset("FXCM-5") or asset("5") or must the symbol be written as "FXCM-5" in the assets.csv?

Thanks, Sphin

Re: In progress/POC cTrader FIX plugin [Re: Sphin] #472675
05/13/18 10:34
05/13/18 10:34
Joined: Jan 2016
Posts: 122
V
Veratyr Offline OP
Member
Veratyr  Offline OP
Member
V

Joined: Jan 2016
Posts: 122
Originally Posted By: Sphin

1. In general a cTrader account is required for the plugin? A 'pure' FIX API account does not work or at least not out of the box?


Yes. As far as I can tell, there's no such thing as a functional "pure" FIX implementation, so this one targets cTrader specifically.

Originally Posted By: Sphin

2. Using your example AssetsCT.csv what do you mean concerning the dash in the assets names? AUD/USD e.g. has the symbol 5 there, selecting it in the strategy must be with asset("FXCM-5") or asset("5") or must the symbol be written as "FXCM-5" in the assets.csv?


The symbol being passed to the plugin (the one in the last column) must be "FXCM-5". You can name it whatever you want in Zorro and use asset() with the Zorro name.

Last edited by Veratyr; 05/13/18 10:34.
Re: In progress/POC cTrader FIX plugin [Re: Veratyr] #472755
05/21/18 02:28
05/21/18 02:28
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Trying to get some prices ...

Code:
function run() {
  BarPeriod = 1;
  LookBack = 0;
  set(TICKS+LOGFILE);
  plot(Asset, priceClose(), NEW, BLUE);
}


selected "EUR/USD" in the asset box, click "Trade" and get these messages:

Click to reveal..
CheckAsset
Login 0 CTFIX..
!Logging in
!Not initialized, logging in
!Loading session settings
!Session settings loaded
!Found 1 accounts
!Starting initiator
!Initiator started
!Not logged in yet...
!Logged in!
at UTC 05-21 01:18
V 1.830 on Mon 18-05-21 03:18:17
!CurrentAccount empty
!Couldn't find session
!CurrentAccount empty
!Couldn't find session
!CurrentAccount empty
!Couldn't find session
Trade: CheckAsset EUR/USD 2018-05-21
Assets AssetscT
!CurrentAccount empty
!Couldn't find session
!CurrentAccount empty
!Couldn't find session
[...]
[fast repeating until click on Stop button]

Directly selecting the asset in the code with

asset("EUR/USD")

the messages slightly differ:

Click to reveal..
CheckAsset
Login 0 CTFIX..
!Logging in
!Not initialized, logging in
!Loading session settings
!Session settings loaded
!Found 1 accounts
!Starting initiator
!Initiator started
!Not logged in yet...
!Logged in!
at UTC 05-21 01:34
!CurrentAccount empty
!Couldn't find session
!CurrentAccount empty
!Couldn't find session
- EUR/USD history unavailable!
V 1.830 on Mon 18-05-21 03:34:00
Error 055: No bars generated
Logout..
!Logging out...
ok

Maybe this is a mapping problem because adjusting your example my AssetscT.csv just looks like:

EUR/USD,1.13795,0.00005,-0.02,0.01,0.0001,0.0871,10,0,100000,0.6,Broker-1

But there are several liquidity streams available and so their assets are called:

EURUSD.aaa
EURUSD.bbb
EURUSD.ccc

Do you know wherefrom getting a valid mapping? In cTrader at least I couldn't find some.

BTW: The connects from above work only once without restarting Zorro. Trying it twice I get:
Quote:
CheckAsset
Login 0 CTFIX..
!Logging in
!Account not valid: [acc. number that worked before]
Can't connect!

Re: In progress/POC cTrader FIX plugin [Re: Sphin] #472768
05/21/18 13:17
05/21/18 13:17
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted By: Sphin
BTW: The connects from above work only once without restarting Zorro.
Dear plugin writers: please don't forget to clean up memory between login calls. Thank you! laugh

Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD] #473231
06/22/18 16:10
06/22/18 16:10
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Is this project still alive?

Re: In progress/POC cTrader FIX plugin [Re: Sphin] #473753
08/09/18 21:50
08/09/18 21:50
Joined: Jan 2016
Posts: 122
V
Veratyr Offline OP
Member
Veratyr  Offline OP
Member
V

Joined: Jan 2016
Posts: 122
Originally Posted By: Sphin
Is this project still alive?


I haven't had the time/motivation to work on it recently.

If anyone else wants to try to pick it up they're welcome to fork it.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1