Prices in RFA.NET are of type double instead of decimal

When receiving and decoding MARKET_BY_PRICE updates in RFA.NET, I found out that price fields are presented as DataBufferType DataBuffer.DataBufferEnum.Real and example app is extracting prices as dataBuffer.Double

This can (and will) lead to loss of precision. Data type of choice for this type of data is System.Decimal.

Why wasn't the decimal used? Is that because the RFA.NET is only thin wrapper around the native library (and there is no .NET decimal equivalent in C++)?

What is the recommended usage in this case? Calling GetAsString() and converting to decimal manually?

Best Answer

  • Steven McCoy
    Answer ✓

    Prices should report to type Real for which the RFA.NET API exposes properties MagnitudeType (exponent) and Value (mantissa) to get the raw data.

    The "Consumer" example converts directly to a string for display purposes only.

Answers