com.moneydance.apps.md.model
Class CurrencyType

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

public final class CurrencyType
extends java.lang.Object

A structure that represents a single type of currency, identified by the three digit currency code. A stock or security in Moneydance is represented as a currency as it is a unit of value that is relative to some other value (ie the base currency)


Nested Class Summary
 class CurrencyType.Snapshot
           
 class CurrencyType.StockSplit
           
 
Field Summary
static int CURRTYPE_CURRENCY
           
static int CURRTYPE_SECURITY
           
static java.lang.String TAG_RELATIVE_TO_CURR
           
 
Constructor Summary
CurrencyType(int id, java.lang.String idString, java.lang.String name, double rate, int decimalPlaces, java.lang.String prefix, java.lang.String suffix, java.lang.String tickerSymbol, int effectiveDate, int currencyType, CurrencyTable table)
          Construct a CurrencyType object.
CurrencyType(int id, java.lang.String idString, java.lang.String name, double rate, int decimalPlaces, java.lang.String prefix, java.lang.String suffix, java.lang.String tickerSymbol, long effectiveDate, int currencyType, CurrencyTable table)
          Deprecated. use the constructor with an 'int' effectiveDate argument instead
 
Method Summary
 CurrencyType.Snapshot addSnapshot(long date, double userRate)
          Deprecated. use addSnapshotInt(int, double) instead
 CurrencyType.Snapshot addSnapshotInt(int date, double userRate)
          Create a new snapshot with the given date and rate and return the result after adding it to the snapshot list.
 CurrencyType.StockSplit addStockSplit(long date, double splitRatio, int oldShares, int newShares)
          Deprecated. use the addStockSplit method that takes an int date instead
 CurrencyType.StockSplit addStockSplitInt(int date, double splitRatio, int oldShares, int newShares)
          Add a stock split with the given ratio (which should match the old/new shares) on the given date (which decimal form is YYYYMMDD)
 double adjustRateForSplits(long date, double rate)
          Deprecated. use adjustRateForSplitsInt(int, double) instead
 double adjustRateForSplits(long date, double rate, long endDate)
          Deprecated. use adjustRateForSplitsInt(int, double, int) instead
 double adjustRateForSplitsInt(int date, double rate)
          Given a value for this currency at the specified day, return the equivalent value in the currency today after adjusting for splits.
 double adjustRateForSplitsInt(int date, double rate, int endDate)
          Given a rate for this currency at the specified day, return the equivalent rate in the currency at endDate after adjusting for splits.
 long adjustValueForSplits(long txnDate, long val)
          Deprecated. use adjustValueForSplitsInt(int, long) instead
 long adjustValueForSplits(long txnDate, long val, long endDate)
          Deprecated. use adjustValueForSplitsInt(int, long, long)
 long adjustValueForSplitsInt(int txnDate, long val)
          Given a number of currency units on the given day, return the equivalent number of units in todays currency value.
 long adjustValueForSplitsInt(int txnDate, long val, int endDate)
          Given a number of currency units on the given day, return the equivalent number of units in the endDate's currency value.
 int compareToCurrency(CurrencyType curr)
          Return an integer indicating whether this currency is less than, equal to, or greater than the given currency when sorting by type, name, and ID.
 long convertValue(long baseCurrencyAmount)
          Convert the given baseCurrencyAmount value to it's value in this currency.
 java.lang.String format(long amt, char decimalChar)
           
 java.lang.String formatFancy(long amt, char decimalChar)
           
 java.lang.String formatSemiFancy(long amt, char decimalChar)
           
 int getCurrencyType()
           
 double getDailyChange()
           
 long getDailyVolume()
           
 int getDecimalPlaces()
           
 double getDoubleValue(long longVal)
           
 long getEffectiveDate()
          Deprecated. use getEffectiveDateInt() instead
 int getEffectiveDateInt()
          Returns the int value (where the decimal form equals YYYYMMDD) representing the first date that this currency is active.
 boolean getHideInUI()
          Get a boolean flag indicating whether or not this currency should be displayed in user-friendly currency lists.
 int getID()
           
 java.lang.String getIDForScheme(java.lang.String idScheme)
          Returns the security/currency ID that was set for this CurrencyType using the given ID scheme.
 java.lang.String getIDString()
           
 long getLongValue(double doubleVal)
           
 java.lang.String getName()
           
 java.lang.String getPrefix()
           
 double getRawRate()
          Get the rate of this currency relative to the base currency.
 double getRawRateByDate(long dt)
          Deprecated. use getRawRateByDateInt(int) instead
 double getRawRateByDateInt(int dt)
          Get the last known raw rate for this currency at the given time.
 CurrencyType.Snapshot getSnapshot(int i)
           
 int getSnapshotCount()
           
 CurrencyType.StockSplit getStockSplit(int i)
           
 int getStockSplitCount()
           
 java.lang.String getSuffix()
           
 CurrencyTable getTable()
          Returns the currency table that this currency is a part of.
 java.lang.String getTag(java.lang.String key)
          Get the value associated with the given key (if any) in this reminder's set of tags.
 TagSet getTags()
           
 java.lang.String getTickerSymbol()
           
 double getUserRate()
          Get the rate of this currency relative to the base currency
 double getUserRateByDate(long dt)
          Deprecated. use getUserRateByDateInt(int) instead
 double getUserRateByDateInt(int dt)
          Return the user rate as of the given date.
 long invertValue(long currencyAmount)
          Convert the given currencyAmount value in this currency to a value in the base currency.
 boolean isDirty()
           
static void main(java.lang.String[] argv)
           
 long parse(java.lang.String str, char decimalChar)
           
 long parse(java.lang.String str, char decimalChar, boolean quickDecimal)
          Parse the given amount string given the provided decimal character.
 void removeSnapshot(int i)
           
 void removeStockSplit(int i)
           
 void resetDirtyFlags()
           
 void setCurrencyType(int newCurrType)
           
 void setDailyChange(double change)
           
 void setDailyVolume(long vol)
           
 void setDecimalPlaces(int newDecimalPlaces)
           
 void setHideInUI(boolean hideInUI)
          Set a boolean flag indicating whether or not this currency should be displayed in user-friendly currency lists.
 void setIDForScheme(java.lang.String idScheme, java.lang.String newID)
          Sets the security/currency ID for the given ID scheme.
 void setIDString(java.lang.String newIDString)
           
 void setName(java.lang.String newName)
           
 void setPrefix(java.lang.String newPrefix)
           
 CurrencyType.Snapshot setSnapshot(long date, double userRate)
          Deprecated. use setSnapshotInt(int, double) instead
 CurrencyType.Snapshot setSnapshotInt(int date, double userRate)
          If a snapshot exists for the specified date, set the rate and return it.
 CurrencyType.Snapshot setSnapshotInt(int date, double userRate, CurrencyType relativeCurr)
          If a snapshot exists for the specified date, set the rate and return it.
 void setSuffix(java.lang.String newSuffix)
           
 void setTag(java.lang.String key, java.lang.String value)
          Set the value associated with the specified key in this reminders set of tags.
 void setTags(TagSet newTags)
          Set the TagSet associated with this object.
 void setTickerSymbol(java.lang.String newTickerSymbol)
           
 void setUserRate(double newRate)
          Set the price or rate for this currency using the normal decimal placement, not the decimal place adjusted values used when setting raw rates.
 void setUserRate(double newRate, CurrencyType relativeCurr)
          Set the new user (not raw) rate to the given value relative to the given currency.
 void sortSnapshots()
           
 void sortStockSplits()
           
 java.lang.String toString()
           
 long unadjustValueForSplitsInt(int asofDate, long todayVal, int today)
          Given a number of currency units as of today, return the equivalent number of units in the asofDate's currency value, which must be a previous date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRTYPE_CURRENCY

public static final int CURRTYPE_CURRENCY
See Also:
Constant Field Values

CURRTYPE_SECURITY

public static final int CURRTYPE_SECURITY
See Also:
Constant Field Values

TAG_RELATIVE_TO_CURR

public static final java.lang.String TAG_RELATIVE_TO_CURR
See Also:
Constant Field Values
Constructor Detail

CurrencyType

public CurrencyType(int id,
                    java.lang.String idString,
                    java.lang.String name,
                    double rate,
                    int decimalPlaces,
                    java.lang.String prefix,
                    java.lang.String suffix,
                    java.lang.String tickerSymbol,
                    long effectiveDate,
                    int currencyType,
                    CurrencyTable table)
Deprecated. use the constructor with an 'int' effectiveDate argument instead

Construct a CurrencyType object.


CurrencyType

public CurrencyType(int id,
                    java.lang.String idString,
                    java.lang.String name,
                    double rate,
                    int decimalPlaces,
                    java.lang.String prefix,
                    java.lang.String suffix,
                    java.lang.String tickerSymbol,
                    int effectiveDate,
                    int currencyType,
                    CurrencyTable table)
Construct a CurrencyType object.

Method Detail

getEffectiveDate

public final long getEffectiveDate()
Deprecated. use getEffectiveDateInt() instead

Returns the long value representing the first date that this currency is effective.


getEffectiveDateInt

public final int getEffectiveDateInt()
Returns the int value (where the decimal form equals YYYYMMDD) representing the first date that this currency is active. This usually only pertains to securities.


getCurrencyType

public final int getCurrencyType()

getID

public final int getID()

getIDString

public final java.lang.String getIDString()

getName

public final java.lang.String getName()

getPrefix

public final java.lang.String getPrefix()

getSuffix

public final java.lang.String getSuffix()

getDecimalPlaces

public final int getDecimalPlaces()

getTickerSymbol

public final java.lang.String getTickerSymbol()

setDecimalPlaces

public final void setDecimalPlaces(int newDecimalPlaces)

getTable

public CurrencyTable getTable()
Returns the currency table that this currency is a part of. Note: This is only available as of build 281.


getDoubleValue

public final double getDoubleValue(long longVal)

getLongValue

public final long getLongValue(double doubleVal)

setIDString

public final void setIDString(java.lang.String newIDString)

setDailyVolume

public final void setDailyVolume(long vol)

getDailyVolume

public final long getDailyVolume()

setDailyChange

public final void setDailyChange(double change)

getDailyChange

public final double getDailyChange()

setCurrencyType

public final void setCurrencyType(int newCurrType)

setTickerSymbol

public final void setTickerSymbol(java.lang.String newTickerSymbol)

setName

public final void setName(java.lang.String newName)

getRawRate

public final double getRawRate()
Get the rate of this currency relative to the base currency.


setUserRate

public final void setUserRate(double newRate)
Set the price or rate for this currency using the normal decimal placement, not the decimal place adjusted values used when setting raw rates.


setUserRate

public final void setUserRate(double newRate,
                              CurrencyType relativeCurr)
Set the new user (not raw) rate to the given value relative to the given currency.

Since:
Moneydance build 616

getUserRate

public final double getUserRate()
Get the rate of this currency relative to the base currency


setPrefix

public final void setPrefix(java.lang.String newPrefix)

setSuffix

public final void setSuffix(java.lang.String newSuffix)

convertValue

public final long convertValue(long baseCurrencyAmount)
Convert the given baseCurrencyAmount value to it's value in this currency.


invertValue

public final long invertValue(long currencyAmount)
Convert the given currencyAmount value in this currency to a value in the base currency.


isDirty

public final boolean isDirty()

resetDirtyFlags

public final void resetDirtyFlags()

addStockSplit

public final CurrencyType.StockSplit addStockSplit(long date,
                                                   double splitRatio,
                                                   int oldShares,
                                                   int newShares)
Deprecated. use the addStockSplit method that takes an int date instead

Add a stock split.


addStockSplitInt

public final CurrencyType.StockSplit addStockSplitInt(int date,
                                                      double splitRatio,
                                                      int oldShares,
                                                      int newShares)
Add a stock split with the given ratio (which should match the old/new shares) on the given date (which decimal form is YYYYMMDD)


adjustValueForSplits

public final long adjustValueForSplits(long txnDate,
                                       long val)
Deprecated. use adjustValueForSplitsInt(int, long) instead

Given a number of currency units on the given day, return the equivalent number of units in todays currency value. This is intended to be used mainly for stock splits.


adjustValueForSplitsInt

public final long adjustValueForSplitsInt(int txnDate,
                                          long val)
Given a number of currency units on the given day, return the equivalent number of units in todays currency value. This is intended to be used mainly for stock splits.


adjustValueForSplits

public final long adjustValueForSplits(long txnDate,
                                       long val,
                                       long endDate)
Deprecated. use adjustValueForSplitsInt(int, long, long)

Given a number of currency units on the given day, return the equivalent number of units in the endDate's currency value. This is intended to be used mainly for stock splits.


adjustValueForSplitsInt

public final long adjustValueForSplitsInt(int txnDate,
                                          long val,
                                          int endDate)
Given a number of currency units on the given day, return the equivalent number of units in the endDate's currency value. This is intended to be used mainly for stock splits.


unadjustValueForSplitsInt

public final long unadjustValueForSplitsInt(int asofDate,
                                            long todayVal,
                                            int today)
Given a number of currency units as of today, return the equivalent number of units in the asofDate's currency value, which must be a previous date. This is intended to be used mainly for stock splits.

Parameters:
asofDate - The older date.
todayVal - The value as of the today date.
today - Today's date (or at least a date more current than asofDate).
Returns:
The value as of the given asofDate, un-adjusted for any splits.

adjustRateForSplits

public final double adjustRateForSplits(long date,
                                        double rate)
Deprecated. use adjustRateForSplitsInt(int, double) instead

Given a value for this currency at the specified day, return the equivalent value in the currency today after adjusting for splits.


adjustRateForSplitsInt

public final double adjustRateForSplitsInt(int date,
                                           double rate)
Given a value for this currency at the specified day, return the equivalent value in the currency today after adjusting for splits.


adjustRateForSplits

public final double adjustRateForSplits(long date,
                                        double rate,
                                        long endDate)
Deprecated. use adjustRateForSplitsInt(int, double, int) instead

Given a rate for this currency at the specified day, return the equivalent rate in the currency at endDate after adjusting for splits.


adjustRateForSplitsInt

public final double adjustRateForSplitsInt(int date,
                                           double rate,
                                           int endDate)
Given a rate for this currency at the specified day, return the equivalent rate in the currency at endDate after adjusting for splits.


removeStockSplit

public final void removeStockSplit(int i)

getStockSplit

public CurrencyType.StockSplit getStockSplit(int i)

getStockSplitCount

public final int getStockSplitCount()

sortStockSplits

public final void sortStockSplits()

setSnapshot

public final CurrencyType.Snapshot setSnapshot(long date,
                                               double userRate)
Deprecated. use setSnapshotInt(int, double) instead

If a snapshot exists for the specified date, set the rate and return it. Otherwise create a new snapshot on that date with the given rate and return the new snapshot.


setSnapshotInt

public final CurrencyType.Snapshot setSnapshotInt(int date,
                                                  double userRate)
If a snapshot exists for the specified date, set the rate and return it. Otherwise create a new snapshot on that date with the given rate and return the new snapshot.


setSnapshotInt

public final CurrencyType.Snapshot setSnapshotInt(int date,
                                                  double userRate,
                                                  CurrencyType relativeCurr)
If a snapshot exists for the specified date, set the rate and return it. Otherwise create a new snapshot on that date with the given rate and return the new snapshot. If relativeCurr is non-null then the price is first converted to the base price by getting the price of the given currency on the given date.

Since:
Moneydance build 616

addSnapshot

public final CurrencyType.Snapshot addSnapshot(long date,
                                               double userRate)
Deprecated. use addSnapshotInt(int, double) instead

Create a new snapshot with the given date and rate and return the result after adding it to the snapshot list.


addSnapshotInt

public final CurrencyType.Snapshot addSnapshotInt(int date,
                                                  double userRate)
Create a new snapshot with the given date and rate and return the result after adding it to the snapshot list.


removeSnapshot

public final void removeSnapshot(int i)

getSnapshot

public final CurrencyType.Snapshot getSnapshot(int i)

sortSnapshots

public final void sortSnapshots()

getRawRateByDate

public final double getRawRateByDate(long dt)
Deprecated. use getRawRateByDateInt(int) instead

Get the last known raw rate for this currency at the given time.


getRawRateByDateInt

public final double getRawRateByDateInt(int dt)
Get the last known raw rate for this currency at the given time.


getUserRateByDate

public final double getUserRateByDate(long dt)
Deprecated. use getUserRateByDateInt(int) instead

Return the user rate as of the given date.


getUserRateByDateInt

public final double getUserRateByDateInt(int dt)
Return the user rate as of the given date.


getSnapshotCount

public final int getSnapshotCount()

getTags

public final TagSet getTags()

setHideInUI

public final void setHideInUI(boolean hideInUI)
Set a boolean flag indicating whether or not this currency should be displayed in user-friendly currency lists. Note: This is only available as of build 326


getHideInUI

public final boolean getHideInUI()
Get a boolean flag indicating whether or not this currency should be displayed in user-friendly currency lists. Note: This is only available as of build 326


getIDForScheme

public java.lang.String getIDForScheme(java.lang.String idScheme)
Returns the security/currency ID that was set for this CurrencyType using the given ID scheme. Returns null if no ID was set using the given scheme.

Since:
Moneydance build 366

setIDForScheme

public void setIDForScheme(java.lang.String idScheme,
                           java.lang.String newID)
Sets the security/currency ID for the given ID scheme.

Since:
Moneydance build 366

getTag

public final java.lang.String getTag(java.lang.String key)
Get the value associated with the given key (if any) in this reminder's set of tags.


setTag

public final void setTag(java.lang.String key,
                         java.lang.String value)
Set the value associated with the specified key in this reminders set of tags. If there is already a value associated with the given key, it will be replaced.


setTags

public final void setTags(TagSet newTags)
Set the TagSet associated with this object. This should only be called when initially constructing this object.


toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

formatFancy

public final java.lang.String formatFancy(long amt,
                                          char decimalChar)

formatSemiFancy

public final java.lang.String formatSemiFancy(long amt,
                                              char decimalChar)

format

public final java.lang.String format(long amt,
                                     char decimalChar)

parse

public final long parse(java.lang.String str,
                        char decimalChar)

parse

public final long parse(java.lang.String str,
                        char decimalChar,
                        boolean quickDecimal)
Parse the given amount string given the provided decimal character. If quickDecimal is true and getDecimalPlaces() is 2 then a decimal point will be inserted into the string so that "1234" will be parsed as if the user entered "12.34"


compareToCurrency

public int compareToCurrency(CurrencyType curr)
Return an integer indicating whether this currency is less than, equal to, or greater than the given currency when sorting by type, name, and ID. This method was added in build 600 (Moneydance 2008)


main

public static void main(java.lang.String[] argv)