public class Market
handleOrders(List[Order])
and handleOrder(Order)
to implement a matching mechanism.
handleOrder(Order)
).
handleOrders(List[Order])
family in Agent#submitOrders(List[Market])
.
On events, it currently supports four places to register.
Modifier and Type | Class and Description |
---|---|
static class |
Market.AgentUpdate |
static class |
Market.ExecutionLog |
static interface |
Market.MarketEvent |
static interface |
Market.OrderEvent |
Modifier and Type | Field and Description |
---|---|
Double |
NO_TICKSIZE |
static Fun_0_2 <Double,Double,Double> |
ROUND_LOWER
Field Type: (Double,Double)=>Double
|
static Fun_0_2 <Double,Double,Double> |
ROUND_UPPER
Field Type: (Double,Double)=>Double
|
Boolean |
_isRunning |
List<Market.OrderEvent> |
afterOrderHandlingEvents |
List<Market.MarketEvent> |
afterSimulationStepEvents |
List<List<Market.AgentUpdate>> |
agentUpdates |
List<Market.OrderEvent> |
beforeOrderHandlingEvents |
List<Market.MarketEvent> |
beforeSimulationStepEvents |
OrderBook |
buyOrderBook |
List<Long> |
buyOrdersCounts |
Env |
env |
List<Long> |
executedOrdersCounts |
List<List<Market.ExecutionLog>> |
executionLogs |
List<Double> |
fundamentalPrices |
Long |
id
The id of this market assigned by the system.
|
List<Double> |
lastExecutedPrices |
List<Double> |
marketPrices |
String |
name
The JSON object name.
|
Long |
outstandingShares |
Random |
random
The RNG given by the system (DON'T CHANGE IT).
|
OrderBook |
sellOrderBook |
List<Long> |
sellOrdersCounts |
List<Long> |
sumExecutedVolumes |
Double |
tickSize |
Time |
time
NOTE: Use
getTime() instead. |
Modifier and Type | Method and Description |
---|---|
Boolean |
addAfterOrderHandlingEvent(Market.OrderEvent e) |
Boolean |
addAfterSimulationStepEvent(Market.MarketEvent e) |
Boolean |
addBeforeOrderHandlingEvent(Market.OrderEvent e) |
Boolean |
addBeforeSimulationStepEvent(Market.MarketEvent e) |
protected void |
cancelBuyOrder(Order order) |
protected void |
cancelSellOrder(Order order) |
void |
check() |
void |
executeAgentUpdate(List<Agent> agents,
Market.AgentUpdate update) |
protected void |
executeBuyOrders(Order buyOrder,
Order sellOrder) |
protected void |
executeOrders(Double price,
Order buyOrder,
Order sellOrder,
Boolean isSellMajor)
Exchange the cash and assets between the buyer and seller.
|
protected void |
executeSellOrders(Order sellOrder,
Order buyOrder) |
Double |
getBestBuyPrice()
Get the best (highest) buy/bid price.
|
Double |
getBestSellPrice()
Get the best (lowest) sell/ask price.
|
OrderBook |
getBuyOrderBook()
Declaration: getBuyOrderBook():plham.OrderBook.
|
Double |
getFundamentalPrice() |
Double |
getFundamentalPrice(Long t) |
Double |
getMarketPrice() |
Double |
getMarketPrice(Long t) |
Double |
getMidPrice()
Get the mid price, the average (middle) of the best buy/bid and sell/ask prices.
|
Double |
getNextMarketPrice()
Return the next market price at t + 1.
|
Long |
getOutstandingShares() |
Double |
getPrice() |
Double |
getPrice(Long t) |
Random |
getRandom() |
OrderBook |
getSellOrderBook()
Declaration: getSellOrderBook():plham.OrderBook.
|
Double |
getTickSize()
Declaration: getTickSize():Double.
See also
roundPrice() . |
Long |
getTime()
Declaration: getTime():Long.
|
Long |
getTradeVolume() |
Long |
getTradeVolume(Long t) |
void |
handleAgentUpdate(Market.AgentUpdate update) |
protected void |
handleBuyLimitOrder(Order buyOrder) |
protected void |
handleBuyMarketOrder(Order buyOrder) |
protected void |
handleBuyOrder(Order order) |
void |
handleOrder(Order order)
Handle orders from some agents.
|
void |
handleOrders(List<Order> orders)
Handle orders from some agents.
|
protected void |
handleSellLimitOrder(Order sellOrder) |
protected void |
handleSellMarketOrder(Order sellOrder) |
protected void |
handleSellOrder(Order order) |
Boolean |
isRunning()
Whether this market is open or not (closed).
|
void |
itayoseOrderBooks()
Perform the itayose method for clearance of matched orders.
|
Double |
roundBuyPrice(Double price) |
Order |
roundPrice(Order order)
Round the price of the order in increments of a tick size.
|
Double |
roundSellPrice(Double price) |
Long |
setId(Long id)
Declaration: setId(id:Long):Long.
For system use only.
|
void |
setInitialFundamentalPrice(Double price) |
void |
setInitialMarketPrice(Double price) |
String |
setName(String name)
Declaration: setName(name:String):String.
For system use only.
|
Long |
setOutstandingShares(Long outstandingShares)
Declaration: setOutstandingShares(outstandingShares:Long):Long.
|
Random |
setRandom(Random random)
For system use only.
|
Boolean |
setRunning(Boolean isRunning)
Declaration: setRunning(isRunning:Boolean):Boolean.
|
Double |
setTickSize(Double tickSize)
Declaration: setTickSize(tickSize:Double):Double.
Note:
tickSize <= 0.0 means no tick size. |
Long |
setTime(Long time)
Declaration: setTime(time:Long):Long.
|
Long |
setTradeVolume(Long t,
Long tradeVolume) |
void |
tickUpdateMarketPrice() |
void |
triggerAfterOrderHandlingEvents(Order order) |
void |
triggerAfterSimulationStepEvents() |
void |
triggerBeforeOrderHandlingEvents(Order order) |
void |
triggerBeforeSimulationStepEvents() |
void |
updateFundamentalPrice(Double price) |
void |
updateMarketPrice() |
void |
updateMarketPrice(Double price) |
void |
updateOrderBooks()
Remove all expired and no-volume orders.
|
Long |
updateTime()
Declaration: updateTime():Long.
|
public Long id
public String name
public Random random
public Boolean _isRunning
public OrderBook buyOrderBook
public OrderBook sellOrderBook
public Long outstandingShares
public Time time
getTime()
instead.public Env env
public Double tickSize
public final Double NO_TICKSIZE
public static final Fun_0_2 <Double,Double,Double> ROUND_UPPER
public static final Fun_0_2 <Double,Double,Double> ROUND_LOWER
public List<Double> marketPrices
public List<Double> fundamentalPrices
public List<Double> lastExecutedPrices
public List<Long> sumExecutedVolumes
public List<Long> buyOrdersCounts
public List<Long> sellOrdersCounts
public List<Long> executedOrdersCounts
public List<List<Market.ExecutionLog>> executionLogs
public List<List<Market.AgentUpdate>> agentUpdates
public List<Market.OrderEvent> beforeOrderHandlingEvents
public List<Market.OrderEvent> afterOrderHandlingEvents
public List<Market.MarketEvent> beforeSimulationStepEvents
public List<Market.MarketEvent> afterSimulationStepEvents
public Long setId(Long id)
For system use only.
public String setName(String name)
For system use only.
public Random getRandom()
public Random setRandom(Random random)
public void handleOrders(List<Order> orders)
handleOrder(Order)
.orders
- a list of orders.public void handleOrder(Order order)
orders
- an order to this market.protected void cancelBuyOrder(Order order)
protected void cancelSellOrder(Order order)
protected void handleBuyOrder(Order order)
protected void handleSellOrder(Order order)
protected void handleBuyLimitOrder(Order buyOrder)
protected void handleSellLimitOrder(Order sellOrder)
protected void handleBuyMarketOrder(Order buyOrder)
protected void handleSellMarketOrder(Order sellOrder)
public void updateOrderBooks()
public void itayoseOrderBooks()
updateOrderBooks()
will be called after this method.public Boolean isRunning()
public Boolean setRunning(Boolean isRunning)
public Double getTickSize()
See also
roundPrice()
.public Double setTickSize(Double tickSize)
Note:
tickSize <= 0.0
means no tick size.public Order roundPrice(Order order)
order
in place and return it.public Double roundBuyPrice(Double price)
public Double roundSellPrice(Double price)
public Double getNextMarketPrice()
updateMarketPrice()
for this purpose.public void tickUpdateMarketPrice()
public void updateMarketPrice()
public void updateMarketPrice(Double price)
public void updateFundamentalPrice(Double price)
public void setInitialMarketPrice(Double price)
public void setInitialFundamentalPrice(Double price)
public Double getPrice()
public Double getPrice(Long t)
public Double getMarketPrice()
public Double getMarketPrice(Long t)
public Double getFundamentalPrice()
public Double getFundamentalPrice(Long t)
public OrderBook getBuyOrderBook()
public OrderBook getSellOrderBook()
public Double getBestBuyPrice()
public Double getBestSellPrice()
public Double getMidPrice()
public Long getOutstandingShares()
public Long setOutstandingShares(Long outstandingShares)
public Long getTime()
public Long setTime(Long time)
public Long updateTime()
public void check()
protected void executeOrders(Double price, Order buyOrder, Order sellOrder, Boolean isSellMajor)
price
is used to exchange.isSellMajor
- is an aux information:
true if the exchange price is determined by an order on the sell orderbook (seller).public Long getTradeVolume()
public Long getTradeVolume(Long t)
public Long setTradeVolume(Long t, Long tradeVolume)
public void handleAgentUpdate(Market.AgentUpdate update)
public void executeAgentUpdate(List<Agent> agents, Market.AgentUpdate update)
public Boolean addBeforeOrderHandlingEvent(Market.OrderEvent e)
public Boolean addAfterOrderHandlingEvent(Market.OrderEvent e)
public Boolean addBeforeSimulationStepEvent(Market.MarketEvent e)
public Boolean addAfterSimulationStepEvent(Market.MarketEvent e)
public void triggerBeforeOrderHandlingEvents(Order order)
public void triggerAfterOrderHandlingEvents(Order order)
public void triggerBeforeSimulationStepEvents()
public void triggerAfterSimulationStepEvents()