|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.moneydance.apps.md.model.InvestUtil
public abstract class InvestUtil
Miscellaneous investment functions
Field Summary | |
---|---|
static java.lang.String |
UNREALIZED_MARKER
Marker to identify special sale transactions that are used for unrealized gain calcs. |
Method Summary | |
---|---|
static java.util.List<CapitalGainBuy> |
buildBuyTransactionList(SecurityAccount sec)
Create a sorted map of date versus buy amount, which includes both cash purchases as well as reinvestments. |
static double |
computeROI(java.util.List<ROICashFlowEntry> timeSeries,
double seedPercent)
Compute the Return On Investment, or Internal Rate of Return, or Annual Return Percent. |
static SplitTxn |
generateUnrealizedSaleTxn(SecurityAccount secAcct,
java.util.Hashtable<java.lang.Long,AvailableSharesTracker> lotsRemaining,
int asofDate)
Generate a sale transaction as if all remaining shares of a security were sold off as of a specific date. |
static SplitTxn |
generateUnrealizedSaleTxn(SecurityAccount secAcct,
long shares,
int asofDate)
Generate a sale transaction as if all remaining shares of a security were sold off as of a specific date. |
static CapitalGainBuy |
getBuyTracker(SecurityAccount sec,
CurrencyType secCurr,
CurrencyType investCurr,
SplitTxn split)
Generate a tracking class for a buy transaction when using average cost method. |
static long |
getCostBasis(SecurityAccount sec)
Returns the current cost basis for the given security. |
static CapitalGainResult |
getCostBasisCapGain(SecurityAccount sec,
java.util.List<CapitalGainBuy> buyTxns,
SplitTxn sellTxn)
Returns the current cost basis for the shares in the given sell transaction in the given security. |
static double |
getCostPerShareValue(SecurityAccount sec,
long shares,
long cost)
Compute the cost per share, avoiding a divide by zero fault (returns zero if no shares). |
static long |
getPerShareSalesNet(AbstractTxn atxn)
Compute the net sale amount, in the currency of the parent investment account, of a sale transaction. |
static java.util.Hashtable<java.lang.Long,AvailableSharesTracker> |
getRemainingLots(RootAccount rootAccount,
SecurityAccount secAcct,
int unrealizedAsOfDate)
Determine the remaining lots in a lot-based security account, as of a specified date, accounting for all sales on or prior to that date. |
static java.lang.String |
getSecurityBalanceInfo(SecurityAccount secAccount,
long shares,
int asofDate,
CurrencyType baseCurrency,
char decimal)
Get security balance detailed info on the shares and price per share. |
static boolean |
isCostBasisValid(SecurityAccount sec)
|
static boolean |
isInvestmentIncome(InvestTxnType txnType)
Determine if a transaction is an income from the fund or if it is a 'bank' transaction where the user is putting money in or taking money out. |
static boolean |
isSaleTransaction(InvestTxnType txnType)
Determine if a transaction is a transaction that can be considered a sale, which is treated specially for capital gains. |
static boolean |
isUserCashFlow(InvestTxnType txnType)
Determine if a transaction is a 'bank' transaction where the user is putting money in or taking money out. |
static void |
processLotBasedTxn(TxnSet acctTxns,
SplitTxn split,
CurrencyType secCurr,
int unrealizedAsOfDate,
java.util.Hashtable<java.lang.Long,AvailableSharesTracker> result)
Process a transaction for a security that uses lot-based cost. |
static int |
recomputeStartDate(java.util.List<ROICashFlowEntry> timeSeries,
int currentBeginDate)
The start date is the parameter that modifies the result of an ROI computation the most, since every cash flow is computed against the start date. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UNREALIZED_MARKER
Method Detail |
---|
public static CapitalGainResult getCostBasisCapGain(SecurityAccount sec, java.util.List<CapitalGainBuy> buyTxns, SplitTxn sellTxn)
sec
- The security account.buyTxns
- A date-sorted list of buy transaction amounts for the security account.sellTxn
- The sale transaction to analyze.
public static long getPerShareSalesNet(AbstractTxn atxn)
atxn
- The transaction to compute with.
public static long getCostBasis(SecurityAccount sec)
public static java.util.List<CapitalGainBuy> buildBuyTransactionList(SecurityAccount sec)
sec
- the security account to build the list of transactions for.
public static CapitalGainBuy getBuyTracker(SecurityAccount sec, CurrencyType secCurr, CurrencyType investCurr, SplitTxn split)
sec
- The security account for which the buy belongs.secCurr
- The security account's currency (shares).investCurr
- The parent investment account's currency (dollars, euro, etc.).split
- The buy transaction.
public static int recomputeStartDate(java.util.List<ROICashFlowEntry> timeSeries, int currentBeginDate)
computeROI(java.util.List, double)
This method finds the first date in the time series, and compares it to the current start date.
If the first date in the time series is at or before the current start date, use the current
start date. If the first date in the time series is after the current, then it is used instead.
timeSeries
- The time series to recompute the start date for, sorted in ascending
date order.currentBeginDate
- The current starting date.
public static double computeROI(java.util.List<ROICashFlowEntry> timeSeries, double seedPercent)
Rn+1 = Rn - NPVn*( (Rn - Rn-1) / (NPVn - NPVn-1)Where R is the rate and NPV is the net present value
timeSeries
- The time series of cash flows. This time series must include the initial
balance as a positive and the ending balance as a negative value.seedPercent
- The starting seed value to begin computations with.
Double.NaN
.public static double getCostPerShareValue(SecurityAccount sec, long shares, long cost)
sec
- The security account the shares belong to.shares
- The number of shares, in the security currency.cost
- The total cost, in the parent investment account's currency.
public static boolean isCostBasisValid(SecurityAccount sec)
public static java.lang.String getSecurityBalanceInfo(SecurityAccount secAccount, long shares, int asofDate, CurrencyType baseCurrency, char decimal)
secAccount
- The security account.shares
- The amount for the account (in shares)asofDate
- The date to check the price for.baseCurrency
- The base currency used to display the price.decimal
- Decimal point for formatting.
public static SplitTxn generateUnrealizedSaleTxn(SecurityAccount secAcct, long shares, int asofDate)
secAcct
- The security account.shares
- The share balance as of the given date.asofDate
- The date to compute the hypothetical sale for.
public static SplitTxn generateUnrealizedSaleTxn(SecurityAccount secAcct, java.util.Hashtable<java.lang.Long,AvailableSharesTracker> lotsRemaining, int asofDate)
secAcct
- The security account.lotsRemaining
- A list of the remaining lots to be sold, or null
to use
average cost basis.asofDate
- The date to compute the hypothetical sale for.
public static java.util.Hashtable<java.lang.Long,AvailableSharesTracker> getRemainingLots(RootAccount rootAccount, SecurityAccount secAcct, int unrealizedAsOfDate)
rootAccount
- The root account to obtain all transactions from.secAcct
- The security to compute the remaining lots for.unrealizedAsOfDate
- The date prior to which to get the unused lots.
null
if the security account doesn't use lot-based accounting.public static void processLotBasedTxn(TxnSet acctTxns, SplitTxn split, CurrencyType secCurr, int unrealizedAsOfDate, java.util.Hashtable<java.lang.Long,AvailableSharesTracker> result)
acctTxns
- The transactions for the account.split
- The transaction to process.secCurr
- The security currency.unrealizedAsOfDate
- The date prior to which to get the unused/available lots.result
- A map of transaction ID to number of shares available. This is an [in, out]
parameter as the map is modified by this method. The available shares will be correct as of
the date of split
public static boolean isUserCashFlow(InvestTxnType txnType)
txnType
- The transaction type.
public static boolean isInvestmentIncome(InvestTxnType txnType)
txnType
- The transaction type.
public static boolean isSaleTransaction(InvestTxnType txnType)
txnType
- The transaction type.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |