Thread: [Quickfix-developers] weird code
Brought to you by:
orenmnero
From: azmat <mr...@gm...> - 2008-03-04 20:50:00
|
All, I am nicely moving along creating my first ever FIX app and would like to thank everyone in helping me with this journey. I am now able to send market data messages, however have problems with the Snapshot / Full Refresh messages that are returned. This is what I wrote. I based it off of what was written in the documentation (http://quickfixengine.org/quickfix/doc/html/csharp/repeating_groups_2.html) int iGroup = Int32.Parse(mdsfr.get(new NoMDEntries()).ToString()); QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries mdGroup = new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries(); MDEntryType entryType = new MDEntryType(); MDEntryPx entryPrice = new MDEntryPx(); MDEntrySize entrySize = new MDEntrySize(); for(uint i=0; i<iGroup; i++) { mdsfr.getGroup(i, mdGroup); // what does this line do?? if (mdGroup.get(new MDEntryType()).ToString() == "0") //bid { MarketDepthData md = new MarketDepthData(Int32.Parse(mdGroup.get(new MDEntrySize()).ToString()), mdGroup.get(new MDEntryPx()).ToString()); mdupdate.bidList.Add(md.Price, md); } else if (mdGroup.get(new MDEntryType()).ToString() == "1") //sell { MarketDepthData md = new MarketDepthData(Int32.Parse(mdGroup.get(new MDEntrySize()).ToString()), mdGroup.get(new MDEntryPx()).ToString()); mdupdate.askList.Add(md.Price, md); } else //trade { mdupdate.LastPrice = mdGroup.get(new MDEntryPx()).ToString(); mdupdate.LastQty = Int32.Parse(mdGroup.get(new MDEntrySize()).ToString()); } The line I think is "weird" is this one: mdsfr.getGroup(i, mdGroup); // what does this line do?? The code compiles fine, but I have other issues in my app that don't let me run it. By the way, mdsfr is a MarketDataSnapshotFullRefresh message. Does anyone have any suggestions as to how I could improve this? thanks! -- View this message in context: http://www.nabble.com/weird-code-tp15836751p15836751.html Sent from the QuickFIX - Dev mailing list archive at Nabble.com. |
From: Hozaifa A. A. <hoz...@ve...> - 2008-03-05 04:56:04
|
Azmat, The line ur asking is getting the group of data number of times coming in a response. this group contains tag 269, 270 and some more. tag 268 (NoMDEntries) is the number of times. Code is correct just start the loop from 1 not zero. Regards Hozaifa Akber Ali azmat wrote: > > All, > I am nicely moving along creating my first ever FIX app and would like to > thank everyone in helping me with this journey. I am now able to send > market data messages, however have problems with the Snapshot / Full > Refresh messages that are returned. > > This is what I wrote. I based it off of what was written in the > documentation > (http://quickfixengine.org/quickfix/doc/html/csharp/repeating_groups_2.html) > > int iGroup = Int32.Parse(mdsfr.get(new > NoMDEntries()).ToString()); > QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries mdGroup = > new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries(); > MDEntryType entryType = new MDEntryType(); > MDEntryPx entryPrice = new MDEntryPx(); > MDEntrySize entrySize = new MDEntrySize(); > > for(uint i=0; i<iGroup; i++) > { > mdsfr.getGroup(i, mdGroup); // what does this line do?? > > if (mdGroup.get(new MDEntryType()).ToString() == "0") > //bid > { > MarketDepthData md = new > MarketDepthData(Int32.Parse(mdGroup.get(new MDEntrySize()).ToString()), > mdGroup.get(new MDEntryPx()).ToString()); > mdupdate.bidList.Add(md.Price, md); > > } > else if (mdGroup.get(new MDEntryType()).ToString() == "1") > //sell > { > MarketDepthData md = new > MarketDepthData(Int32.Parse(mdGroup.get(new MDEntrySize()).ToString()), > mdGroup.get(new MDEntryPx()).ToString()); > mdupdate.askList.Add(md.Price, md); > } > else //trade > { > mdupdate.LastPrice = mdGroup.get(new > MDEntryPx()).ToString(); > mdupdate.LastQty = Int32.Parse(mdGroup.get(new > MDEntrySize()).ToString()); > } > > The line I think is "weird" is this one: > > mdsfr.getGroup(i, mdGroup); // what does this line do?? > > The code compiles fine, but I have other issues in my app that don't let > me run it. By the way, mdsfr is a MarketDataSnapshotFullRefresh message. > Does anyone have any suggestions as to how I could improve this? > > thanks! > > -- View this message in context: http://www.nabble.com/weird-code-tp15836751p15843272.html Sent from the QuickFIX - Dev mailing list archive at Nabble.com. |
From: azmat <mr...@gm...> - 2008-03-05 22:07:13
|
thanks. But the confusing part of the code is that getGroup returns a Group BUT I am not placing it in any object, but it still compiles. It looks like a line of code that wouldn't do anything...like: "string".ToString(); mdsfr.getGroup(i, mdGroup) //what does this line do?? Any suggestions? It's really blowing my mind. thanks! azmat Hozaifa Akber Ali wrote: > > > Azmat, > > The line ur asking is getting the group of data number of times coming in > a response. this group contains tag 269, 270 and some more. tag 268 > (NoMDEntries) is the number of times. Code is correct just start the loop > from 1 not zero. > > Regards > Hozaifa Akber Ali > > > -- View this message in context: http://www.nabble.com/weird-code-tp15836751p15861131.html Sent from the QuickFIX - Dev mailing list archive at Nabble.com. |
From: Shane T. <str...@co...> - 2008-03-05 22:21:41
|
Also notice that you should be getting the number of groups in the same way: QuickFix.NoMDEntries noMDentries = new QuickFix.NoMDEntries(); message.get(noMDentries); // From message, get NoMDEntries. for (int i = 1; i < noMDentries.getValue(); i++) { message.getGroup(i, group); group.get(mdEntryPx); group.get(mdEntryType); // Handle mdEntryPx and mdEntryType here. } On 3/5/08, azmat <mr...@gm...> wrote: > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > > > thanks. But the confusing part of the code is that getGroup returns a Group > BUT I am not placing it in any object, but it still compiles. It looks like > a line of code that wouldn't do anything...like: > > "string".ToString(); > > > mdsfr.getGroup(i, mdGroup) //what does this line do?? > > > > Any suggestions? > It's really blowing my mind. > > thanks! > azmat > > > > Hozaifa Akber Ali wrote: > > > > > > Azmat, > > > > The line ur asking is getting the group of data number of times coming in > > a response. this group contains tag 269, 270 and some more. tag 268 > > (NoMDEntries) is the number of times. Code is correct just start the loop > > from 1 not zero. > > > > Regards > > Hozaifa Akber Ali > > > > > > > > > -- > View this message in context: http://www.nabble.com/weird-code-tp15836751p15861131.html > > Sent from the QuickFIX - Dev mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers > -- Shane Trotter Connamara Systems, LLC |
From: Shane T. <str...@co...> - 2008-03-05 22:19:29
|
Azmat, According to the documentation on how to get groups that you posted in the first email: If you notice, you use message.getGroup(1, group) to insert the first group of "message" into the "group" object. Then you can utilize "group" to pull out the pieces of information. For example: // Create group holder object. QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries(); // From message, insert group data from the first group into "group" object. message.getGroup(1, group); // Create the objects we want to store the values in. QuickFix.MDEntryPx mdEntryPx = new QuickFix.MDEntryPx(); QuickFix.MDEntryType mdEntryType = new QuickFix.MDEntryType(); // Insert the group values into the holder objects. group.get(mdEntryType); group.get(mdEntryPx); Now mdEntryType will contain the type of the first group, and mdEntryPx will contain the price of the first group. Now you can test the types using standard QuickFIX types: switch (mdEntryType.getValue()) { case QuickFix.MDEntryType.BID: bidPrice = mdEntryPx.getValue(); break; case QuickFix.MDEntryType.OFFER: offerPrice = mdEntryPx.getValue(); break; } -- Shane Trotter Connamara Systems, LLC |