celeboss.data
Class Portfolio

java.lang.Object
  extended byceleboss.data.Portfolio
All Implemented Interfaces:
java.util.EventListener, Monitorable, java.beans.PropertyChangeListener, java.io.Serializable, ShareOwner

public class Portfolio
extends java.lang.Object
implements ShareOwner, java.beans.PropertyChangeListener, Monitorable, java.io.Serializable

This class represents a Portfolio associated to an account.

Version:
1.0
Author:
bevans
See Also:
Serialized Form

Field Summary
static java.lang.String CASH
          Property name for events of Cash property
static java.lang.String CHARTPOSITION
          Event property name when chart position changes
static java.lang.String GAIN
          Property name for event of Weekly Gain property
static java.lang.String MILLIONS
          Property name for events of Update property
static boolean MULTIPLESHARE_MODE
          This controls th4e mode that shares are recorded.
static java.lang.String NEWSHARE
          Property name for event of new Share property
static java.lang.String PREDICTDIV
          Property name for events of Update property
static java.lang.String PREDICTVALUE
          Property name for events of Update property
static java.lang.String PREDICTWORTH
          Property name for events of Update property
static java.lang.String PROFIT
          Property name for events of Profit property
static java.lang.String REMOVESHARE
          Property name for event of remove Share property
static java.lang.String TOTALWORTH
          Property name for events of Total Worth property
static java.lang.String UPDATED
          Property name for events of Update property
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener arg0)
          Add a listener.
 void addPropertyChangeListener(java.lang.String arg0, java.beans.PropertyChangeListener arg1)
          Add a listener for a specific Property.
 java.lang.String buyShares(Celebrity celebrity, int number, OrderNotifier notify)
          This will issue a buy order for the specified celebrity.
 Portfolio createLocal()
          Create a local version of this portfolio.
 ChangableValue getCashAvailable()
          Return the amount of cash available for purchases
 java.util.Collection getCelebrities()
          Return a colelciton of the celebrits that this portfolio holds shares.
 int getChartPosition()
          The current chart position for today.
 java.util.Date getLastUpdate()
          Return the date when this Portfolio was last updated.
 CelebrityManager getManager()
          Get a handle to the controlling manager.
 java.lang.Integer getMillions()
          Return the amount of cash banked
 java.lang.String getName()
          This returns a readible name based on the UserId and the status.
 ChangableValue getPredictedDividend()
          Thepredicted dividend at the end of the dividend week.
 ChangableValue getPredictedValue()
          The predicted value at the end of the trading week.
 ChangableValue getPredictedWorth()
          The predicted worth at the end of the trading week.
 ChangableValue getProfit()
          The current profit over the 7 days cycle.
 java.util.Collection getShares()
          Return a list of shares this portfolio has
 ChangableValue getTotalWorth()
          Return the total worth of this portfolio.
 java.lang.String getUserAlias()
          Get the user name of account
 int getUserId()
           
 java.lang.String getUserName()
          Get the user id owning this portfolio.
 ChangableValue getWeeklyGain()
          Get the percentage gain of the total worth ove rthe last 7 days.
 boolean isLive()
          Is this portfolio remote or local.
 boolean isReadOnly()
          Can this portfolio be manipulated
 void propertyChange(java.beans.PropertyChangeEvent arg0)
          An change has happened in the Share Blocks
 void refresh()
          Refresh this portfolio.
 void removePropertyChangeListener(java.beans.PropertyChangeListener arg0)
          Remove a previously registered listener.
 void removePropertyChangeListener(java.lang.String arg0, java.beans.PropertyChangeListener arg1)
          Remove a previousl registered listener
 java.lang.String sellShares(Celebrity celebrity, int number, OrderNotifier notify)
          This will issue a sell order for the specified celebrity.
 void setCashAvailable(float cash)
          Update how much cash is availalbe.
 void setChartPosition(int i)
          Update the current chart position.
 void setMillions(int mils)
          Update how much money is banked
 void setShares(java.util.Collection newShares)
          Update the share portfolio
 void setUpdated()
          This portfolio recorded has just been updated
 void setUserDetails(java.lang.String newUser, int id)
          Update the usernameof portfolio.
 void setUsername(java.lang.String username, java.lang.String password)
          Update the userid and password assigned to this Portfolio
 void setWeeklyGain(float newGain)
          Update the percentage gain value.
 java.lang.String toString()
          String representation of Portfolio
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CASH

public static final java.lang.String CASH
Property name for events of Cash property

See Also:
Constant Field Values

CHARTPOSITION

public static final java.lang.String CHARTPOSITION
Event property name when chart position changes

See Also:
Constant Field Values

GAIN

public static final java.lang.String GAIN
Property name for event of Weekly Gain property

See Also:
Constant Field Values

MILLIONS

public static final java.lang.String MILLIONS
Property name for events of Update property

See Also:
Constant Field Values

MULTIPLESHARE_MODE

public static final boolean MULTIPLESHARE_MODE
This controls th4e mode that shares are recorded. TODO This should be moved to a user settable property in CelebrityManager once it's stable

See Also:
Constant Field Values

NEWSHARE

public static final java.lang.String NEWSHARE
Property name for event of new Share property

See Also:
Constant Field Values

PREDICTDIV

public static final java.lang.String PREDICTDIV
Property name for events of Update property

See Also:
Constant Field Values

PREDICTVALUE

public static final java.lang.String PREDICTVALUE
Property name for events of Update property

See Also:
Constant Field Values

PREDICTWORTH

public static final java.lang.String PREDICTWORTH
Property name for events of Update property

See Also:
Constant Field Values

PROFIT

public static final java.lang.String PROFIT
Property name for events of Profit property

