com.moneydance.apps.md.model
Class CurrencyUtil

java.lang.Object
  extended by com.moneydance.apps.md.model.CurrencyUtil

public abstract class CurrencyUtil
extends java.lang.Object

Miscellaneous currency functions (mostly conversion).


Constructor Summary
CurrencyUtil()
           
 
Method Summary
static double convertToBasePrice(double priceFromCurr, CurrencyType curr, int date)
          Convert the given price (in terms of the given currency) to a price in terms of the base currency.
static long convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency)
          Return the amount of toCurrency that the given value of fromCurrency is currently worth.
static long convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)
          Return the amount of 'toCurrency' obtained by exchanging 'value' of 'fromCurrency' at the rate 'rate'
static long convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
          Return the amount of toCurrency that the given value of fromCurrency was worth on the given date.
static CurrencyTable createDefaultTable(java.lang.String primaryCurrency)
           
static double getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency)
          Get the raw (adjusted for decimal place differences) rate between the two currencies.
static double getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)
          Convert the given user-identifiable rate to the 'raw' rate used to exchange amounts between the given two currencies.
static double getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
          Get the raw (adjusted for decimal place differences) rate between the two currencies.
static double getSplitAdjustedRelativeUserPrice(CurrencyType curr1, CurrencyType curr2, int date)
          Get the price (going rate) for currency curr1 in terms of curr2 on the given date.
static double getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency)
          Get the current user-identifiable rate from fromCurrency to toCurrency.
static double getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, double rawRate)
          Convert the given raw rate to the user-identifiable rate used to exchange amounts between the given two currencies.
static double getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
          Get the raw (adjusted for decimal place differences) rate between the two currencies.
static void main(java.lang.String[] argv)
          Retrieve the latest exchange rates
static void sortCurrencyList(CurrencyType[] list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurrencyUtil

public CurrencyUtil()
Method Detail

getRawRate

public static double getRawRate(CurrencyType fromCurrency,
                                CurrencyType toCurrency,
                                int effectiveDate)
Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date.


getUserRate

public static double getUserRate(CurrencyType fromCurrency,
                                 CurrencyType toCurrency,
                                 int effectiveDate)
Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date.


getRawRate

public static double getRawRate(CurrencyType fromCurrency,
                                CurrencyType toCurrency)
Get the raw (adjusted for decimal place differences) rate between the two currencies.


convertToBasePrice

public static double convertToBasePrice(double priceFromCurr,
                                        CurrencyType curr,
                                        int date)
Convert the given price (in terms of the given currency) to a price in terms of the base currency.


getRawRate

public static double getRawRate(CurrencyType fromCurrency,
                                CurrencyType toCurrency,
                                double userRate)
Convert the given user-identifiable rate to the 'raw' rate used to exchange amounts between the given two currencies.


getUserRate

public static double getUserRate(CurrencyType fromCurrency,
                                 CurrencyType toCurrency,
                                 double rawRate)
Convert the given raw rate to the user-identifiable rate used to exchange amounts between the given two currencies.


getUserRate

public static double getUserRate(CurrencyType fromCurrency,
                                 CurrencyType toCurrency)
Get the current user-identifiable rate from fromCurrency to toCurrency.


convertValue

public static long convertValue(long value,
                                CurrencyType fromCurrency,
                                CurrencyType toCurrency)
Return the amount of toCurrency that the given value of fromCurrency is currently worth.


convertValue

public static long convertValue(long value,
                                CurrencyType fromCurrency,
                                CurrencyType toCurrency,
                                double userRate)
Return the amount of 'toCurrency' obtained by exchanging 'value' of 'fromCurrency' at the rate 'rate'


convertValue

public static long convertValue(long value,
                                CurrencyType fromCurrency,
                                CurrencyType toCurrency,
                                int effectiveDate)
Return the amount of toCurrency that the given value of fromCurrency was worth on the given date.


getSplitAdjustedRelativeUserPrice

public static double getSplitAdjustedRelativeUserPrice(CurrencyType curr1,
                                                       CurrencyType curr2,
                                                       int date)
Get the price (going rate) for currency curr1 in terms of curr2 on the given date. This adjusts the price to be in terms of splits in either currency so that the price is in terms of today's units of each currency (but the price is from the given date, not today's prices).


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Retrieve the latest exchange rates

Throws:
java.lang.Exception

createDefaultTable

public static CurrencyTable createDefaultTable(java.lang.String primaryCurrency)

sortCurrencyList

public static void sortCurrencyList(CurrencyType[] list)