|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--support.Ticker.RefMarketMaker
|
+--stockmarket.MarketMaker
This class implements the actions of a market maker who handles all the trades for a certain stock.
Buy orders and sell orders sent to the market maker specify the number of share (size) and the price. The market maker assigns a unique ID to each order, which can be later used to cancel the order.
The market maker maintains a priority queue of open buy orders and a priority queue of open sell orders, such that the best bid (highest price of a buy-order) is strictly less than the best ask (lowest price of a sell-order).
Whenever a new order arrives, the market maker tries to match it with open orders of the opposite type. A maximal series of trades are then executed crossing matching orders. Spreads between the prices of matching orders give a profit to the market maker.
The market disseminates the transactions performed by means of the following events:
Each event has an ID, size, and price. Spread events have ID=0.
| Fields inherited from class support.Ticker.RefMarketMaker |
BuyOrders,
IDTable,
SellOrders |
| Constructor Summary | |
MarketMaker()
|
|
| Method Summary | |
java.util.Enumeration |
buyOrder(int size,
int price)
process a buy order |
protected void |
crossOrders(Sequence events)
execute a maximal series of trades by matching open buy and sell orders, and profit from spreads |
protected int |
id(Locator loc)
adaptor |
java.util.Enumeration |
openOrders()
list open orders |
protected int |
price(Locator loc)
adaptor |
protected void |
setID(Locator loc,
int id)
adaptor |
protected void |
setSize(Locator loc,
int size)
adaptor |
protected int |
size(Locator loc)
adaptor |
| Methods inherited from class support.Ticker.RefMarketMaker |
cancel,
sellOrder |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
public MarketMaker()
| Method Detail |
public java.util.Enumeration buyOrder(int size,
int price)
public java.util.Enumeration openOrders()
protected void crossOrders(Sequence events)
protected int price(Locator loc)
protected int size(Locator loc)
protected void setSize(Locator loc,
int size)
protected int id(Locator loc)
protected void setID(Locator loc,
int id)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||