def agent__get_account(self, args): import os from sample_agent import Agent from sample_config import Config # needed for the bankDirectory text = "This test checks agent.get_account \n" text = text + " The purpose of this method is to establish an account for our firm which contains \n" text = text + " all kinds of assets and liabilities. The method simply adds all kinds of assets \n" text = text + " and stores them in one volume. As our firms holds 250.0 assets \n" text = text + " and 250 liabilites the total volume of our account should be 500.0 \n" self.print_info(text) # # INITIALIZATION # environment_directory = str(args[0]) identifier = str(args[1]) log_directory = str(args[2]) # Configure logging parameters so we get output while the program runs logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S', filename=log_directory + identifier + ".log", level=logging.INFO) logging.info('START logging for test agent__get_account in run: %s', environment_directory + identifier + ".xml") # Construct firm filename config = Config() list_env = os.listdir(environment_directory) config.read_xml_config_file(environment_directory + list_env[0]) # get the firm_directory from the environment firm_directory = config.firm_directory # and loop over all firms in the directory listing = os.listdir(firm_directory) firmFilename = firm_directory + listing[0] # generate an agent agent = Agent("baseagent id", {"test": "parameters"}, {"test": "variables"}) agent.identifier = "test_agent" config.agents = [] config.agents.append(agent) agent.get_parameters_from_file(firmFilename, config) agent_helper = Agent("helperagent id", {"test": "parameters"}, {"test": "variables"}) agent_helper.identifier = "helper_agent" config.agents.append(agent_helper) from sample_transaction import Transaction amount = 150.0 transaction = Transaction() transaction.this_transaction("loans", "", agent.identifier, agent_helper.identifier, amount, 0.0, 0, -1) # environment.firms[0] is only for testing purposes DO NOT USE IN PRODUCTION transaction.add_transaction(config) amount = 100.0 transaction = Transaction() transaction.this_transaction("cash", "", agent.identifier, agent_helper.identifier, amount, 0.0, 0, -1) # environment.firms[0] is only for testing purposes DO NOT USE IN PRODUCTION transaction.add_transaction(config) amount = 250.0 transaction = Transaction() transaction.this_transaction("goods", "", agent.identifier, agent_helper.identifier, amount, 0.0, 0, -1) # environment.firms[0] is only for testing purposes DO NOT USE IN PRODUCTION transaction.add_transaction(config) # # TESTING # print(agent.accounts) account = 0.0 # counting all types in account together print(agent.__str__()) # and checking how much is the total # volume of the account for type in ["loans", "cash", "goods"]: if type == "loans": account = account + agent.get_account(type) print("L = " + str(account)) if type == "cash": account = account + agent.get_account(type) print("L+M = " + str(account)) if type == "goods": account = account + agent.get_account(type) print("L+M+G = " + str(account))