Gamestudio Links
Zorro Links
Newest Posts
Detrend=SHUFFLE?
by jcl
52 minutes 54 seconds ago
type casting issue
by hatten
Today at 13:44
bmap_process crashes
by Superku
Today at 13:43
Intercept Friday Daily Close
by OptimusPrime
Yesterday at 19:25
tmf...
by MINER
Yesterday at 10:43
Multiple BB Bands
by jcl
Yesterday at 09:45
Using R
by jcl
Yesterday at 09:41
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
14 registered (AndrewAMD, AndyDow, kvm, hatten, PriceAlgoTrader, chsmac85, jenGs, CocaCola, 3 invisible), 483 Guests and 7 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
PersianBoy, xenomoprhen, PriceAlgoTrader, Tomber, MorganP
18126 Registered Users
Topic Options
Rate This Topic
#472600 - 05/07/18 17:17 In progress/POC cTrader FIX plugin
Veratyr Offline
Member

Registered: 01/08/16
Posts: 121
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.


Edited by Veratyr (05/07/18 17:21)

Top
#472601 - 05/07/18 19:02 Re: In progress/POC cTrader FIX plugin [Re: Veratyr]
AndrewAMD Online
Senior Member

Registered: 02/21/17
Posts: 483
Loc: 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.

Top
#472603 - 05/07/18 21:14 Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD]
Veratyr Offline
Member

Registered: 01/08/16
Posts: 121
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

Top
#472604 - 05/07/18 21:25 Re: In progress/POC cTrader FIX plugin [Re: Veratyr]
AndrewAMD Online
Senior Member

Registered: 02/21/17
Posts: 483
Loc: Chicago
I appreciate the insight. Thanks! laugh

Top
#472647 - 05/10/18 00:56 Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD]
Sphin Offline
User

Registered: 12/11/13
Posts: 567
Loc: 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

Top
#472675 - 05/13/18 12:34 Re: In progress/POC cTrader FIX plugin [Re: Sphin]
Veratyr Offline
Member

Registered: 01/08/16
Posts: 121
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.


Edited by Veratyr (05/13/18 12:34)

Top
#472755 - 05/21/18 04:28 Re: In progress/POC cTrader FIX plugin [Re: Veratyr]
Sphin Offline
User

Registered: 12/11/13
Posts: 567
Loc: 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!

Top
#472768 - 05/21/18 15:17 Re: In progress/POC cTrader FIX plugin [Re: Sphin]
AndrewAMD Online
Senior Member

Registered: 02/21/17
Posts: 483
Loc: 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

Top
#473231 - 06/22/18 18:10 Re: In progress/POC cTrader FIX plugin [Re: AndrewAMD]
Sphin Offline
User

Registered: 12/11/13
Posts: 567
Loc: Fuerth, DE
Is this project still alive?

Top
#473753 - 08/09/18 23:50 Re: In progress/POC cTrader FIX plugin [Re: Sphin]
Veratyr Offline
Member

Registered: 01/08/16
Posts: 121
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.

Top



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

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