[QFJ-77] Support big decimal in message generation. Created: 25/Sep/06  Updated: 21/Jun/11  Resolved: 12/Jun/07

Status: Closed
Project: QuickFIX/J
Component/s: Message Generation
Affects Version/s: None
Fix Version/s: 1.2.0

Type: New Feature Priority: Default
Reporter: Steve Bate Assignee: Steve Bate
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by QFJ-612 BigDecimal for stock prices Closed

 Description   

Provide a new field type that can be specified in a custom data dictionary. This field type would cause the generated code to use BigDecimal instead of doubles.



 Comments   
Comment by Rob Gilliam [ 27/Mar/07 ]

I would suggest instead just ditching double and Double altogether and using BigDecimal instead for ALL fields of FIX type "float", as very few monetary values (for example) can actually be represented in IEEE 754 format with 100% accuracy

Also, I'm currently working round issues with, for example, "Percentage" format fields which need to be multiplied by 100 to get from the factor value that FIX specifies to the percentage value needed by our system (e.g. from "0.0386" to 3.86%) as this may introduce rounding errors and/or make previously-ignorable inaccuracies significant: for example multiplying a BidYield of 0.0386 by 100.0 and converting the result to String results in 3.8600000000000003 (%)

I'm therefore having to extract field data using Message.getString(int) and then construct a BigDecimal from the String value. My life would be MUCH easier if DoubleField.getValue() just returned a BigDecimal! OK, for backwards compatibilty it might be necessary to add a DoubleField.getBigDecimal() method instead, plus appropriate implementations of DoubleField.setValue(BigDecimal) and valueEquals(BigDecimal)

Comment by Steve Bate [ 10/Jun/07 ]

There is an option for the code generator to use BigDecimal instead of double for fields like price and quantity. The generated code can be used as a replacement for the default QFJ message JARs. The enabled the feature pass a "-Dgenerator.decimal" option on the command line when running the generate.code Ant target.

Generated at Sat Nov 23 07:21:34 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.