How to round Off LastPrice and Avg Price

Imported from previous forum

I want to round off the Last Price and Avg price when it is sent back to the client in Execution Report, any suggestions to getting this done by a FIX rule?

Need to round it off to 4 decimal places.

Amrit,

Rounding off of avg px and last px is something that should ideally be done by your OMS and not FIX engine. There are various factor involved in the aspect of rounding off these fields. These could be,

  • Rounding up/down the prices
  • Truncation prices to specific # of decimal places
  • Which exchange/country the order was executed on/for as most of the asian exchanges have specific requirement as to how many digits precision should be maintained when rounding off the prices.

All the above factors can change the behavior/dictate as to how these fields should be rounded. Hope this helps.

I want to round off the Last Price and Avg price when it is sent back to
the client in Execution Report, any suggestions to getting this done by
a FIX rule?

Need to round it off to 4 decimal places.

Amrit,

I definitely agree with you. FIX engine’s responsibility is to transmit messages across the network and take care about reliability on top of TCP/IP. Nothing less, nothing more.

From my experience, people are usually having troubles converting floating-point number into string when exchange accepts 4 digits for prices less than $1 and 2 for $1 or more. If that is the case, then we need to round floating-point number using the best model (which usually is very specific) and convert it into a string with a given precision.

There is a good explanation of rounding models in wiki article - http://en.wikipedia.org/wiki/Floating_point#Rounding_modes

For example, someone may want to round down when buying and up when selling.

To convert floating-point to a string, I would recommend using ‘snprintf()’ function which conforms to ISO C99 standard (ISO/IEC 9899:1999). It allows you to specify a precision.

Beware that this trick might not be very straight forward with some FIX engines that provide you with a type-safe interface. For example, in QuickFIX you have to explicitly work with ‘FIX::StringField’ class instead of ‘FIX::Price’ to be able to assign a string to a floating-point field.

If none of the above is possible, you might of course use FIX engine’s rule to do this work if your FIX engine allows it. But this is not a part of standard and, most importantly, do not expect that to work fast.

  • Vlad

Hi Amrit,

A typical FIX engine is not supposed to perform any business logic. Apart from the session management it just propagates application messages upstream/downstream to OMS/EMS.

Rounding off Last price/Average price or any such task can be performed in your OMS.

Thanks

Sumit

I want to round off the Last Price and Avg price when it is sent back to
the client in Execution Report, any suggestions to getting this done by
a FIX rule?

Need to round it off to 4 decimal places.

If OMS is the trading application you are referring, then that makes sense.
If it is a one off (client specific), I don’t think OMS would readily accept to make the change. But it still could be done at the trading application(application that communicates with appia) layer.

Hi Amrit,

A typical FIX engine is not supposed to perform any business logic.
Apart from the session management it just propagates application
messages upstream/downstream to OMS/EMS.

Rounding off Last price/Average price or any such task can be performed
in your OMS.

Thanks

Sumit

I want to round off the Last Price and Avg price when it is sent back
to the client in Execution Report, any suggestions to getting this
done by a FIX rule?

Need to round it off to 4 decimal places.