Thread: RE: [Quickfix-developers] Custom message
Brought to you by:
orenmnero
|
From: Mike S. <MS...@rj...> - 2006-03-10 17:05:50
|
I got it working, but it's definitely not the most elegant code.
=20
Message TraderLogin =3D new Message();
TraderLogin.getHeader().setField(new BeginString("FIX.4.2"));
TraderLogin.getHeader().setField(new StringField(35, "CG"));
TraderLogin.getHeader().setField(new
SenderCompID(sessionID.getSenderCompID()));
TraderLogin.getHeader().setField(new SenderSubID("2"));
TraderLogin.getHeader().setField(new
TargetCompID(sessionID.getTargetCompID()));
TraderLogin.setField(new FIX.UserName("abc"));
TraderLogin.setField(new RawData("abc"));
TraderLogin.setField(new RawDataLength(3));
Session.sendToTarget(TraderLogin, sessionID);
=20
________________________________
From: qui...@li...
[mailto:qui...@li...] On Behalf Of
Mike Smith
Sent: Friday, March 10, 2006 10:47 AM
To: qui...@li...
Subject: [Quickfix-developers] Custom message
=20
Hi,
=20
I'm trying to connect to an exchange and they have a custom Trader Login
message with a message type of CG. Has anybody created a custom message
before? If so, could you send me a code sample or give me a few tips?
=20
Thanks,
=20
Mike
|
|
From: Shepheard, T. \(London\) <Tob...@ml...> - 2006-03-10 17:08:26
|
The "official" way to do it is to update the DataDictionary, and then it
becomes just another message type as far as quickfix is concerned. This
does mean that you'll have to do your own build though.
=20
=20
-----Original Message-----
From: qui...@li...
[mailto:qui...@li...] On Behalf Of
Mike Smith
Sent: 10 March 2006 17:06
To: qui...@li...
Subject: RE: [Quickfix-developers] Custom message
I got it working, but it's definitely not the most elegant code.
=20
Message TraderLogin =3D new Message();
TraderLogin.getHeader().setField(new BeginString("FIX.4.2"));
TraderLogin.getHeader().setField(new StringField(35, "CG"));
TraderLogin.getHeader().setField(new
SenderCompID(sessionID.getSenderCompID()));
TraderLogin.getHeader().setField(new SenderSubID("2"));
TraderLogin.getHeader().setField(new
TargetCompID(sessionID.getTargetCompID()));
TraderLogin.setField(new FIX.UserName("abc"));
TraderLogin.setField(new RawData("abc"));
TraderLogin.setField(new RawDataLength(3));
Session.sendToTarget(TraderLogin, sessionID);
=20
=09
_____ =20
From: qui...@li...
[mailto:qui...@li...] On Behalf Of
Mike Smith
Sent: Friday, March 10, 2006 10:47 AM
To: qui...@li...
Subject: [Quickfix-developers] Custom message
=20
Hi,
=20
I'm trying to connect to an exchange and they have a custom
Trader Login message with a message type of CG. Has anybody created a
custom message before? If so, could you send me a code sample or give
me a few tips?
=20
Thanks,
=20
Mike
--------------------------------------------------------
If you are not an intended recipient of this e-mail, please notify the =
sender, delete it and do not read, act upon, print, disclose, copy, =
retain or redistribute it. Click here for important additional terms =
relating to this e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------
|
|
From: Joerg T. <Joe...@ma...> - 2006-03-10 17:22:08
|
Shepheard, Toby (London) wrote:
> The "official" way to do it is to update the DataDictionary, and then i=
t
> becomes just another message type as far as quickfix is concerned. This
> does mean that you'll have to do your own build though.
Is the generation of the message objects from the data dictionary now par=
t of the standard=20
QF build? This only applies for QF/J AFAIK.
My general feeling is that the core engine and the FIX version specific c=
ode (which=20
derives from core engine classes) should be put into separate jar files o=
r shared objects.
Together with a script which generates the code for such a package from t=
he XML file this=20
would be using custom messages and fields much easier.
Cheers, J=F6rg
--=20
Joerg Thoennes
http://macd.com
Tel.: +49 (0)241 44597-24 Macdonald Associates GmbH
Fax : +49 (0)241 44597-10 Lothringer Str. 52, D-52070 Aachen
|
|
From: Shepheard, T. \(London\) <Tob...@ml...> - 2006-03-10 17:27:41
|
My mistake, I use QF/J and was assuming the other versions worked similarly. Apologies for any confusion. -----Original Message----- From: Joerg Thoennes [mailto:Joe...@ma...]=20 Sent: 10 March 2006 17:16 To: Shepheard, Toby (London) Cc: Mike Smith; qui...@li... Subject: Re: [Quickfix-developers] Custom message Shepheard, Toby (London) wrote: > The "official" way to do it is to update the DataDictionary, and then it > becomes just another message type as far as quickfix is concerned. This > does mean that you'll have to do your own build though. Is the generation of the message objects from the data dictionary now part of the standard=20 QF build? This only applies for QF/J AFAIK. <snip> -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the = sender, delete it and do not read, act upon, print, disclose, copy, = retain or redistribute it. Click here for important additional terms = relating to this e-mail. http://www.ml.com/email_terms/ -------------------------------------------------------- |
|
From: Mike S. <MS...@rj...> - 2006-03-13 19:45:30
|
I apologize in advance for the length of this message.
Because one of the exchanges I'm communicating with has custom nonFIX =
message types, I've had to create a custom message type 'CI' within =
QuickFix. To do this, I created a class calld TraderLoginResponse =
within the fix42 folder of quickfix_net_messages_vs8. The code for that =
looks like this...
namespace QuickFix42
{
public class TraderLoginResponse : Message
{
public TraderLoginResponse() : base(MsgType()) { }
static QuickFix.MsgType MsgType() { return new =
QuickFix.MsgType("CI"); }
public void set(QuickFix.Username value)
{ setField(value); }
public QuickFix.Username get(QuickFix.Username value)
{ getField(value); return value; }
public QuickFix.Username getUsername()
{
QuickFix.Username value =3D new QuickFix.Username();
getField(value); return value;
}
public bool isSet(QuickFix.Username field)
{ return isSetField(field); }
public bool isSetUsername()
{ return isSetField(553); }
};
}
I then added the message to my data dictionary. It looks like this....
<message name=3D"TraderLoginResponse" msgtype=3D"CI" msgcat=3D"admin">
<field name=3D"Username" required=3D"Y"/>
</message>
I also had to add the field definition for Username to the data =
dictionary.
<field number=3D"553" name=3D"Username" type=3D"STRING"/>
When I get a CI message from the exchange, I'm getting the following =
error.
Message 47 Rejected: Conditionally Required Field Missing
Here is what the CI message looks like
8=3DFIX.4.2?
9=3D74?
35=3DCI?
49=3DXXX?
56=3DXXXX?
34=3D47?
52=3D20060313-18:50:46.462?
57=3DX?
553=3DXXX?
10=3D131?
Fyi....here is my header definition in the data dictionary.
<header>
<field name=3D"BeginString" required=3D"Y"/>
<field name=3D"BodyLength" required=3D"Y"/>
<field name=3D"MsgType" required=3D"Y"/>
<field name=3D"SenderCompID" required=3D"Y"/>
<field name=3D"TargetCompID" required=3D"Y"/>
<field name=3D"DeliverToCompID" required=3D"N"/>
<field name=3D"MsgSeqNum" required=3D"Y"/>
<field name=3D"SenderSubID" required=3D"N"/>
<field name=3D"TargetSubID" required=3D"N"/>
<field name=3D"PossDupFlag" required=3D"N"/>
<field name=3D"PossResend" required=3D"N"/>
<field name=3D"SendingTime" required=3D"Y"/>
<field name=3D"OrigSendingTime" required=3D"N"/>
</header>
Does anybody have any ideas as to why I would be getting this message =
and how I can fix it?
Thanks in advance,
Mike
-----Original Message-----
From: Joerg Thoennes [mailto:Joe...@ma...]=20
Sent: Friday, March 10, 2006 11:12 AM
To: Mike Smith
Cc: qui...@li...
Subject: Re: [Quickfix-developers] Custom message
Hi Mike,
> I'm trying to connect to an exchange and they have a custom Trader =
Login
> message with a message type of CG. Has anybody created a custom =
message
> before? If so, could you send me a code sample or give me a few tips?
I assume this message is outbound, ie to be sent to the exchange.
The FIX messages for QF are generated by some XSLT and Ruby scripts from =
the FIX data=20
dictionary. You could use these scripts to generate your own messages =
from a modified=20
FIX4*.xml file, but I do not know how much tweaking is still needed to =
do this.
If you just need one message, just copy a small message, ie =
NewOrderSingle and adapt it to=20
your needs. I.e. for java code in =
quickfix/src/java/src/quickfix/fix40/NewOrderSingle.java:
package quickfix.fix40;
import quickfix.FieldNotFound;
import quickfix.Group;
import quickfix.field.*;
public class NewOrderSingle extends Message
{
public NewOrderSingle()
{
getHeader().setField(new MsgType("D"));
}
public NewOrderSingle(
quickfix.field.ClOrdID aClOrdID,
quickfix.field.HandlInst aHandlInst,
quickfix.field.Symbol aSymbol,
quickfix.field.Side aSide,
quickfix.field.OrderQty aOrderQty,
quickfix.field.OrdType aOrdType ) {
getHeader().setField(new MsgType("D"));
set(aClOrdID);
set(aHandlInst);
set(aSymbol);
set(aSide);
set(aOrderQty);
set(aOrdType);
}
public void set(quickfix.field.ClOrdID value)
{ setField(value); }
public quickfix.field.ClOrdID get(quickfix.field.ClOrdID value)
throws FieldNotFound
{ getField(value); return value; }
...
Copy this to your code tree and adapt it, eg:
package smith.mike...;
import quickfix.FieldNotFound;
import quickfix.Group;
import quickfix.field.*;
public class CustomMessage extends Message
{
public CustomMessage()
{
getHeader().setField(new MsgType("CG"));
}
public CustomMessage(
quickfix.field.XXX field1, ... ) {
getHeader().setField(new MsgType("CG"));
set(field1);
...
}
public void set(quickfix.field.XXX value)
{ setField(value); }
public quickfix.field.XXX get(quickfix.field.XXX value)
throws FieldNotFound
{ getField(value); return value; }
...
If you have repeating group, this is a bit more complicated.
Now you can say
message =3D new CustomMessage( value1, .... );
Session.sendToTarget( message, sessionId ); ...
If you want to receive such message, you have to update your data =
dictionary to include it
and create your own MessageFactory to tell QF how to messages with =
MsgType=3DCG to a Java=20
object.
Please apply this to C# or C++ analogeously.
Cheers, J=F6rg
--=20
Joerg Thoennes
http://macd.com
Tel.: +49 (0)241 44597-24 Macdonald Associates GmbH
Fax : +49 (0)241 44597-10 Lothringer Str. 52, D-52070 Aachen
|
|
From: Oren M. <or...@qu...> - 2006-03-13 19:49:47
|
This means you are trying to pull a field out of the message that is not there. What field is it reporting is missing? What fields are you pulling out of the message in your callback? --oren Mike Smith wrote: >QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html >QuickFIX Support: http://www.quickfixengine.org/services.html > >I apologize in advance for the length of this message. > >Because one of the exchanges I'm communicating with has custom nonFIX message types, I've had to create a custom message type 'CI' within QuickFix. To do this, I created a class calld TraderLoginResponse within the fix42 folder of quickfix_net_messages_vs8. The code for that looks like this... > >namespace QuickFix42 >{ > > public class TraderLoginResponse : Message > { > public TraderLoginResponse() : base(MsgType()) { } > static QuickFix.MsgType MsgType() { return new QuickFix.MsgType("CI"); } > > public void set(QuickFix.Username value) > { setField(value); } > public QuickFix.Username get(QuickFix.Username value) > { getField(value); return value; } > public QuickFix.Username getUsername() > { > QuickFix.Username value = new QuickFix.Username(); > getField(value); return value; > } > public bool isSet(QuickFix.Username field) > { return isSetField(field); } > public bool isSetUsername() > { return isSetField(553); } > > }; > >} > >I then added the message to my data dictionary. It looks like this.... ><message name="TraderLoginResponse" msgtype="CI" msgcat="admin"> > <field name="Username" required="Y"/> ></message> > >I also had to add the field definition for Username to the data dictionary. ><field number="553" name="Username" type="STRING"/> > >When I get a CI message from the exchange, I'm getting the following error. >Message 47 Rejected: Conditionally Required Field Missing > >Here is what the CI message looks like >8=FIX.4.2? >9=74? >35=CI? >49=XXX? >56=XXXX? >34=47? >52=20060313-18:50:46.462? >57=X? >553=XXX? >10=131? > >Fyi....here is my header definition in the data dictionary. ><header> > <field name="BeginString" required="Y"/> > <field name="BodyLength" required="Y"/> > <field name="MsgType" required="Y"/> > <field name="SenderCompID" required="Y"/> > <field name="TargetCompID" required="Y"/> > <field name="DeliverToCompID" required="N"/> > <field name="MsgSeqNum" required="Y"/> > <field name="SenderSubID" required="N"/> > <field name="TargetSubID" required="N"/> > <field name="PossDupFlag" required="N"/> > <field name="PossResend" required="N"/> > <field name="SendingTime" required="Y"/> > <field name="OrigSendingTime" required="N"/> > </header> > >Does anybody have any ideas as to why I would be getting this message and how I can fix it? > >Thanks in advance, > >Mike > >-----Original Message----- >From: Joerg Thoennes [mailto:Joe...@ma...] >Sent: Friday, March 10, 2006 11:12 AM >To: Mike Smith >Cc: qui...@li... >Subject: Re: [Quickfix-developers] Custom message > >Hi Mike, > > > >>I'm trying to connect to an exchange and they have a custom Trader Login >>message with a message type of CG. Has anybody created a custom message >>before? If so, could you send me a code sample or give me a few tips? >> >> > >I assume this message is outbound, ie to be sent to the exchange. > >The FIX messages for QF are generated by some XSLT and Ruby scripts from the FIX data >dictionary. You could use these scripts to generate your own messages from a modified >FIX4*.xml file, but I do not know how much tweaking is still needed to do this. > >If you just need one message, just copy a small message, ie NewOrderSingle and adapt it to >your needs. I.e. for java code in quickfix/src/java/src/quickfix/fix40/NewOrderSingle.java: > >package quickfix.fix40; >import quickfix.FieldNotFound; >import quickfix.Group; >import quickfix.field.*; > >public class NewOrderSingle extends Message >{ > public NewOrderSingle() > { > getHeader().setField(new MsgType("D")); > } > public NewOrderSingle( > quickfix.field.ClOrdID aClOrdID, > quickfix.field.HandlInst aHandlInst, > quickfix.field.Symbol aSymbol, > quickfix.field.Side aSide, > quickfix.field.OrderQty aOrderQty, > quickfix.field.OrdType aOrdType ) { > > getHeader().setField(new MsgType("D")); > set(aClOrdID); > set(aHandlInst); > set(aSymbol); > set(aSide); > set(aOrderQty); > set(aOrdType); > } > > public void set(quickfix.field.ClOrdID value) > { setField(value); } > public quickfix.field.ClOrdID get(quickfix.field.ClOrdID value) > throws FieldNotFound > { getField(value); return value; } > >... > >Copy this to your code tree and adapt it, eg: > >package smith.mike...; >import quickfix.FieldNotFound; >import quickfix.Group; >import quickfix.field.*; > >public class CustomMessage extends Message >{ > public CustomMessage() > { > getHeader().setField(new MsgType("CG")); > } > public CustomMessage( > quickfix.field.XXX field1, ... ) { > > getHeader().setField(new MsgType("CG")); > set(field1); > ... > } > > public void set(quickfix.field.XXX value) > { setField(value); } > public quickfix.field.XXX get(quickfix.field.XXX value) > throws FieldNotFound > { getField(value); return value; } > >... > >If you have repeating group, this is a bit more complicated. > >Now you can say > >message = new CustomMessage( value1, .... ); >Session.sendToTarget( message, sessionId ); ... > >If you want to receive such message, you have to update your data dictionary to include it >and create your own MessageFactory to tell QF how to messages with MsgType=CG to a Java >object. > >Please apply this to C# or C++ analogeously. > >Cheers, Jörg > > > |
|
From: Mike S. <MS...@rj...> - 2006-03-13 19:53:14
|
Thanks Oren, I now realize what I'm doing wrong and it IS in my = callback. Mike. -----Original Message----- From: Oren Miller [mailto:or...@qu...]=20 Sent: Monday, March 13, 2006 1:50 PM To: Mike Smith Cc: qui...@li... Subject: Re: [Quickfix-developers] Custom message This means you are trying to pull a field out of the message that is not = there. What field is it reporting is missing? What fields are you=20 pulling out of the message in your callback? --oren Mike Smith wrote: >QuickFIX Documentation: = http://www.quickfixengine.org/quickfix/doc/html/index.html >QuickFIX Support: http://www.quickfixengine.org/services.html > >I apologize in advance for the length of this message. > >Because one of the exchanges I'm communicating with has custom nonFIX = message types, I've had to create a custom message type 'CI' within = QuickFix. To do this, I created a class calld TraderLoginResponse = within the fix42 folder of quickfix_net_messages_vs8. The code for that = looks like this... > >namespace QuickFix42 >{ > > public class TraderLoginResponse : Message > { > public TraderLoginResponse() : base(MsgType()) { } > static QuickFix.MsgType MsgType() { return new = QuickFix.MsgType("CI"); } > > public void set(QuickFix.Username value) > { setField(value); } > public QuickFix.Username get(QuickFix.Username value) > { getField(value); return value; } > public QuickFix.Username getUsername() > { > QuickFix.Username value =3D new QuickFix.Username(); > getField(value); return value; > } > public bool isSet(QuickFix.Username field) > { return isSetField(field); } > public bool isSetUsername() > { return isSetField(553); } > > }; > >} > >I then added the message to my data dictionary. It looks like this.... ><message name=3D"TraderLoginResponse" msgtype=3D"CI" msgcat=3D"admin"> > <field name=3D"Username" required=3D"Y"/> ></message> > >I also had to add the field definition for Username to the data = dictionary. ><field number=3D"553" name=3D"Username" type=3D"STRING"/> > >When I get a CI message from the exchange, I'm getting the following = error. >Message 47 Rejected: Conditionally Required Field Missing > >Here is what the CI message looks like >8=3DFIX.4.2? >9=3D74? >35=3DCI? >49=3DXXX? >56=3DXXXX? >34=3D47? >52=3D20060313-18:50:46.462? >57=3DX? >553=3DXXX? >10=3D131? > >Fyi....here is my header definition in the data dictionary. ><header> > <field name=3D"BeginString" required=3D"Y"/> > <field name=3D"BodyLength" required=3D"Y"/> > <field name=3D"MsgType" required=3D"Y"/> > <field name=3D"SenderCompID" required=3D"Y"/> > <field name=3D"TargetCompID" required=3D"Y"/> > <field name=3D"DeliverToCompID" required=3D"N"/> > <field name=3D"MsgSeqNum" required=3D"Y"/> > <field name=3D"SenderSubID" required=3D"N"/> > <field name=3D"TargetSubID" required=3D"N"/> > <field name=3D"PossDupFlag" required=3D"N"/> > <field name=3D"PossResend" required=3D"N"/> > <field name=3D"SendingTime" required=3D"Y"/> > <field name=3D"OrigSendingTime" required=3D"N"/> > </header> > >Does anybody have any ideas as to why I would be getting this message = and how I can fix it? > >Thanks in advance, > >Mike > >-----Original Message----- >From: Joerg Thoennes [mailto:Joe...@ma...]=20 >Sent: Friday, March 10, 2006 11:12 AM >To: Mike Smith >Cc: qui...@li... >Subject: Re: [Quickfix-developers] Custom message > >Hi Mike, > > =20 > >>I'm trying to connect to an exchange and they have a custom Trader = Login >>message with a message type of CG. Has anybody created a custom = message >>before? If so, could you send me a code sample or give me a few tips? >> =20 >> > >I assume this message is outbound, ie to be sent to the exchange. > >The FIX messages for QF are generated by some XSLT and Ruby scripts = from the FIX data=20 >dictionary. You could use these scripts to generate your own messages = from a modified=20 >FIX4*.xml file, but I do not know how much tweaking is still needed to = do this. > >If you just need one message, just copy a small message, ie = NewOrderSingle and adapt it to=20 >your needs. I.e. for java code in = quickfix/src/java/src/quickfix/fix40/NewOrderSingle.java: > >package quickfix.fix40; >import quickfix.FieldNotFound; >import quickfix.Group; >import quickfix.field.*; > >public class NewOrderSingle extends Message >{ > public NewOrderSingle() > { > getHeader().setField(new MsgType("D")); > } > public NewOrderSingle( > quickfix.field.ClOrdID aClOrdID, > quickfix.field.HandlInst aHandlInst, > quickfix.field.Symbol aSymbol, > quickfix.field.Side aSide, > quickfix.field.OrderQty aOrderQty, > quickfix.field.OrdType aOrdType ) { > > getHeader().setField(new MsgType("D")); > set(aClOrdID); > set(aHandlInst); > set(aSymbol); > set(aSide); > set(aOrderQty); > set(aOrdType); > } > > public void set(quickfix.field.ClOrdID value) > { setField(value); } > public quickfix.field.ClOrdID get(quickfix.field.ClOrdID value) > throws FieldNotFound > { getField(value); return value; } > >... > >Copy this to your code tree and adapt it, eg: > >package smith.mike...; >import quickfix.FieldNotFound; >import quickfix.Group; >import quickfix.field.*; > >public class CustomMessage extends Message >{ > public CustomMessage() > { > getHeader().setField(new MsgType("CG")); > } > public CustomMessage( > quickfix.field.XXX field1, ... ) { > > getHeader().setField(new MsgType("CG")); > set(field1); > ... > } > > public void set(quickfix.field.XXX value) > { setField(value); } > public quickfix.field.XXX get(quickfix.field.XXX value) > throws FieldNotFound > { getField(value); return value; } > >... > >If you have repeating group, this is a bit more complicated. > >Now you can say > >message =3D new CustomMessage( value1, .... ); >Session.sendToTarget( message, sessionId ); ... > >If you want to receive such message, you have to update your data = dictionary to include it >and create your own MessageFactory to tell QF how to messages with = MsgType=3DCG to a Java=20 >object. > >Please apply this to C# or C++ analogeously. > >Cheers, J=F6rg > > =20 > |