Reputation: 5078
I'm trying to send a QuoteRequest (Tag 35=R) with QuickFIX engine required fields being:
QuoteReqID (Tag: 131)
NoRelatedSym (Tag: 146)
Symbol (Tag: 55)
OrderQty (Tag: 38) *This tag MUST be part of the repeating group (broker said)
Account (Tag: 1)
Here what I did but I'm stuck at how to actually set the account field which should be in a group as they said but not sure how to use group in this case:
string qrid = new Random().Next(111111111, 999999999).ToString();
QuickFix.Fields.QuoteReqID QuoteReqID = new QuickFix.Fields.QuoteReqID(qrid);
QuickFix.FIX44.QuoteRequest message = new QuickFix.FIX44.QuoteRequest(QuoteReqID);
message.NoRelatedSym = new QuickFix.Fields.NoRelatedSym(1);
message.SetField(new QuickFix.Fields.Symbol("EURUSD"));
message.SetField(new QuickFix.Fields.OrderQty(1000)); // not sure which amount to set
// QuickFix.Session.SendToTarget(message, application.QuoteSessionID);
Upvotes: 4
Views: 3953
Reputation: 5078
Here's the code I've used to make it work:
if ( is_logged_on ) { // previously run initiator.start() and listen for initiator.IsLoggedOn to be true
Console.WriteLine("We're logged on!");
Console.WriteLine("Sending QuoteRequest...");
// we're using two sessions: 1 for quotes and another for trades
// QuoteSessionID holds sessionID for quote operations
if ( application != null ) {
// generate a unique request ID
string qrid = new Random().Next(111111111, 999999999).ToString();
QuickFix.Fields.QuoteReqID QuoteReqID = new QuickFix.Fields.QuoteReqID(qrid);
// create QuoteRequest instance
QuickFix.FIX44.QuoteRequest message = new QuickFix.FIX44.QuoteRequest(QuoteReqID);
// Symbol, OrderQty and Account are in a repeating groups
QuickFix.Group group = new QuickFix.Group(QuickFix.Fields.Tags.NoRelatedSym, QuickFix.Fields.Tags.Symbol);
group.SetField(new QuickFix.Fields.Symbol("EURUSD"));
group.SetField(new QuickFix.Fields.OrderQty(500));
group.SetField(new QuickFix.Fields.Account(Account));
// add this group to message
message.AddGroup(group);
// send message to FIX server with QuoteSessionID
QuickFix.Session.SendToTarget(message, application.QuoteSessionID);
}
else
{
Console.WriteLine("QuoteSessionID is null");
}
}
Upvotes: 6