• Version 1.16.0
Show / Hide Table of Contents

Using LINQ

Language-Integrated Query (LINQ) is a technology that allows easily to search, filter and transform data in collections.

FIX Engine API allows applying queries to messages and groups. Both common interfaces and classes like IFieldSet and Group and strongly typed message are supported.

Using LINQ with common interfaces

IEnumerable<IMessage> messages = GetMessages();
// Filter messages
var sellOrders = messages.Where(m => m.Type == MsgType.Order_Single && m[Tag.Side] == Side.Sell);
// Select group entries
var sellOrdersAllocs = sellOrders.SelectMany(m => m.GetGroup(Tag.NoAllocs));
// Search in groups
var myTotalShares = sellOrdersAllocs.Where(alloc => alloc[Tag.AllocAccount] == "MyAccount").
    Select(alloc => alloc.GetDouble(Tag.AllocShares)).Sum();

Using LINQ with strongly typed messages

IEnumerable<OrderSingle> messages = GetMessages();
// Filter messages
var sellOrders = messages.Where(m => m.Side == Fix42.Side.Sell);
// Select group entries
var sellOrdersAllocs = sellOrders.SelectMany(m => m.NoAllocs);
// Search in groups
var myTotalShares = sellOrdersAllocs.Where(alloc => alloc.AllocAccount == "MyAccount").
    Select(alloc => alloc.AllocShares).Sum();
In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX