java - Currency data type necessary in financial applications? -


We are developing a stock trading application and are arguing that we have a data type for currency Should apply.

The proposed currency data type contains an amount and a type of currency (for example USD, EUR, JPE).

I am at this point against it because we are also for the continuous beans of a property type.

First of all, it was susceptible to data such as a stockquote class, in which the stock of OHLC (open, high, low, and close pricing) is included. If each of them is presented with a currency example, then all OHLC will have reference to the same currency type (such as USD). In financial applications, all the locations of currency are used all over the place, not just stock quotes, so we are talking about a lot of redundancy.

The second, a currency example is a combination of two values ​​(the amount and type of currency), then you either leave the type of currency altogether and only the database table Store the zodiac field in or create a currency type column in the table for each currency assets, which will be redundant within the table and break 2 normal forms. Either way, reading a record back to the table in the StockQuote object would be impossible with JPA, and would be difficult at best with hibernate.

Anyone before experiencing similar problems? Is it a custom currency category for financial applications in general? If so, how do you implement it with JPA / Hibernate?

It is worth noting that shares are not always quoted in plain currencies such as stocks on LSE in Pence Has been quoted, not pounded. All shares on one exchange will be quoted in the same currency units so that you think that for a given share on a given exchange, you know what the currency is, the currency is making nonsense, you only need the price.

Comments