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 e-mail:antderu@libero.it, Integrations of Bruno Mencarelli
See Also:
Serialized Form

Field Summary
 java.util.ArrayList buyOrderStorehouse
          The arrayList which contains the buy orders.
 java.util.ArrayList buyOrderWithAuctionPriceStorehouse
          The arrayList which contains the buy orders with auction price.
 java.util.ArrayList closingContractLog
          The arrayList to log the closing contracts.
 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.
 int instantNumber
          The total number of instant.
 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 nOfBuyOrderWithAuctionPrice
          The number of buy order with auction price.
 int nOfBuySharesWithAuctionPrice
          The number ofshares with auction price in buy side.
 int nOfSellOrderWithAuctionPrice
          The number of sell order with auction price.
 int nOfSellSharesWithAuctionPrice
          The number ofshares with auction price in sell side.
 int numberOfInstant
          The number of actual instant.
 double openingPrice
          The opening price.
 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.
 double referencePrice
          The reference price of each days.
 java.util.ArrayList sellOrderStorehouse
          The arrayList which contains the sell orders.
 java.util.ArrayList sellOrderWithAuctionPriceStorehouse
          The arrayList which contains the sell orders with auction price.
 int sharesInBuySide
          The number of shares in buy side of book.
 int sharesInBuySideInOpeningOrClosingAuctions
          The number of shares in buy side of book in opening or closing Auctions.
 int sharesInSellSide
          The number of shares in sell side of book.
 int sharesInSellSideInOpeningOrClosingAuctions
          The number of shares in sell side of book in opening or closing Auctions.
 java.util.ArrayList tableForTheoreticalPrice
          The arrayList as a table to evaluete the teoric price.
 double theoreticalPrice
          The theoretical price.
 
Constructor Summary
Book(Zone aZone)
          Constructor for a new book.
 
Method Summary
private  double extract(java.util.ArrayList nameList, int indexOrder, int positionDatum)
          To extract data from the orders received from agents.
private  int fillStorehouseDecreasingP(double newPrice)
          To fill buyOrderStorehouse in descreasing order.
private  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 getSharesInBuySideInOpeningOrClosingAuctions()
          To get the number of shares in buy side in opening or closing Auctions.
 int getSharesInSellSide()
          To get the number of shares filled in the sell side of book.
 int getSharesInSellSideInOpeningOrClosingAuctions()
          To get the number of shares in sell side in opening or closing Auctions.
 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 opening()
          To conclude contracts (if opening price > 0) or to fill the order with auction price.
 void recreateTableForTheoreticalPrice()
           
 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 setInstantNumber(int n)
          To set the value of total number of instant
 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 setNumberOfInstant()
          To set the value of actual instant
 void setOpeningPrice()
          To set the opening price.
 void setOrderFromAgent(double[] orderFromAgent)
          Receiving an order when the market is open.
 void setOrderInOpeningOrClosingAuctionsFromAgent(double[] orderFromAgent)
          Receiving an order in opening or closing Auctions from an agent.
 void setPrinting(int p)
          To set the value of option printing.
 void setRefencePrice()
          At the end of each day to calculate the reference price.
private  double[] setRows(double[] order)
          To set rows in tableForTheoreticalPrice.
private  void setTableForTheoreticalPrice(double[] order)
          To set the prices in decreasing order for evaluete the theoretical price.
 void setTheoreticalPrice()
          To set the theoretical price.
private  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.


instantNumber

public int instantNumber
The total number of instant.


numberOfInstant

public int numberOfInstant
The number of actual instant.


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.


sharesInBuySideInOpeningOrClosingAuctions

public int sharesInBuySideInOpeningOrClosingAuctions
The number of shares in buy side of book in opening or closing Auctions.


sharesInSellSideInOpeningOrClosingAuctions

public int sharesInSellSideInOpeningOrClosingAuctions
The number of shares in sell side of book in opening or closing Auctions.


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
The arrayList which contains the buy orders.


sellOrderStorehouse

public java.util.ArrayList sellOrderStorehouse
The arrayList which contains the sell orders.


closingContractLog

public java.util.ArrayList closingContractLog
The arrayList to log the closing contracts.


tableForTheoreticalPrice

public java.util.ArrayList tableForTheoreticalPrice
The arrayList as a table to evaluete the teoric price.


buyOrderWithAuctionPriceStorehouse

public java.util.ArrayList buyOrderWithAuctionPriceStorehouse
The arrayList which contains the buy orders with auction price.


sellOrderWithAuctionPriceStorehouse

public java.util.ArrayList sellOrderWithAuctionPriceStorehouse
The arrayList which contains the sell orders with auction price.


referencePrice

public double referencePrice
The reference price of each days.


theoreticalPrice

public double theoreticalPrice
The theoretical price.


openingPrice

public double openingPrice
The opening price.


nOfBuyOrderWithAuctionPrice

public int nOfBuyOrderWithAuctionPrice
The number of buy order with auction price.


nOfSellOrderWithAuctionPrice

public int nOfSellOrderWithAuctionPrice
The number of sell order with auction price.


nOfBuySharesWithAuctionPrice

public int nOfBuySharesWithAuctionPrice
The number ofshares with auction price in buy side.


nOfSellSharesWithAuctionPrice

public int nOfSellSharesWithAuctionPrice
The number ofshares with auction price in sell side.


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

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


extract

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


fillStorehouseIncreasingP

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


fillStorehouseDecreasingP

private 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.


setPrinting

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


setInstantNumber

public void setInstantNumber(int n)
To set the value of total number of instant


setAgentListIndex

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


setNumberOfInstant

public void setNumberOfInstant()
To set the value of actual instant


setMeanPrice

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


setRefencePrice

public void setRefencePrice()
At the end of each day to calculate the reference price.


setClean

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


setRows

private double[] setRows(double[] order)
To set rows in tableForTheoreticalPrice.


setTableForTheoreticalPrice

private void setTableForTheoreticalPrice(double[] order)
To set the prices in decreasing order for evaluete the theoretical price.


setTheoreticalPrice

public void setTheoreticalPrice()
To set the theoretical price.


setOpeningPrice

public void setOpeningPrice()
To set the opening price.


opening

public void opening()
To conclude contracts (if opening price > 0) or to fill the order with auction price.


recreateTableForTheoreticalPrice

public void recreateTableForTheoreticalPrice()

setOrderInOpeningOrClosingAuctionsFromAgent

public void setOrderInOpeningOrClosingAuctionsFromAgent(double[] orderFromAgent)
Receiving an order in opening or closing Auctions 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.


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.


getSharesInSellSideInOpeningOrClosingAuctions

public int getSharesInSellSideInOpeningOrClosingAuctions()
To get the number of shares in sell side in opening or closing Auctions.


getSharesInBuySideInOpeningOrClosingAuctions

public int getSharesInBuySideInOpeningOrClosingAuctions()
To get the number of shares in buy side in opening or closing Auctions.


getLaggedMeanPrice

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


getLocalHistory

public int getLocalHistory()
to get the local History.