Agent#

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

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.

参考

canceled_order(log)[ソース]#

call back when cancel order is accepted by a market.

パラメータ:

log (CancelLog) -- log for order cancellation

戻り値の型:

None

戻り値:

None

executed_order(log)[ソース]#

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

パラメータ:

log (ExecutionLog) -- log for order execution

戻り値の型:

None

戻り値:

None

get_asset_volume(market_id)[ソース]#

getter of the asset volume held by the agent.

パラメータ:

market_id (int) -- market ID.

戻り値:

asset volume for the specified market ID.

戻り値の型:

int

get_cash_amount()[ソース]#

getter of the cash amount held by the agent.

戻り値:

cash amount held by this agent.

戻り値の型:

float

get_prng()[ソース]#

getter of the pseudo random number generator.

戻り値:

pseudo random number generator for this agent.

戻り値の型:

random.Random

is_market_accessible(market_id)[ソース]#

determine if the market ID is included in the asset volume

パラメータ:

market_id (int) -- market ID.

戻り値:

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

戻り値の型:

bool

set_asset_volume(market_id, volume)[ソース]#

setter of the asset volume held by agent.

パラメータ:
  • market_id (int) -- market ID.

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

戻り値の型:

None

戻り値:

None

set_cash_amount(cash_amount)[ソース]#

setter of the cash amount held by agent.

パラメータ:

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

戻り値の型:

None

戻り値:

None

set_market_accessible(market_id)[ソース]#

set the specified market volume to 0.

パラメータ:

market_id (int) -- market ID.

戻り値の型:

None

戻り値:

None

setup(settings, accessible_markets_ids, *args, **kwargs)[ソース]#

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

パラメータ:
  • 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.

戻り値の型:

None

戻り値:

None

abstract submit_orders(markets)[ソース]#

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.

パラメータ:

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

戻り値:

order list.

戻り値の型:

List[Union[Order, Cancel]]

注釈

You should implement this method if you inherit this agent.

submitted_order(log)[ソース]#

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

パラメータ:

log (OrderLog) -- log for order submission

戻り値の型:

None

戻り値:

None

update_asset_volume(market_id, delta)[ソース]#

increasing or decreasing the asset volume.

パラメータ:
  • market_id (int) -- market ID.

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

戻り値の型:

None

戻り値:

None

update_cash_amount(delta)[ソース]#

increasing or decreasing the cash amount.

パラメータ:

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

戻り値の型:

None

戻り値:

None