See Also:
Constant Field Values

REMOVESHARE

public static final java.lang.String REMOVESHARE
Property name for event of remove Share property

See Also:
Constant Field Values

TOTALWORTH

public static final java.lang.String TOTALWORTH
Property name for events of Total Worth property

See Also:
Constant Field Values

UPDATED

public static final java.lang.String UPDATED
Property name for events of Update property

See Also:
Constant Field Values
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener arg0)
Add a listener.

Specified by:
addPropertyChangeListener in interface Monitorable
Parameters:
arg0 - Listener.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String arg0,
                                      java.beans.PropertyChangeListener arg1)
Add a listener for a specific Property.

Parameters:
arg0 - Property name
arg1 - Listener to be notified

buyShares

public java.lang.String buyShares(Celebrity celebrity,
                                  int number,
                                  OrderNotifier notify)
This will issue a buy order for the specified celebrity. If there is no notify, then a block operation is performed.

Parameters:
celebrity - Celebrity to buy
number - Number of shares.
notify - Inform this object when the order is complete.
Returns:
Error code for a blocking operation.

createLocal

public Portfolio createLocal()
Create a local version of this portfolio. The local portfolio will execute any buy or sell orders locally. This would be suited to implemnetating a what if scenario.

Returns:
Portfolio that is local

getCashAvailable

public ChangableValue getCashAvailable()
Return the amount of cash available for purchases

Returns:
Money.

getCelebrities

public java.util.Collection getCelebrities()
Return a colelciton of the celebrits that this portfolio holds shares.

Returns:
Collection of Celebrities.

getChartPosition

public int getChartPosition()
The current chart position for today.

Returns:
Integer position

getLastUpdate

public java.util.Date getLastUpdate()
Return the date when this Portfolio was last updated.

Returns:
Update date.

getManager

public CelebrityManager getManager()
Get a handle to the controlling manager.

Specified by:
getManager in interface ShareOwner
Returns:
Celebrity manager.

getMillions

public java.lang.Integer getMillions()
Return the amount of cash banked

Returns:
Money in millions

getName

public java.lang.String getName()
This returns a readible name based on the UserId and the status.

Returns:
String

getPredictedDividend

public ChangableValue getPredictedDividend()
Thepredicted dividend at the end of the dividend week.

Returns:
Money over last 7 days made.

getPredictedValue

public ChangableValue getPredictedValue()
The predicted value at the end of the trading week.

Returns:
Money over last 7 days made.

getPredictedWorth

public ChangableValue getPredictedWorth()
The predicted worth at the end of the trading week.

Returns:
Money over last 7 days made.

getProfit

public ChangableValue getProfit()
The current profit over the 7 days cycle.

Returns:
Money over last 7 days made.

getShares

public java.util.Collection getShares()
Return a list of shares this portfolio has

Returns:
Collection of ShareBlocks

getTotalWorth

public ChangableValue getTotalWorth()
Return the total worth of this portfolio.

Returns:
Money value

getUserName

public java.lang.String getUserName()
Get the user id owning this portfolio.

Returns:
User id.

getUserId

public int getUserId()
Returns:
Returns the userNumber.

getUserAlias

public java.lang.String getUserAlias()
Get the user name of account

Returns:
Long user name.

getWeeklyGain

public ChangableValue getWeeklyGain()
Get the percentage gain of the total worth ove rthe last 7 days.

Returns:
Percentage gain.

isLive

public boolean isLive()
Is this portfolio remote or local. Remote portfolios are governed by the share ownership detials returned from the remote server. Local portfolios deal with share localy.

Returns:
True or False.

isReadOnly

public boolean isReadOnly()
Can this portfolio be manipulated

Returns:
Is read only

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent arg0)
An change has happened in the Share Blocks

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
arg0 - Description.

refresh

public void refresh()
Refresh this portfolio. This will queue a refresh command for immediate execution.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener arg0)
Remove a previously registered listener.

Specified by:
removePropertyChangeListener in interface Monitorable
Parameters:
arg0 - to remove.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String arg0,
                                         java.beans.PropertyChangeListener arg1)
Remove a previousl registered listener

Parameters:
arg0 - Property name
arg1 - Previous listeners

sellShares

public java.lang.String sellShares(Celebrity celebrity,
                                   int number,
                                   OrderNotifier notify)
This will issue a sell order for the specified celebrity. If there is no notify, then a block operation is performed.

Parameters:
celebrity - Celebrity to sell
number - Number of shares.
notify - Inform this object when the order is complete.
Returns:
Error message when a blocking operation

setCashAvailable

public void setCashAvailable(float cash)
Update how much cash is availalbe.

Parameters:
cash - New cash available.

setChartPosition

public void setChartPosition(int i)
Update the current chart position.

Parameters:
i - New chart position.

setMillions

public void setMillions(int mils)
Update how much money is banked

Parameters:
mils - New cash banked.

setShares

public void setShares(java.util.Collection newShares)
Update the share portfolio

Parameters:
newShares - Collection of new shares.

setUpdated

public void setUpdated()
This portfolio recorded has just been updated


setUserDetails

public void setUserDetails(java.lang.String newUser,
                           int id)
Update the usernameof portfolio.

Parameters:
newUser - New user name.
id - The identifier of the user account.

setUsername

public void setUsername(java.lang.String username,
                        java.lang.String password)
Update the userid and password assigned to this Portfolio

Parameters:
username - New User name.
password - New password

setWeeklyGain

public void setWeeklyGain(float newGain)
Update the percentage gain value.

Parameters:
newGain - New gain percentage

toString

public java.lang.String toString()
String representation of Portfolio

Returns:
String based on userId.