question

Upvotes
Accepted
20 1 0 5

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?

treprfarfa-apidatausage
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
1.2k 23 28 42

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Great thanks Steven - this works great!

Click below to post an Idea Post Idea