Getting values from the currency converter
When you need to get values from the currency converter call the CurrencyConverter.getValue() or CurrencyConverter.getCustomValue() action. Typically, this is in a currency converter update callback. The realized profit and loss position tracker does this to normalize positions to a base currency.
The getValue() action takes two parameters, the currency you want to convert from and the currency you want to convert to. The value returned from the currency converter's cache is the current default value for the specified currencies. You can then use the returned value as a multiplier to convert a value, price, or position from one currency to the other.
If the currency converter cannot find a value for directly converting between the specified currencies it tries to reverse the currencies. If that does not yield a return value then the currency converter checks the cross currency pairs that have been set up to determine whether it can use a third currency to convert between the first two. See
About cross currencies.
The
getCustomValue() action takes three parameters, the currency you want to convert from, the currency you want to convert to, and the field you want to get from the cache. The value returned from the currency converter's cache is the field value you explicitly request for the specified currencies. This field must have been previously specified with the
CurrencyConverter.setCustomValue() action. You can then use the returned value as a multiplier to convert a value, price or position from one currency to the other. See
Setting symbol values in the currency converter cache.