货币换算问题. [英] Currency conversion issue.

查看:69
本文介绍了货币换算问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们正在设计一个基于Java的货币转换应用程序,其中货币名称和货币解码值存储在Currency表中,外汇汇率存储在Foreign_exchange Rates表中.关于如何执行此操作的想法.这种情况是在基于交易的实时应用程序中,外汇汇率不时发生变化,所以我的问题是如何获取最新的值,该值将进行同步并计算正确的转换率".请提出建议.我应使用哪种数据结构来实现此目标.


Hi,
We are designing a java based application for currency conversion where the currency name and currency decode values are stored in Currency Table,The foreign exchange rates are stored in Foreign_exchange rates table.I have to go ahead and implement this,can you please suggest me some ideas as to how should i go about implementing this.This scenario is in Trading based real time application where the foreign exchange rates are changing every now and then,so my question is how will i get the latest value which will be in sync and calculate the "correct conversion rate".Please advice..What datastructure should i use for implementing this.


Currency Table
Currency name| Decode
Indian Rupee | INR







Foreign Exchange Rate(Example) table
CurrencyName| F_E_Name| F_E_Value
INR         | USD     | 46
INR         | EUR     | 56
INR         | GBP     | 80 
INR         | Dinar   | 120 
... so on


以上值将从外汇支票系统中获取,我将如何确保这些值始终保持同步?希望我的问题现在已经理解.

我还实现了以下类.


The above values will be got from a foreign exchange feeder system,how will i ensure the values are in sync always?Hope my question is understood now.

i have also implemented the below classes.

class currency{
   private int currencyPk;
   private String primaryCurrencyName;
   private String decode;
   //getter and setters for the same
   }


class foreignExchangeRate{
   private int currencyFk;
   private String primaryCurrencyName;
   private String foreignExchangeCurrencyName;
   private int foreignExchangeCurrencyValue;
   //getter and setters for the same
   }


请在实施部分上提供建议

[edit]将代码块移至仅覆盖代码-OriginalGriff [/edit]


Please advice on the implementation part

[edit]Code block moved to cover only the code - OriginalGriff[/edit]

推荐答案

如果要处理未知的更新,则必须隐含某种形式的订阅者/发布者模式.发布者将负责基本费率,订阅者可以计算这些值.

关于外汇汇率的一些建议-它们并不复杂,但确实需要小心处理.汇率可以直接应用,也可以作为累进汇率应用.
如果您将两种汇率(例如GBP-USD和USD-EUR)相结合以获得第三个汇率(在本例中为GBP-EUR),则需要考虑方向,并确定汇率是直线汇率还是直线汇率.您不能仅仅将所有东西都保留为星光灿烂的利率,因为这些值会由于四舍五入而损坏.

弄清楚如何合并费率,然后应该会看到存储费率的模式.
If you want to deal with unknown upates then you''ll have to impliment some form of subscriber/publisher pattern. The publisher will be responsible for the base rates and the subscribers can calculate the values.

A word of advice about FX rates - they are not complicated but they do need to be handled with care. Rates can be applied straight or as a reciprical - multiply or divide.
If you are combining two rates, say GBP-USD and USD-EUR, to get a third, in this case GBP-EUR, you need to take into account the direction and decide if the rate should be straight or reciprical. You can''t just hold everything as staright rates because the values will become corrupted by rounding.

Work out how you intend to combine rates and then you should see the pattern for storing them.


这篇关于货币换算问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