Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bjin opened this issue Jan 16, 2024 · 2 comments

Comments

@bjin
Copy link

bjin commented Jan 16, 2024

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);
    }
    ...
};
@mjpt777
Copy link
Contributor

mjpt777 commented Jan 20, 2024

@bjin Does this fix work for you?

@bjin
Copy link
Author

bjin commented Jan 21, 2024

@mjpt777 Yes, the issue is fixed. Thanks!

@bjin bjin closed this as completed Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants