Class Book

java.lang.Object
  extended bySwarmObjectImpl
      extended byBook

public class Book
extends SwarmObjectImpl

This is the book. The book works on the basis of two arrayList containing sell order in increasing order or buy order in decreasing order. The orders are arrays which have in the first position the price, in the second the number of agent who places the order and in the third the quantity. If an order obtains an immediate matching, it is not filed

Author:
Antonio de Ruvo, integrazioni da parte di Bruno Mencarelli, antderu@libero.it
See Also:
Serialized Form

Field Summary
 java.util.ArrayList buyOrderStorehouse
           
 int count
          The number of share negotiated
 double currentMeanPrice
          The addition of prices*quantity to calculate the mean price.
 double executedPrice
          The price of the last contract closing.
 ListIndex indexAgentListIndex
          The index used for send message to agents.
 double[] localHistory
          The vector containing the local price history.
 int localHistoryLength
          The length of the local price history.
 double meanPrice
          The mean price of yesterday.
 double[] meanPriceHistory
          The vector containing the history of mean prices.
 int meanPriceHistoryLength
          The length of the mean price history.
 int orderNumber
          The number of orders received from agents.
 double previousClosingPrice
          The closing price of yesterday.
 int printing
          If 1 many objects print data on the terminal window.
 java.util.ArrayList sellOrderStorehouse
           
 int sharesInBuySide
          The number of shares in buy side of book.
 int sharesInBuySideBeforeOpening
          The number of shares in buy side of book before opening.
 int sharesInSellSide
          The number of shares in sell side of book.
 int sharesInSellSideBeforeOpening
          The number of shares in sell side of book before opening.
 
Constructor Summary
Book(Zone aZone)
          Constructor for a new book.
 
Method Summary
 double extract(java.util.ArrayList nameList, int indexOrder, int positionDatum)
          To extract data from the orders received from agents.
 int fillStorehouseDecreasingP(double newPrice)
          To fill buyOrderStorehouse in descreasing order.
 int fillStorehouseIncreasingP(double newPrice)
          To fill sellOrderStorehouse in increasing order
 double getBuyFirstLastSpread()
          To get the spread between the first and the last price in the buy side.
 int getBuySellQuantitySpread()
          To get the spread between quantities in sell and buy side.
 double getLaggedMeanPrice(int lag)
          to get the lagged Mean Price.
 int getLocal(double[] vect)
          This is the getLocal method, that counts for the difference between the buying and selling orders sent by the agents.
 int getLocalHistory()
          to get the local History.
 double getMeanPrice()
          To get the mean price of yesterday.
 double getPreviousClosingPrice()
          To get the closing price of yesterday.
 double getPrice()
          To get the last executed price.
 double getSellFirstLastSpread()
          To get the spread between the first and the last price in the sell side.
 int getSharesInBuySide()
          To get the number of shares filled in the buy side of book.
 int getSharesInBuySideBeforeOpening()
          To get the number of shares in buy side before opening.
 int getSharesInSellSide()
          To get the number of shares filled in the sell side of book.
 int getSharesInSellSideBeforeOpening()
          To get the number of shares in sell side before opening.
 double getSpread()
          To get the spread between first bid and first ask price.
private  void message(double n, double p, double q)
          To inform the agent of executed price.
 void setAgentListIndex(ListIndex i)
          To know the adress of memory of the agent.
 void setClean()
          At the beginning of each day to clean the book.
 void setLocal(double[] vect, double p)
          This is the SetLocal method, used to shift the rows of the localHistory vector.
 void setMeanPrice()
          At the end of each day to calculate the mean price.
 void setOrderBeforeOpeningFromAgent(double[] orderFromAgent)
          Receiving an order before opening from an agent.
 void setOrderFromAgent(double[] orderFromAgent)
          Receiving an order when the market is open.
 void setPrinting(int p)
          To set the value of option printing.
 double[] standardizedOrder(double[] orderFromAgent)
          To standardize the order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexAgentListIndex

public ListIndex indexAgentListIndex
The index used for send message to agents.


printing

public int printing
If 1 many objects print data on the terminal window.


orderNumber

public int orderNumber
The number of orders received from agents.


count

