Reference 〉 Function

baseAgent.trade(partnerAgent, good1str, amt1num, good2str, amt2num)

Exchanges a quantity of one good for a quantity of another good, and records the demand for each. Requires at least two goods to have been registered, but does not require a monetary good. Ordinary usage would be giving up amt1 of good1 to get amt2 of good2, but negative amounts can reverse the direction.

Parameters

  • partner Agent, required

    The agent object of the trading partner. The agent object can be retrieved by ID with model.agent().

  • good1 str, required

    The good to be sold (if amt1>0) or bought (if amt1<0). This good must have been previously registered with Goods.add().

  • amt1 num, required

    The amount of good1 to give up. Note that amt1 can be negative, in which case the agent buys an amount of good1.

  • good2 str, required

    The good to be bought (if amt2>0) or sold (if amt2<0). This good must have been previously registered with Goods.add().

  • amt2 num, required

    The amount of good2 to obtain. Note that amt2 can be negative, in which case the agent sells an amount of good2.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.