agentsociety.cityagent.bankagent

Module Contents

Classes

BankAgentConfig

Configuration for BankAgent.

BankAgent

A central banking agent that manages monetary policy in the simulation.

Functions

calculate_inflation

Calculate annual inflation rates based on historical price data.

Data

API

agentsociety.cityagent.bankagent.__all__

[‘BankAgent’]

agentsociety.cityagent.bankagent.calculate_inflation(prices)

Calculate annual inflation rates based on historical price data.

Args: prices (list/np.array): A list of monthly price values

Returns: list: Annual inflation rates in percentages. Returns empty list if insufficient data (less than 2 full years of data).

Logic: 1. Truncates input to full years of data (multiples of 12 months) 2. Reshapes monthly data into yearly groups 3. Computes average price per year 4. Calculates year-over-year inflation rates

class agentsociety.cityagent.bankagent.BankAgentConfig

Bases: agentsociety.agent.AgentParams

Configuration for BankAgent.

time_diff: int

‘Field(…)’

class agentsociety.cityagent.bankagent.BankAgent(id: int, name: str, toolbox: agentsociety.agent.AgentToolbox, memory: agentsociety.memory.Memory, agent_params: Optional[agentsociety.cityagent.bankagent.BankAgentConfig] = None, blocks: Optional[list[agentsociety.agent.Block]] = None)

Bases: agentsociety.agent.BankAgentBase

A central banking agent that manages monetary policy in the simulation.

Key Responsibilities:

  1. Adjusts interest rates based on inflation trends (Taylor Rule implementation)

  2. Applies interest to citizens’ savings periodically

  3. Interacts with economic simulation components via EconomyClient

Configurable Parameters:

  • time_diff: Frequency of policy updates in simulation seconds (default: 30 days)

Initialization

Initialize the banking agent.

  • Args:

    • name (str): The name or identifier of the agent.

    • toolbox (AgentToolbox): The toolbox of the agent.

    • memory (Memory): The memory of the agent.

  • Description:

    • Initializes the banking agent with the provided parameters and sets up necessary internal states.

ParamsType

None

description: str = <Multiline-String>
async reset()

Reset the BankAgent.

async month_trigger() → bool

Check if monthly policy update should be triggered.

Returns: bool: True if required time interval has passed since last update

Note: Uses simulation time rather than real-world time

async forward()

Execute monthly policy update cycle.

Performs two main actions:

  1. Applies interest to citizens’ savings

  2. Adjusts interest rate based on inflation (Taylor Rule)