public int count
The number of share negotiated


sharesInBuySide

public int sharesInBuySide
The number of shares in buy side of book.


sharesInSellSide

public int sharesInSellSide
The number of shares in sell side of book.


sharesInBuySideBeforeOpening

public int sharesInBuySideBeforeOpening
The number of shares in buy side of book before opening.


sharesInSellSideBeforeOpening

public int sharesInSellSideBeforeOpening
The number of shares in sell side of book before opening.


executedPrice

public double executedPrice
The price of the last contract closing.


meanPrice

public double meanPrice
The mean price of yesterday.


previousClosingPrice

public double previousClosingPrice
The closing price of yesterday.


currentMeanPrice

public double currentMeanPrice
The addition of prices*quantity to calculate the mean price.


buyOrderStorehouse

public java.util.ArrayList buyOrderStorehouse

sellOrderStorehouse

public java.util.ArrayList sellOrderStorehouse

meanPriceHistoryLength

public int meanPriceHistoryLength
The length of the mean price history.


localHistoryLength

public int localHistoryLength
The length of the local price history.


meanPriceHistory

public double[] meanPriceHistory
The vector containing the history of mean prices.


localHistory

public double[] localHistory
The vector containing the local price history.

Constructor Detail

Book

public Book(Zone aZone)
Constructor for a new book.

Method Detail

message

private void message(double n,
                     double p,
                     double q)
To inform the agent of executed price.

See Also:
BasicSumAgent

standardizedOrder

public double[] standardizedOrder(double[] orderFromAgent)
To standardize the order.


extract

public double extract(java.util.ArrayList nameList,
                      int indexOrder,
                      int positionDatum)
To extract data from the orders received from agents.


fillStorehouseIncreasingP

public int fillStorehouseIncreasingP(double newPrice)
To fill sellOrderStorehouse in increasing order


fillStorehouseDecreasingP

public int fillStorehouseDecreasingP(double newPrice)
To fill buyOrderStorehouse in descreasing order.


setLocal

public void setLocal(double[] vect,
                     double p)
This is the SetLocal method, used to shift the rows of the localHistory vector.


getLocal

public int getLocal(double[] vect)
This is the getLocal method, that counts for the difference between the buying and selling orders sent by the agents.


setAgentListIndex

public void setAgentListIndex(ListIndex i)
To know the adress of memory of the agent.


setPrinting

public void setPrinting(int p)
To set the value of option printing.


setMeanPrice

public void setMeanPrice()
At the end of each day to calculate the mean price.


setClean

public void setClean()
At the beginning of each day to clean the book.


setOrderBeforeOpeningFromAgent

public void setOrderBeforeOpeningFromAgent(double[] orderFromAgent)
Receiving an order before opening from an agent.


setOrderFromAgent

public void setOrderFromAgent(double[] orderFromAgent)
Receiving an order when the market is open.


getPrice

public double getPrice()
To get the last executed price.


getMeanPrice

public double getMeanPrice()
To get the mean price of yesterday.


getLaggedMeanPrice

public double getLaggedMeanPrice(int lag)
to get the lagged Mean Price.


getLocalHistory

public int getLocalHistory()
to get the local History.


getSharesInSellSide

public int getSharesInSellSide()
To get the number of shares filled in the sell side of book.


getSharesInBuySide

public int getSharesInBuySide()
To get the number of shares filled in the buy side of book.


getPreviousClosingPrice

public double getPreviousClosingPrice()
To get the closing price of yesterday.


getSellFirstLastSpread

public double getSellFirstLastSpread()
To get the spread between the first and the last price in the sell side.


getBuyFirstLastSpread

public double getBuyFirstLastSpread()
To get the spread between the first and the last price in the buy side.


getSpread

public double getSpread()
To get the spread between first bid and first ask price.


getBuySellQuantitySpread

public int getBuySellQuantitySpread()
To get the spread between quantities in sell and buy side.


getSharesInSellSideBeforeOpening

public int getSharesInSellSideBeforeOpening()
To get the number of shares in sell side before opening.


getSharesInBuySideBeforeOpening

public int getSharesInBuySideBeforeOpening()
To get the number of shares in buy side before opening.