net.sf.emarket.trade.domain
Class OrderBook

java.lang.Object
  extended by net.sf.emarket.trade.domain.OrderBook

public class OrderBook
extends java.lang.Object

OrderBook arranges the orders according to their price, in their precedence.

 buy size     price     sell size
 ---------------------------------------
               31.8      20
               31.7      3
               31.6      8
               31.5      
               31.4      10
  5            31.3
  20           31.2
  40           31.1
 

Author:
nambi sankaran

Field Summary
static java.util.Comparator<? super Order> limitPriceComparator
           
static java.util.Comparator<Order> timeComparator
           
 
Constructor Summary
OrderBook(java.lang.String symbol)
           
 
Method Summary
 int findMatchingOrders(ReceivedOrder order, java.util.List<ReceivedOrder> matchedOrders)
          findMatchingOrders creates a list of matching orders from order book.
 java.util.List<PriceDepth> getBuyPriceDepths(int level)
           
 Quote getQuote()
           
 Quote getQuote(Quote quote)
           
 java.util.List<PriceDepth> getSellPriceDepths(int level)
           
 java.lang.String getSymbol()
           
 void loadOrders(java.util.List<ReceivedOrder> orders)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

limitPriceComparator

public static java.util.Comparator<? super Order> limitPriceComparator

timeComparator

public static java.util.Comparator<Order> timeComparator
Constructor Detail

OrderBook

public OrderBook(java.lang.String symbol)
Method Detail

getSymbol

public java.lang.String getSymbol()

loadOrders

public void loadOrders(java.util.List<ReceivedOrder> orders)

getQuote

public Quote getQuote(Quote quote)

getQuote

public Quote getQuote()

getBuyPriceDepths

public java.util.List<PriceDepth> getBuyPriceDepths(int level)

getSellPriceDepths

public java.util.List<PriceDepth> getSellPriceDepths(int level)

findMatchingOrders

public int findMatchingOrders(ReceivedOrder order,
                              java.util.List<ReceivedOrder> matchedOrders)
findMatchingOrders creates a list of matching orders from order book. If there are no matches, the list is empty. The list simply contains a list of orders, that contains the list of matching orders. This method doesn't take care of partial matches.

Parameters:
order -
Returns:


Copyright © 2009. All Rights Reserved.