|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.moneydance.apps.md.model.CapitalGainBuy
public class CapitalGainBuy
Tracks a buy transaction for capital gain calculations, particularly average cost with long term and short term gains. Per U.S. IRS Publication 564, single-category average cost allocates to the earliest shares acquired first:
Even though you include all unsold shares of a fund in a single category to compute average basis, you may have both short-term and long-term gains or losses when you sell these shares. To determine your holding period, the shares disposed of are considered to be those acquired first.This class tracks how many shares of a particular buy transaction has already been allotted by one or more sale transactions, and also helps track the remaining average cost basis. Note that these objects should always be processed in date order. If the date provided to methods
allot(long, int)
, getRemainingShares(int)
or
setRemainingBasis(double, int)
were ever to go backwards in time, this
could give incorrect results because of stock splits.
Constructor Summary | |
---|---|
CapitalGainBuy(SecurityAccount account,
int date,
long totalAmount,
long sharesPurchased)
Constructor to allow most fields to be final. |
Method Summary | |
---|---|
long |
allot(long sharesRequested,
int asofDate)
Allocate the requested number of shares from the total amount, if possible. |
int |
compareTo(CapitalGainBuy other)
|
int |
getDateInt()
|
long |
getRemainingBasis()
|
long |
getRemainingShares(int asofDate)
Compute the remaining shares for a buy transaction |
long |
getSharesPurchased()
|
long |
getTotalAmount()
|
boolean |
isAllocated()
|
void |
setRemainingBasis(double averageCost,
int asofDate)
Compute the remaining basis for this buy transaction, given a particular average cost. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CapitalGainBuy(SecurityAccount account, int date, long totalAmount, long sharesPurchased)
account
- The associated security account.date
- The date of the buy transaction.totalAmount
- The total buy amount, in the investment account's currency.sharesPurchased
- The number of shares purchased in the buy transaction.Method Detail |
---|
public int getDateInt()
public long getTotalAmount()
public long getSharesPurchased()
public boolean isAllocated()
getTotalAmount()
to get the cost basis.public long allot(long sharesRequested, int asofDate)
sharesRequested
- The number of shares requested to be allotted.asofDate
- The date of the allotment.
public long getRemainingShares(int asofDate)
asofDate
- The date the remaining shares should be computed for, adjusting for any
splits previous.
public void setRemainingBasis(double averageCost, int asofDate)
averageCost
- The current average cost, computed for a particular sale transaction.asofDate
- The date the remaining basis is valid for. The shares remaining are
brought forward to this date, adjusting for splits.public long getRemainingBasis()
public int compareTo(CapitalGainBuy other)
compareTo
in interface java.lang.Comparable<CapitalGainBuy>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |