Skip to content

Regression: carry field sinceVersion into composite types breaks other use of these types #967

Closed
@bjin

Description

@bjin

Commit bca8849 carries field sinceVersion down to composite types, but it seems that this behavior change will break other use of these composite types.

Schema file: https://www.cmegroup.com/ftp/SBEFix/Production/Templates/templates_v13.xml (registration required to download, uploaded as templates_v13.xml.txt). The schema version is 13.

Composite types:

        <composite name="PRICENULL9" description="Optional Price with constant exponent -9" sinceVersion="9">
            <type name="mantissa" description="mantissa" presence="optional" nullValue="9223372036854775807" primitiveType="int64"/>
            <type name="exponent" description="exponent" presence="constant" primitiveType="int8">-9</type>
        </composite>

New fields with PRICENULL9 type:

    <ns2:message name="MDInstrumentDefinitionFX63" id="63" description="MDInstrumentDefinitionFX" blockLength="337" semanticType="d" sinceVersion="12">
        ...
        <field name="AltMinPriceIncrement" id="37739" type="PRICENULL9" description="New sub-tick which is only available for order entry when certain conditions are met, tick value which corresponds to the Alt Min Quote Life" offset="309" sinceVersion="13" semanticType="Price"/>
        <field name="AltMinQuoteLife" id="37738" type="uInt32NULL" description="MQL duration in number of microseconds applied to orders at AltMinPriceIncrement" offset="317" sinceVersion="13" semanticType="int"/>
        <field name="AltPriceIncrementConstraint" id="37742" type="PRICENULL9" description="Minimum price offset better than the best Standard Tick order for an order to be allowed into the market" offset="321" sinceVersion="13" semanticType="Price"/>
        <field name="MaxBidAskConstraint" id="37743" type="PRICENULL9" description="Maximum bid/ask spread for which sub-tick orders will be accepted (Sub tick orders will be rejected if bid/ask spread is greater than this value)" offset="329" sinceVersion="13" semanticType="Price"/>
        ...
    </ns2:message>

The new fields from MDInstrumentDefinitionFX63 promotes sinceVersion=13 down to composite type PRICENULL9, which breaks use of PRICENULL9 from other types with older acting schema version.

class PRICENULL9
{
    ...
    SBE_NODISCARD std::int64_t mantissa() const SBE_NOEXCEPT
    {
        if (m_actingVersion < 13)
        {
            return INT64_C(9223372036854775807);
        }

        std::int64_t val;
        std::memcpy(&val, m_buffer + m_offset + 0, sizeof(std::int64_t));
        return SBE_LITTLE_ENDIAN_ENCODE_64(val);
    }
    ...
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions