- Inherits From:
- SwarmObject
- Declared In:
- Agent.h
double demand;
double profit;
double wealth;
double position;
double cash;
double initialcash;
double minholding;
double mincash;
double intrate;
double intratep1;
double price;
double dividend;
int myID;
demand bid or -offer profit exp-weighted moving average wealth total agent wealth position total shares of stock cash total agent cash position initialcash No description. minholding No description. mincash No description. intrate No description. intratep1 No description. price No description. dividend No description. myID No description.
- + setWorld:
- - setID:
- - setPosition:
- - setintrate:
- - setminHolding:minCash:
- - setInitialCash:
- - setInitialHoldings
- - getPriceFromWorld
- - getDividendFromWorld
- - creditEarningsAndPayTaxes
- - constrainDemand::
- - getAgentPosition
- - getWealth
- - getCash
- - prepareForTrading
- - getDemandAndSlope:forPrice:
- - updatePerformance
+ setWorld:(World *)aWorld
Sets a world for an agent. It is a class method as it is used in both class and instance methods in BFagent.
- (double)constrainDemand:(double *)slope :(double)trialprice
Method used by agents to constrain their demand according to the mincash and minholding constraints.
It checks "demand" against the mincash and minholding constraints and clips it if necessary, then also setting *slope. For use within subclass implementations of getDemandAndSlope: forPrice:. Used only by agents that work with the Slope Specialist.
- creditEarningsAndPayTaxes
No method description.
- (double)getAgentPosition
Return the agent's current position
- (double)getCash
Return the agent's current cash level
- (double)getDemandAndSlope:(double *)slope forPrice:(double)trialprce
This message is sent to each agent during bidding to ask for its bid (demand > 0) or offer (demand < 0) at price p. The agent may also return a value for d(demand)/d(price) through "slope", but this is not required; *slope may be left unchanged. This method may be called one or more times in each period, depending on the specialist method. The last such call is at the final trading price. The -prepareForTrading message is sent to each agent before the first such call in each period. Note that agents without demand functions return zero slope, but the Slope specialist is never used with these agents.
There is no default for this method in the Agent class; the agent subclasses MUST provide it.
- getDividendFromWorld
Sets an instance variable of agent, dividend, to the current dividend. That information is retrieved from the object known as "world".
- getPriceFromWorld
Sets an instance variable of agent, price, to the current price which is controlled by the object known as "world". Please note this assumes world is already set.
- (double)getWealth
Return the agent's current wealth
- prepareForTrading
Sent to each enabled agent at the start of each trading period, before the first -getDemandAndSlope:forPrice: message for that agent. The class method +prepareForTrading: is sent to each type before any of these messages. This probably should have some subclassMustImplement code here, because the default code does nothing. It must be overridden
- setID:(int)iD
Gives an integer name to an agent during creation. Sometimes it helps with debugging to have a unique id for each agent
- setInitialCash:(double)initcash
Sets the initial cash holdings of each agent.
- setInitialHoldings
Sets the initial stock holdings of each agent. It is the designated initializer. Most agent classes will have additional initialization, but should do [super setInitialHoldings] to run this first. It will initialize instance variables common to all agents, setting profit,wealth, and position equal to 0, and it sets the variable cash equal to initialcash
- setPosition:(double)aDouble
Sets the agent's position (holding) to "aDouble".
- setintrate:(double)rate
Sets the IVAR intrate and uses that to calculate intratep1 (intrate + 1).
- setminHolding:(double)holding minCash:(double)minimumcash
Sets the borrowing and short selling constraints, i.e., the values can be negative. It sets values of the IVARS minholding and mincash
- updatePerformance
Sent to each enabled agent at the end of each period to tell it to update its performance meaures, forecasts, etc. The default code does nothing, this method must be specified by each agent type. Probably needs a subclass responsibility statement