agentsociety.cityagent.bankagent¶
Module Contents¶
Classes¶
Configuration for BankAgent. |
|
A central banking agent that manages monetary policy in the simulation. |
Functions¶
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.AgentParamsConfiguration for BankAgent.
- 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.BankAgentBaseA central banking agent that manages monetary policy in the simulation.
Key Responsibilities:
Adjusts interest rates based on inflation trends (Taylor Rule implementation)
Applies interest to citizens’ savings periodically
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
- 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:
Applies interest to citizens’ savings
Adjusts interest rate based on inflation (Taylor Rule)