Class StopLossAgent

java.lang.Object
  extended bySwarmObjectImpl
      extended byBasicSumAgent
          extended byStopLossAgent

public class StopLossAgent
extends BasicSumAgent

StopLossAgent inherits from BasicSumAgent and operates in random way, like a random agent. After that, its behavior can be modified by a "stop loss" decision, operating in two possible ways (i) without memory: if the current price, i.e. the last executedPrice (at day t) is >= to (mean price at day t-stopLossInterval) *(1+maxLossRate) <= to (mean price at day t-stopLossInterval) *(1-maxLossRate) and checkingIfShortOrLong=0, the agent buys/sells, at the current price, a quantity of shares between 1 and maxOrderQuantity; (ii) with memory (the short or long position of the agent is taken in account; if the agent has no position, doesn't operate here): if the current price, i.e. the last executedPrice (at day t) is >= to (mean price at day t-stopLossInterval) *(1+maxLossRate) <= to (mean price at day t-stopLossInterval) *(1-maxLossRate) and checkingIfShortOrLong=1, the agent buys if short (shareQuantity<0); sells if long (shareQuantity>0) at the current price, a quantity of shares between 1 and maxOrderQuantity (regardless its shareQuantity value).

Author:
Bruno Mencarelli
See Also:
Serialized Form

Field Summary
(package private)  int checkingIfShortOrLong
          These are the variables that the agent checks for the stop-loss strategy.
(package private)  double maxLossRate
          THis is the maximun rate of loss that the agent will accept before appliying the strategy.
 double[] order
          This is the vector containing the basic input of an order: the price of the offer, the quantity of shares and the identification number of the agent.
 StopLossRuleMaster ruleMaster
          This is the RuleMaster of the stop loss agent.
(package private)  int stopLossInterval
          These are the variables that the agent checks for the stop-loss strategy.
 
Fields inherited from class BasicSumAgent
agentWealthAtMeanDailyPrice, asymmetricBuySellProb, buySellSwitch, executedPrices, iMax, liquidityQuantity, maxOrderQuantity, meanOperatingPrice, number, price, printing, shareQuantity, shareValueAtMeanDailyPrice, theBook
 
Constructor Summary
StopLossAgent(Zone aZone, int maxOrderQuantity)
          Constructor for a new stop loss agent.
 
Method Summary
 void act0()
          This method is called in the first phase of the day.
 void act1()
          This method is called during the simulated day.
 void setMaxLossRate$andCheckingIfShortOrLong(double r, int sl)
          This method sets the maxlossrate and the option checking if short or long.
 void setRuleMaster(StopLossRuleMaster r)
          This method stes the Rule Master.
 void setStopLossInterval(int i)
          This method sets the stoplossinterval.
 
Methods inherited from class BasicSumAgent
act2, extract, getWealthAtMeanDailyPrice, setAsymmetricBuySellProb, setBook, setConfirmationOfExecutedPrice, setMaxOrderQuantity, setNumber, setPrinting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

order

public double[] order
This is the vector containing the basic input of an order: the price of the offer, the quantity of shares and the identification number of the agent.


stopLossInterval

int stopLossInterval
These are the variables that the agent checks for the stop-loss strategy.


checkingIfShortOrLong

int checkingIfShortOrLong
These are the variables that the agent checks for the stop-loss strategy.


maxLossRate

double maxLossRate
THis is the maximun rate of loss that the agent will accept before appliying the strategy.


ruleMaster

public StopLossRuleMaster ruleMaster
This is the RuleMaster of the stop loss agent.

Constructor Detail

StopLossAgent

public StopLossAgent(Zone aZone,
                     int maxOrderQuantity)
Constructor for a new stop loss agent.

Method Detail

setRuleMaster

public void setRuleMaster(StopLossRuleMaster r)
This method stes the Rule Master.


setStopLossInterval

public void setStopLossInterval(int i)
This method sets the stoplossinterval.


setMaxLossRate$andCheckingIfShortOrLong

public void setMaxLossRate$andCheckingIfShortOrLong(double r,
                                                    int sl)
This method sets the maxlossrate and the option checking if short or long.


act0

public void act0()
This method is called in the first phase of the day.

Overrides:
act0 in class BasicSumAgent

act1

public void act1()
This method is called during the simulated day. The agent acts in the market.

Overrides:
act1 in class BasicSumAgent