OrderBook
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
Order books of various kinds may be created to facilitate the trade of a single asset between player/agents.
Specification for the OrderBook interface which each order book must implement:
The interface includes functions to create and cancel LimitOrder and execute market orders, as well as do initialization and bookkeeping
- double executeMarketOrder(OrderType type, int quantity) throws !LiquidityException
- boolean placeLimitOrder(LimitOrder order)
- boolean cancelLimitOrder(LimitOrder order)
- void cleanup() -- this function does periodic bookkeeping and cleanup for the order book
- void setMyWorld(FinancialModel myWorld);
- void setMyID(int a);
It also includes functions to get 'snapshot' meta-data about the OrderBook
- double[] getBuyOrders(); double[] getSellOrders();
- double getAskPrice(); double getBidPrice(); double getSpread();
- double getReturnRate();
- double getReturnRate();
- double getVolume(); double getAverageTradePrice();
- double getRandomComponent() -- returns a commonly shared random value computed each 'step'
Remarks:
See definitions of LimitOrder and GenericPlayer.
The players are responsible for doing accounting about the proceeds and costs of buying and selling the assets. Order books have no knowledge of the actual quantity of asset that are outstanding, or whether the Players actually have enough money or assets on hand to realistically complete the transaction. To that extent, the order books act on faith.
At present several order books have been implemented:
- ContBook, the most basic, handles limit orders, computes the total excess demand and a trade price to clear the market of all trades each step
- DoubleAuctionOrderBook behaves like a typical stock market. Some (patient) traders place limit orders which specify a quantity and price. Other (impatient) traders place market orders which execute immediately at the market price, provided that there is adequate liquidity provided by outstanding limit orders. As implemented, placing or cancelling a limit order takes log time, placing a market order takes constant time, and cleanup takes linear time, all w.r.t. the number of limit orders pending.
- LSBook