Venice 0.7beta

org.mov.portfolio
Class ShareAccount

java.lang.Object
  extended by org.mov.portfolio.AbstractAccount
      extended by org.mov.portfolio.ShareAccount
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, Account

public class ShareAccount
extends AbstractAccount
implements java.lang.Cloneable

Representation of a share account in a portfolio.

Author:
Andrew Leppard

Field Summary
 
Fields inherited from interface org.mov.portfolio.Account
CASH_ACCOUNT, SHARE_ACCOUNT
 
Constructor Summary
ShareAccount(java.lang.String name)
          Create a new share account width the default currency.
ShareAccount(java.lang.String name, Currency currency)
          Create a new share account with the given currency.
 
Method Summary
 java.lang.Object clone()
          Create a clone of this account.
 boolean equals(java.lang.Object object)
          Compares this share account to another.
 StockHolding get(Symbol symbol)
          Return the stock holding for a given symbol.
 Currency getCurrency()
          Return the currency of the account.
 java.lang.String getName()
          Return the name of this account.
 java.util.HashMap getStockHoldings()
          Return all the stock holdings for this share account.
 int getType()
          Return the type of this account.
 Money getValue(EODQuoteBundle quoteBundle, int dateOffset)
          Return the value of this account on the given day.
 Money getValue(EODQuoteBundle quoteBundle, TradingDate date)
          Return the value of this account on the given day.
 boolean isHolding(Symbol symbol)
          Return whether the account is holding the current symbol.
 void removeAllTransactions()
          Remove all transactions from account.
 int size()
          Return the number of stock holdings in this share account.
 void transaction(Transaction transaction)
          Perform a transaction on this account.
 
Methods inherited from class org.mov.portfolio.AbstractAccount
compareTo
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShareAccount

public ShareAccount(java.lang.String name,
                    Currency currency)
Create a new share account with the given currency.

Parameters:
name - the name of the new share account
currency - the currency of the share account

ShareAccount

public ShareAccount(java.lang.String name)
Create a new share account width the default currency.

Parameters:
name - the name of the new share account
Method Detail

clone

public java.lang.Object clone()
Create a clone of this account.

Overrides:
clone in class java.lang.Object
Returns:
the clone

equals

public boolean equals(java.lang.Object object)
Compares this share account to another.

Overrides:
equals in class java.lang.Object
Parameters:
object - another share account
Returns:
true if the share accounts are equal; false otherwise

getName

public java.lang.String getName()
Description copied from interface: Account
Return the name of this account.

Specified by:
getName in interface Account
Returns:
name of the account

getValue

public Money getValue(EODQuoteBundle quoteBundle,
                      TradingDate date)
               throws MissingQuoteException
Description copied from interface: Account
Return the value of this account on the given day.

Specified by:
getValue in interface Account
Parameters:
quoteBundle - the quote bundle
date - the date
Throws:
MissingQuoteException

getValue

public Money getValue(EODQuoteBundle quoteBundle,
                      int dateOffset)
               throws MissingQuoteException
Description copied from interface: Account
Return the value of this account on the given day.

Specified by:
getValue in interface Account
Parameters:
quoteBundle - the quote bundle
dateOffset - fast date offset
Throws:
MissingQuoteException

transaction

public void transaction(Transaction transaction)
Description copied from interface: Account
Perform a transaction on this account.

Specified by:
transaction in interface Account
Parameters:
transaction - transaction to occur

get

public StockHolding get(Symbol symbol)
Return the stock holding for a given symbol.

Parameters:
symbol - the stock symbol
Returns:
stock holding for the symbol or null if we do not own any

isHolding

public boolean isHolding(Symbol symbol)
Return whether the account is holding the current symbol.

Parameters:
symbol - the stock symbol
Returns:
TRUE if we are holding the symbol; FALSE otherwise

getStockHoldings

public java.util.HashMap getStockHoldings()
Return all the stock holdings for this share account.

Returns:
all stock holdings

getType

public int getType()
Description copied from interface: Account
Return the type of this account.

Specified by:
getType in interface Account
Returns:
type of the account, either Account.CASH_ACCOUNT or Account.SHARE_ACCOUNT

getCurrency

public Currency getCurrency()
Description copied from interface: Account
Return the currency of the account.

Specified by:
getCurrency in interface Account
Returns:
default currency.

removeAllTransactions

public void removeAllTransactions()
Description copied from interface: Account
Remove all transactions from account.

Specified by:
removeAllTransactions in interface Account

size

public int size()
Return the number of stock holdings in this share account.

Returns:
number of stocks ownwed

Venice 0.7beta