public class Agent
submitOrders(List[Market])
to implement a trading strategy.
submitOrders(Market)
would not work expectedly.
Market#handleOrders(List[Order])
in submitOrders(List[Market])
family.
setMarketAccessible(Market)
to tell the agent to enter that market.
setMarketAccessible(Market)
, getAssetVolume(Market)
will raise an error.
getRandom()
and do NOT make new Random()
.
Modifier and Type | Field and Description |
---|---|
Map<Long,Long> |
assetsVolumes
A mapping from markets (id) to the volumes of the assets.
|
Double |
cashAmount
The amount of cash.
|
Long |
id
The id of this agent assigned by the system (DON'T CHANGE IT).
|
String |
name
The JSON object name (DON'T CHANGE IT).
|
Random |
random
The RNG given by the system (DON'T CHANGE IT).
|
Modifier and Type | Method and Description |
---|---|
Long |
getAssetVolume(Market market) |
Long |
getAssetVolume(Long id) |
Double |
getCashAmount() |
Random |
getRandom() |
Boolean |
isMarketAccessible(Market market) |
Boolean |
isMarketAccessible(Long id) |
Long |
nextOrderId()
Get the next order id.
|
void |
orderExecuted(Market market,
Long orderId,
Double price,
Double cashAmountDelta,
Long assetVolumeDelta)
Callback when one's order is executed at the market.
|
Long |
setAssetVolume(Market market,
Long assetVolume) |
Long |
setAssetVolume(Long id,
Long assetVolume) |
Double |
setCashAmount(Double cashAmount) |
Long |
setId(Long id)
For system use only.
|
Long |
setMarketAccessible(Market market) |
Long |
setMarketAccessible(Long id) |
String |
setName(String name)
For system use only.
|
Random |
setRandom(Random random)
For system use only.
|
List<Order> |
submitOrders(Market market)
Submit orders to the market.
|
List<Order> |
submitOrders(List<Market> markets)
Submit orders to the markets.
|
String |
toString() |
Long |
updateAssetVolume(Market market,
Long delta) |
Long |
updateAssetVolume(Long id,
Long delta) |
Double |
updateCashAmount(Double delta) |
public Long id
public String name
public Random random
public Double cashAmount
public Map<Long,Long> assetsVolumes
public Long setId(Long id)
public String setName(String name)
public Random getRandom()
public Random setRandom(Random random)
public List<Order> submitOrders(List<Market> markets)
markets
- a list of all markets (but some may not be up-to-date).public List<Order> submitOrders(Market market)
submitOrders(List[Market])
.markets
- a list of all markets (but some may not be up-to-date).public Boolean isMarketAccessible(Long id)
public Boolean isMarketAccessible(Market market)
public Long setMarketAccessible(Long id)
public Long setMarketAccessible(Market market)
public Double getCashAmount()
public Double setCashAmount(Double cashAmount)
public Double updateCashAmount(Double delta)
public Long getAssetVolume(Long id)
public Long setAssetVolume(Long id, Long assetVolume)
public Long getAssetVolume(Market market)
Exception
- if isMarketAccessible(market)
is false.public Long setAssetVolume(Market market, Long assetVolume)
Exception
- if isMarketAccessible(market)
is false.public Long updateAssetVolume(Long id, Long delta)
Exception
- if isMarketAccessible(market)
is false.public Long updateAssetVolume(Market market, Long delta)
public void orderExecuted(Market market, Long orderId, Double price, Double cashAmountDelta, Long assetVolumeDelta)
orderId
- (0 if unspecified)market
- price
- the price at which the order is executedcashAmountDelta
- how much changedassetVolumeDelta
- how much changedpublic Long nextOrderId()
plham.Order
.
To enable automated order numbering, override this method and return unique integers.plham.OrderBook
public String toString()