Thread: [Quickfix-developers] How do I change the field of a message from the .net api?
Brought to you by:
orenmnero
From: Wilhelm T. <th...@cu...> - 2009-01-09 04:43:21
|
hello Happy new year to all! I'm using the .net api I'm working on a gateway, I receive a message from my acceptor function fromApp(Message message, SessionID sessionID) 1) I basically need to change some fields from this message and forward back the message to my Initiator I'm basically doing this: message.removeField((int)49); message.removeField(56); Console.Out.WriteLine(">>>> m=" + message.ToString()); message.setField(49, "MAXP2"); // SenderCompID message.setField(56, "MAX2PRICE"); // TargetCompID Console.Out.WriteLine(">>>> m=" + message.ToString()); message.setString(49, "MAXP2"); // SenderCompID message.setString(56, "MAX2PRICE"); // TargetCompID Console.Out.WriteLine(">>>> m=" + message.ToString()); but when I call some ,remove, replace, setField, setString, nothing change the fields 49 and 56? 2) I also try to loop over the fields and create a new message but I do not get the correct field System.Collections.IEnumerator enum_ = message.GetEnumerator(); QuickFix.Field key = null; while(enum_.MoveNext()){ key = (Field)enum_.Current; message2.setField(key.getField(), (string)key.getObject()); } Here is what I see once this while execute: + message {8=FIX.4.29=22535=V34=249=BLABLA52=20090109-03:49:01.46456=GATEWAY146=155=6E Sep0848=6E012008090000003232167=FUT200=200809202=0207=TTSIM262=1/8/2009 7:49:01 PM172263=1264=10265=1266=Y267=3269=0269=1269=210=192} QuickFix.Message {QuickFix42.MarketDataRequest} + message2 {8=FIX.4.29=6935=V146=1262=1/8/2009 7:49:01 PM172263=1264=10265=1266=Y267=310=251} QuickFix42.MarketDataRequest Which is weird as message2 isn't at all like message? Any idea why? thanks a lot for your help Wilhem |
From: Peter P. <pet...@ho...> - 2009-01-09 15:37:07
|
Dear Wilhem, I'm new to QuickFix but maybe I can help? As someone coming new to it, I also found that Quickfix was very tricky to use; it displays truly bizarre behaviour at times! I do not believe that you can build a message manually in this way, because Quickfix wants to understand the structure of what you are building (with repeating groups etc) and will probably just throw out things that it does not like. When I needed to do what you are trying, I decided to build a new message by knowing what fields should be present in the incoming message and getting those values explicitly then rebuilding the groups using the QF-standard way, not by simply setting fields manually. Yours, Dan Date: Thu, 8 Jan 2009 19:54:41 -0800 From: th...@cu... To: qui...@li... Subject: [Quickfix-developers] How do I change the field of a message from the .net api? hello Happy new year to all! I'm using the .net api I'm working on a gateway, I receive a message from my acceptor function fromApp(Message message, SessionID sessionID) 1) I basically need to change some fields from this message and forward back the message to my Initiator I'm basically doing this: message.removeField((int)49); message.removeField(56); Console.Out.WriteLine(">>>> m=" + message.ToString()); message.setField(49, "MAXP2"); // SenderCompID message.setField(56, "MAX2PRICE"); // TargetCompID Console.Out.WriteLine(">>>> m=" + message.ToString()); message.setString(49, "MAXP2"); // SenderCompID message.setString(56, "MAX2PRICE"); // TargetCompID Console.Out.WriteLine(">>>> m=" + message.ToString()); but when I call some ,remove, replace, setField, setString, nothing change the fields 49 and 56? 2) I also try to loop over the fields and create a new message but I do not get the correct field System.Collections.IEnumerator enum_ = message.GetEnumerator(); QuickFix.Field key = null; while(enum_.MoveNext()){ key = (Field)enum_.Current; message2.setField(key.getField(), (string)key.getObject()); } Here is what I see once this while execute: + message {8=FIX.4.29=22535=V34=249=BLABLA52=20090109-03:49:01.46456=GATEWAY146=155=6E Sep0848=6E012008090000003232167=FUT200=200809202=0207=TTSIM262=1/8/2009 7:49:01 PM172263=1264=10265=1266=Y267=3269=0269=1269=210=192} QuickFix.Message {QuickFix42.MarketDataRequest} + message2 {8=FIX.4.29=6935=V146=1262=1/8/2009 7:49:01 PM172263=1264=10265=1266=Y267=310=251} QuickFix42.MarketDataRequest Which is weird as message2 isn't at all like message? Any idea why? thanks a lot for your help Wilhem _________________________________________________________________ Choose the perfect PC or mobile phone for you http://clk.atdmt.com/UKM/go/130777504/direct/01/ |
From: Andrei G. <an...@gm...> - 2009-01-09 16:20:57
|
On Fri, Jan 9, 2009 at 1:54 AM, Wilhelm Thomas <th...@cu...> wrote: > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > > hello > > Happy new year to all! > > I'm using the .net api > > I'm working on a gateway, I receive a message from my acceptor function > > fromApp( > > Message message, SessionID sessionID) > > 1) I basically need to change some fields from this message and forward back the message to my Initiator > > I'm basically doing this: > > > message.removeField((int)49); > message.removeField(56); > Console.Out.WriteLine(">>>> m=" + message.ToString()); > message.setField(49, "MAXP2"); // SenderCompID > message.setField(56, "MAX2PRICE"); // TargetCompID > Console.Out.WriteLine(">>>> m=" + message.ToString()); > message.setString(49, "MAXP2"); // SenderCompID > message.setString(56, "MAX2PRICE"); // TargetCompID > Console.Out.WriteLine(">>>> m=" + message.ToString()); > > > but when I call some ,remove, replace, setField, setString, nothing change the > fields 49 and 56? You are setting header fields into the body. This is a no-no. The correct way to do it would be: message.getHeader().setString(49, "MAXP2"); // SenderCompID message.getHeader().setString(56, "MAX2PRICE"); // TargetCompID Anyway, keep in mind that if you want to send this message via QuickFIX (i.e. SendToTarget), MAXP2-MAX2PRICE must be a valid session defined in your coniguration file. > > 2) I also try to loop over the fields and create a new message but I do not get the correct field > > System.Collections. > > IEnumerator enum_ = message.GetEnumerator(); > QuickFix.Field key = null; > while(enum_.MoveNext()){ > key = (Field)enum_.Current; > message2.setField(key.getField(), (string)key.getObject()); > } > > Here is what I see once this while execute: > > + message {8=FIX.4.2 9=225 35=V 34=2 49=BLABLA 52=20090109-03:49:01.464 56=GATEWAY146=1 55=6E Sep08 48=6E012008090000003232 167=FUT 200=200809 202=0 207=TTSIM 262=1/8/2009 7:49:01 PM172 263=1 264=10 265=1 266=Y 267=3 269=0 269=1 269=2 10=192 } QuickFix.Message {QuickFix42.MarketDataRequest} > > + message2 {8=FIX.4.2 9=69 35=V 146=1 262=1/8/2009 7:49:01 PM172 263=1 264=10 265=1 266=Y 267=3 10=251 } QuickFix42.MarketDataRequest > > Which is weird as message2 isn't at all like message? > > Any idea why? 1) You are not iterating over header/trailer fields. 2) You won't get fields in repeating group, as they are kept in separate structures. |