This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Convert structure array containing FIX tags to cell array of FIX messages


fixstr = struct2fix(fixstruct)



fixstr = struct2fix(fixstruct) converts FIX messages in a structure array fixstruct to raw FIX messages in the cell array fixstr.


collapse all

Create two FIX messages using a structure array fixstruct. The FIX protocol version is 4.4. Each FIX message represents a sell side transaction for 100 shares of symbol ABC. The order transaction time is the current moment. The order type is a previously quoted order. The order handling instruction is a private automated execution. The message type indicates a new order. The second structure in the structure array has the same order field values except that the order identifier is unique across orders.

fixstruct.BeginString{1,1} = 'FIX.4.4';
fixstruct.CLOrdId{1,1}  = '338';
fixstruct.Side{1,1}  = '2';
fixstruct.TransactTime{1,1}  = datestr(now);
fixstruct.OrdType{1,1}  = 'D';
fixstruct.Symbol{1,1}  = 'ABC';
fixstruct.HandlInst{1,1}  = '1';
fixstruct.OrderQty{1,1} = '100';
fixstruct.MsgType{1,1} = 'D';

fixstruct.BeginString{2,1} = 'FIX.4.4';
fixstruct.CLOrdId{2,1}  = '339';
fixstruct.Side{2,1}  = '2';
fixstruct.TransactTime{2,1}  = datestr(now);
fixstruct.OrdType{2,1}  = 'D';
fixstruct.Symbol{2,1}  = 'ABC';
fixstruct.HandlInst{2,1}  = '1';
fixstruct.OrderQty{2,1} = '100';
fixstruct.MsgType{2,1} = 'D';

Convert FIX messages in the structure array fixstruct to a cell array of raw FIX messages fixstr.

fixstr = struct2fix(fixstruct)
fixstr =

  2×1 cell array

    '8=FIX.4.4 35=D 11=338 54=2 60=16-Aug-2016 14:56:48 40=D 55=ABC 21=1 38...'
    '8=FIX.4.4 35=D 11=339 54=2 60=16-Aug-2016 14:56:48 40=D 55=ABC 21=1 38...'

Each character vector is a raw FIX message that contains FIX tags and values. The space in between the tag and value pairs is a SOH character. This character is not printable and has a hexadecimal value of 0x01.

Input Arguments

collapse all

FIX message, specified as a structure array. The data in the structure represents one FIX message. The structure fields correspond to FIX tag names. The structure values are the values that you specify in the FIX message.

Example: fixStruct.BeginString{1,1} = 'FIX.4.4';
fixStruct.CLOrdId{1,1} = '338';
fixStruct.Side{1,1} = '2';
fixStruct.TransactTime{1,1} = datestr(now);
fixStruct.OrdType{1,1} = 'D';
fixStruct.Symbol{1,1} = 'ABC';
fixStruct.HandlInst{1,1} = '1';
fixStruct.MsgType{1,1} = 'D';
fixStruct.OrderQty{1,1} = '100';

Data Types: struct

Output Arguments

collapse all

FIX message, returned as a cell array of one or more converted raw FIX messages. The number of messages in the output argument depends on the number of messages that you specify in the input argument.

Introduced in R2015b

Was this topic helpful?