Agent#

class pams.agents.Agent(agent_id, prng, simulator, name, logger=None)[source]#

Agent class (abstract class)

Once you define the agent class inheriting this agent ABC class, simulator automatically generate agents using the class you define. Therefore, you don’t need to call __init__ or any other method and simulator automatically call them if it is necessary.

submit_orders(self, markets: List[Market]) is required to be implemented.

See also

canceled_order(log)[source]#

call back when cancel order is accepted by a market.

Parameters:

log (CancelLog) – log for order cancellation

Return type:

None

Returns:

None

executed_order(log)[source]#

call back when a submitted order is executed in a market.

Parameters:

log (ExecutionLog) – log for order execution

Return type:

None

Returns:

None

get_asset_volume(market_id)[source]#

getter of the asset volume held by the agent.

Parameters:

market_id (int) – market ID.

Returns:

asset volume for the specified market ID.

Return type:

int

get_cash_amount()[source]#

getter of the cash amount held by the agent.

Returns:

cash amount held by this agent.

Return type:

float

get_prng()[source]#

getter of the pseudo random number generator.

Returns:

pseudo random number generator for this agent.

Return type:

random.Random

is_market_accessible(market_id)[source]#

determine if the market ID is included in the asset volume

Parameters:

market_id (int) – market ID.

Returns:

whether the asset volume held by the agent contains the specified market or not.

Return type:

bool

set_asset_volume(market_id, volume)[source]#

setter of the asset volume held by agent.

Parameters:
  • market_id (int) – market ID.

  • volume (int) – volume to be set for the market

Return type:

None

Returns:

None

set_cash_amount(cash_amount)[source]#

setter of the cash amount held by agent.

Parameters:

cash_amount (float) – cash amount held by this agent.

Return type:

None

Returns:

None

set_market_accessible(market_id)[source]#

set the specified market volume to 0.

Parameters:

market_id (int) – market ID.

Return type:

None

Returns:

None

setup(settings, accessible_markets_ids, *args, **kwargs)[source]#

agent setup. Usually be called from simulator/runner automatically.

Parameters:
  • settings (Dict[str, Any]) – agent configuration. Usually, automatically set from json config of simulator. This must include the parameters “cashAmount” and “assetVolume”.

  • accessible_markets_ids (List[int]) – list of market IDs.

Return type:

None

Returns:

None

abstract submit_orders(markets)[source]#

submit orders (abstract method). This method automatically called from runners.

This method is called only when this agent has a chance to submit orders. Therefore, it is not guaranteed that this method is called at all the step of simulation.

Parameters:

markets (List[Market]) – markets to order.

Returns:

order list.

Return type:

List[Union[Order, Cancel]]

Note

You should implement this method if you inherit this agent.

submitted_order(log)[source]#

call back when an order submission is accepted by a market.

Parameters:

log (OrderLog) – log for order submission

Return type:

None

Returns:

None

update_asset_volume(market_id, delta)[source]#

increasing or decreasing the asset volume.

Parameters:
  • market_id (int) – market ID.

  • delta (int) – amount of change in the asset volume.

Return type:

None

Returns:

None

update_cash_amount(delta)[source]#

increasing or decreasing the cash amount.

Parameters:

delta (float) – amount of change in the cash amount.

Return type:

None

Returns:

None