Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickfix read custom repeating group

I have this sample response that I get from my service provider. They have defined tags which are already defined (I have checked from FIXimate).

8=FIXT.1.19=108135=IB49=NSECM56=MTBM34=1924=1115=21828=61826=Nifty CPSE1815=2294.51816=2310.151817=2286.551818=2276.751819=2294.21820=1967852601488651821=262231822=257851823=0.771824=2799.551825=2139.51827=-1826=Nifty GrowSect 151815=7037.751816=7070.351817=7023.651818=6990.61819=7042.91820=7768216282514231821=782041822=750561823=0.751824=7354.551825=5942.151827= 1826=Nifty50 Value 201815=5444.71816=5465.61817=5417.41818=5413.61819=5425.91820=1.90667550936387E+151821=1348851822=1341791823=0.231824=5563.81825=4171.651827=-1826=Nifty Mid Liq 151815=4133.551816=4206.551817=4133.551818=4107.21819=4205.41820=1573956262705091821=428041822=442911823=2.391824=4677.051825=3770.551827=-1826=Nifty Pvt Bank1815=15385.21816=15415.51817=15339.751818=15248.81819=15377.71820=9015155094048031821=589741822=592681823=0.851824=16152.151825=13298.31827=+1826=NIFTY MIDCAP 1001815=19184.851816=19326.31817=19184.851818=19046.551819=19314.251820=7127426889917151821=1858871822=1884631823=1.411824=21840.851825=17700.91827=-10=174

Problem is I am unable to read the repeating group. I create a custom group as

 noIndexRecords = int(message.getField(1828))
 if noIndexRecords > 0:
    group = fix.Group(1828, 1826, )
    message.getGroup(num=1, group=group)

But this shows me a FieldNotFound error. I have made changes to specifications file FIX50SP2.xml as:

Fields added:

<field number='1815' name="OpenIndex" type="PRICE"/>
<field number='1816' name="HighIndex" type="PRICE"/>
<field number='1817' name="LowIndex" type="PRICE"/>
<field number='1818' name="CloseIndex" type="PRICE"/>
<field number='1819' name="IndexValue" type="PRICE"/>
<field number='1820' name="MarketCapitalization" type="DOUBLE"/>
<field number='1821' name="NoOfDownMoves" type="INT"/>
<field number='1822' name="NoOfUpMoves" type="INT"/>
<field number='1823' name="PercentageChange" type="DECIMAL"/>
<field number='1824' name="YearlyHigh" type="PRICE"/>
<field number='1825' name="YearlyLow" type="PRICE"/>
<field number='1826' name="IndexName" type="STRING"/>
<field number='1827' name="NetChangeIndicator" type="CHAR"/>
<field number='1828' name="NumberOfRecords" type="INT"/>
<field number='8288' name='NoIndexRecords' type='NUMINGROUP'/>

Message Category added:

<message name='IndexBroadcast' msgtype="IB" msgcat="app">
            <field name="NumberOfRecords" required="N"/>
            <component name="NoIndexRecord" required="N"/>

Component defined as:

<component name="NoIndexRecord">
    <group name='NoIndexRecords' required='N'>
        <field name='IndexName' required='Y'/>
        <field name='SecurityID' required='N'/>
        <field name='OpenIndex' required='N'/>
        <field name='HighIndex' required='N'/>
        <field name='LowIndex' required='N'/>
        <field name='CloseIndex' required='N'/>
        <field name='IndexValue' required='N'/>
        <field name='MarketCapitalization' required='N'/>
        <field name='NoOfDownMoves' required='N'/>
        <field name='NoOfUpMoves' required='N'/>
        <field name='PercentageChange' required='N'/>
        <field name='YearlyHigh' required='N'/>
        <field name='YearlyLow' required='N'/>
        <field name='NetChangeIndicator' required='N'/>
    </group>
</component>

I have gone through different discussions and forums and was unable to find the solution. A similar question goes unanswered.

Any help is appreciated. Thanks

like image 841
ap14 Avatar asked Sep 17 '18 12:09

ap14


1 Answers

I have made changes to specifications file FIX50SP2.xml

I assume you are referring to the file spec/FIX50SP2.xml of the QuickFIX C++ Fix Engine Library. For that to work, I think you would need to recompile the quickfix-engine. Unless you are forking the QuickFix engine project, that probably isn't what you want.

Try defining your fields like this:

import quickfix

class MarketCapitalizationField(quickfix.DoubleField):
    number = 1820

    def __init__(self, data=None)
        args = (self.number,) if data is None else (self.number, data)
        super(MarketCapitalizationField, self).__init__(*args)

class IndexNameField(quickfix.StringField):
    number = 1826

    def __init__(self, data=None)
        args = (self.number,) if data is None else (self.number, data)
        super(IndexNameField, self).__init__(*args)

class NumberOfRecordsField(quickfix.IntField):
    number = 1828

    def __init__(self, data=None)
        args = (self.number,) if data is None else (self.number, data)
        super(NumberOfRecordsField, self).__init__(*args)

... and then reading your message like this:

noIndexRecords = int(message.getField(NumberOfRecords.number))
for idx in range(1, noIndexRecords+1):
    message.getGroup(i, group)
    group.getField(MarketCapitalizationField.number)
    group.getField(IndexNameField.number)
like image 180
Guy Hoozdis Avatar answered Oct 04 '22 03:10

Guy Hoozdis